Monday, November 08, 2021

Money is Hard in Programming

Last week I wrote about the making change for a dollar project. It got me thinking about how hard dealing with money in programming really is. The problem with money is that 1/10 is an infinitely repeating fraction in Binary.If one adds 1/10

Take the following C$ code.

double penny = 1.0 / 10.0;
double dime = 0.0;
Console.WriteLine(penny);  
for (int I = 0; I < 100; I++)
{
     dime += penny;
}
if (dime == 10.0) Console.WriteLine("Dime");
Console.WriteLine(dime);

One might expect that the word “dime” would be printed but it’s not. What this code actually prints is the following.

0.1
9.99999999999998

The 0.1 is expected but as you can see, adding the 0.1 100 times doesn’t give exactly 10.0. The problem often doesn’t show up right away. This sort of thing often confuses beginners because the programming language “helpfully” hides the issue. When I had the program display the value of “dime” after every addition the discrepancy don’t show up until around 6.0.

5.8
5.9
5.99999999999999

It’s not only beginners who struggle with this issue. It’s a pretty common issue and some languages support a currency data type for that reason. The currency data type adds some overhead to operations and not everyone is a fan of using it. A different alternative is to use integers and insert a decimal point on display.

One of the first programming languages I used for business related software, called DIBOL, didn’t support floating point numbers at all. It supported 18 digits of integer accuracy. It was an interesting language. Using it did make it easier for me to think about using integers for money later in my career though. Most beginners don’t have that sort of a helpful start. They are used to thinking in digital rather than binary. To my way of thinking this reinforces my thinking that learning binary is an important part of computer science education.

Thursday, November 04, 2021

How Many Ways to Make a Dollar

I ran into a reminder of an interesting programming problem the other day. One I meant to use with students but never did. Other teachers I know do use it. Simply pot, how many possible combinations of coins are there that add up to a dollar. It’s easily solved with a set of nested loops like the ones below.

int count = 0;

for (int halves = 0; halves <= 2; halves++)
{
     for (int quarter = 0; quarter <= 4; quarter++)
     {
         for (int dimes = 0; dimes <= 10; dimes++)
         {
             for (int nickels = 0; nickels <= 20; nickels++)
             {
                 for (int penny = 0; penny <= 100; penny++)
                 {
                     int value = halves * 50 + quarter * 25 + dimes * 10 + nickels * 5 + penny;
                     if (value == 100)
                     {
                         count++;
                     }
                 }
             }
         }
     }
}
Console.WriteLine(count);

It’s pretty straight forward. The key thing is understanding what coins there are and what their value it. The code above doesn’t include a dollar coin. Should it? Probably but it depends on the way the problem is specified. Also these are the coins currently being minted. Over the history of the country there have been a number of other coins in circulation

US TREASURY: What denominations of coins are no longer being produced?

There are quite a few denominations of coins that the United States Mint does not produce any longer for general circulation. They are the half-cent coin, the two-cent coin, the three-cent coin, the half-dime coin (although it was replaced by the five-cent coin), a twenty-cent coins, and the various denominations of gold coins. Although the Mint does produce a series of gold bullion coins, these are not intended for circulation.

The problem would be more interesting if some of these were allowed. I keep thinking that there must be another way to solve the problem though. I just can’t think of what it might be.

[Edit] Jeremiah Simmons shared information about solving this problem using Dynamic Programming. It's more complicated but scales better. Take a look. Understanding The Coin Change Problem With Dynamic Programming

It is so sawesome when educators share ideas with each other.

Thursday, September 30, 2021

Define Learn To Code

I saw an interesting question today on Twitter:

My first response is that there is no definitive answer to that question. I thought about it for a while. One can learn to program by hooking a Raspberry Pi to a monitor, keyboard, and mouse and firing up Thonny and learn Python. One can use any number of online IDEs and a Chrome book. The last classes I taught had a mix of students running Eclipse and Processing on Mac and PC laptops with no appreciable difference. In short, does the computer even matter?

Maybe there is a question that has to be asked and answered before discussing the right or best laptop to use. That question is “what does it mean to “learn how to code?” I suspect we could have quite a long discussion on that question alone.

To me it boils down to:

  • What problem are you trying to solve – how do you define “learning to code”
  • What software helps you best learn to code by your definition
  • What hardware runs the software you want to run

Picking the hardware should almost always be the last thing one picks. Now I have to go think about what it means to “learn how to code.”

Sunday, September 26, 2021

Phun With Phone Numbers

Among the programming projects I ran into recently was one to calculate all of the combinations of letters one could make from a phone number. Companies do this sort of thing all the time. They generate the combinations and then look for words related to their business so they can use it as a mnemonic and help people remember their phone number. Probably a bigger deal before domain names than now but still useful.

How many possible combinations are there? Well, that depends. It can be a low or 2187 (3 to the 7th power) and a high of 16384 (4 to the 7th power). The highest number is for phone numbers with all 7s and/or 9s.

I’m trying to write small bits of code to keep my mind active and solving interesting (to me) little programs. Initially I didn’t care to write this program (though eventually I did) so was thinking around the problem from other directions. What if I took a word and had a program generate a phone number? That was fun. And pretty easy. So I thought about the logical (to me anyway) next step. What if I had a list of 7 letter words and generated a file with the phone numbers that matched each word?

It turns out I have a small word list with just under 114,000 words in it. Step one was building a new file with only the seven letter words in it. A nice little project that is simple even for beginners.

I borrowed the code from the earlier program that turned a word into a number. A handy thing that shows the value of methods and reusable code. I used that to create the file with a list of seven letter words and phone numbers. A list of just over 22,000 for what its worth.

When I did write the program to create all the possible combinations of characters for a phone number I had a nice data file to use to check my work. That was surprisingly helpful.

Anyone out there assigning the program to create all the combinations of letters for a phone number? What interesting solutions are students coming up with?

Friday, September 24, 2021

An AI Tutor for CS Education

Recently I came across a Microsoft Research project called AI for Programming Education. The project “goal is to build a personalized and autonomous intelligent teaching assistant (an AI Tutor) for programming education, enabling on-demand education.”

It’s an intriguing and I think ambiguous idea. I tend to be skeptical of AI tutors as a general idea. A half dozen years or so ago I attended a workshop at Microsoft Research dealing with hinting systems. In other words, how can the computer give hints to beginners. I wrote about hinting systems and the workshop here.

The tl;dr is that it is a hard problem. No surprise to teachers of course. Knowing when to hint and how much to hint is a tough problem for human teachers. For a computer AI it is going to be harder still. That’s just one part of what an AI tutor would have to be able to do.

I don’t know any more about the project than what I read on the web page (link above) and that they are looking for a CS Education researcher to help with pedagogy. CS Education/Pedagogy Research Internship Opportunity at Microsoft (AI-driven Program Synthesis in the PROSE team) That is an encouraging move.

With more and more of education moving to the cloud, more and more online curriculum being developed, and systems that are getting smarter about helping programmers to write code (IntelliCode Completion In Visual Studio (Preview) 2022), creating an AI tutor seems like a logical project to take on. I assume papers will be published. I look forward to reading more about this project over time.

Monday, September 20, 2021

Book Review–System Error: Where Big Tech Went Wrong and How We Can Reboot

System Error: Where Big Tech Went Wrong and How We Can Reboot is what you get when a top philosopher, a top political scientist, and a top computer scientist get together to think deeply about technology and society and write a book.  It’s not a book for just one group. It’s not a dry textbook or academic paper but a clearly written explanation of the issues. It’s a book for everyone.

The book talks a lot about both artificial intelligence and social computing which are more connected to each other than may be obvious at times. The social and political impacts of these topics and others are covered in a clear and understandable way without hyperbola, scaremongering, or blatant cheerleading. This is one more thing that makes it stand out from many other books on these topics.

Yes, there are parts that are scary. Yes, there are parts that are optimistic. All in all though it is as fair and open minded a book as one can get. The book askes questions that have to be asked. There is enough data and sets of facts to give one a lot to think about. In fact, I found several times that I had to put the book down to think about what I had read. It’s that sort of book.

Were I teaching Advanced Placement Computer Science today, especially Principles but also APCS A, I would assign reading from it and have class discussions. If I could not get a class set I would at least have some copies in the library put on reserve. But I’d really like my students to read it all.

This is a book that should be on some required reading lists. Computer scientists really do need to think about the “should we do this” question as much as the “can we do this” question. This is the book to start thinking that way. But policymakers need this books as well. So do business people. So give it to the polysci and business majors you know.  A lot of social scientists should read it as well – sociology, psychology, social work. Probably more. It will help one understand what people are dealing with in today’s world.

Technology is impacting society, and our democracy, in many ways. Some are obvious and some are not. If we want to have a civil society we need to think deeply about the impact of technology on individuals and organizations This book is a great way to start.

Friday, September 17, 2021

Debugging–Slow is Smooth and Smooth is Fast

Mike Zamansky had an interesting post called  What They Used To Know that got me thinking about the old days. Now Mike is a youngster and didn’t really start in computers until the 1980s.  I started in the 1970s with punch cards and batch processing. That meant that there was no instant gratification seeing your program run.

With batch, one handed their cards to an operator and some time later, hours or maybe a day, one got their cards back with a listing that showed the results. Results usually meaning a list of errors that kept the program from running.

Desk checking, studying the listing and trying to fix as many errors as possible before trying again was a bit of an art form. To this day I will often print out a program to look at the big picture in a way that still doesn’t feel effective on a screen. It’s tempting to see that as a way to go – limited opportunities to have the computer check ones code.

There are downsides to this sort of thing though. Specifically, having limited runs or at least long waits between runs encourages writing large amounts of code at a time and discourages writing and testing small pieces of code regularly.

Being able to hit “compile” every other minute though tends to encourage, or at least support, the beginner tendency to “throw some code in and see what happens.” This wastes time in the long run and often leads to ugly, hard to maintain, and inefficient code.

The military has a saying that “slow is smooth and smooth is fast” that some what applies. Slowing down to really analyze code, think smoothly, generally leads to a faster result. Tossing code in on a wing and a prayer is not smooth but chaotic. Slowing down to really look at what is happening is smooth and looks slow to the casual viewer but leads to faster results.

As I was thinking tonight and asking, “what if we limited people to some limited number of compiles a day?” It seemed like a good idea until I thought of the possible problems. That’s when I realized that external controls on speed are not the answer. Rather the answer is for developers to regulate themselves. To slow down and focus in ordered to make faster progress.

Tuesday, September 07, 2021

Some Simple Early Programming Projects

If you are not on Twitter you may be missing a lot of good things. For example, the other day Kelly Lougheed (@kellylougheed ) tweeted out a bunch of simple labs that only require user input and mathematical operations. I have copied them below because I want to be able to find them again later.

I’ve used unit conversion for years but it gets old. Fahrenheit to Celsius, miles to kilometers, grams to tons, you get the idea. It gets boring. Kelly has some great ideas. There is an idea from Neil Plotnick (@NeilPlotnick)  below Kelly’s ideas.

Have any more? Add them to the comments for future readers! And be sure to follow @kellylougheed and @NeilPlotnick on Twitter.


Kelly Lougheed (@kellylougheed )

Programming activities that involve ONLY user input and mathematical operations:

  • Program to calculate the tip
  • Program to calculate cost per person when dining out
  • Program to convert units (made-up units like Harry Potter currency okay) What else?

Also just wrote this silly lab where the user can input their age and be told their future in 10/20/30 years ("When you are X years old, you will retire to a desert island", etc.)

0.3 Fortune Teller Lab

Fortune Teller Lab Directions: Where do you see yourself in 10 years? Have the user type in their age, and tell them their future at various ages (which you calculate by adding years to their current…

docs.google.com

And for extensions, I love little math challenges that involve Ss printing out the result of mathematical expressions (getting practice with operators!). For example, there is the Four 4's Challenge, and also this 1996 Challenge:

0.3 1996 Lab

1996 Lab Directions: Use the numerals 1, 9, 9 and 6 exactly in that order to make a mathematical expression that prints the following numbers: 28, 32, 35, 38, 72, 73, 76, 77, 100 and 1000. You can…

docs.google.com


Neil Plotnick replying to @kellylougheed

I have my students code algebra equations like the distance formula. Also stuff for geometry such as area and volume measurements. Ohms law for physics. Ideal gas laws in chemistry.

Saturday, September 04, 2021

Are You Assigning Projects or Recipes?

Chris Lehmann, the amazing principal of Science Leadership Academy in Philadelphia,  says “If you assign a project and get back 30 of the same thing, that’s not a project, that is a recipe.”  Now recipes have their place for sure.  They often make a good start. I see programming as a creative thing (art/craft/skill/science/what ever) and I want to see creativity from my students.

For me this starts with day one. In my introduction to my classes I tell students that I want to see creativity. I want them to make projects their own. This can be a difficult thing for some students. There are teachers out there who do want to see the same thing from every student. It makes things easy to grade I guess. Or something.

Very often in early projects is is hard to be creative. There are only so many ways to calculate degrees Fahrenheit to Celsius. On the other hand you can ask students to find two measurements they like and convert one of them to the other. You’ll be amazed at the combinations students come up with. Sure you’ll get the simple conversion using degrees Kelvin but someone will do miles to furlongs.

Even simple programs can get creative with tools that make graphics easy. C# and Visual Basic both have the Windows Forms libraries to use but Processing can make using Java or Python colorful and graphic as well. To say nothing of a lot of block programming systems.

Of course, students getting bogged down in how a program looks can be an issue at times but that can be dealt with though conversation.

An even better way is often letting students choose their own projects. I always finish up a semester with a larger project that students select themselves. Student get very creative with those projects. The Advanced Placement Computer Science Principles course requires a Create project which serves a similar purpose.

For smaller projects it can take a bit more to encourage creativity. After all if there is known input and expected output that’s going to be the same. Here is where you want students to be creative in their code. Let students decide if they want to use a for loop, a while loop, or even a foreach loop. Decision structures can also be done in different ways. Having students turn in code that looks different is a great learning/teaching opportunity. I love showing students the different solutions that students turn in. This both encourages them to try to be different and lets them see different solutions. The idea is to open their minds to looking at problems in different ways.

The most important thing is to encourage creativity. Celebrate it!

Thursday, August 26, 2021

IntelliCode Completion In Visual Studio (Preview) 2022

There is a preview out for Visual Studio 2022 available and since I a) love to try new things and b) am not limited to by what is on the student computers I have been trying it out. Normally, I don’t see a lot in new versions of Visual Studio that impact me personally or me as a teacher. That is not the case with this new version of VS. The new feature is called IntelliCode Completion. (you can read more about it here)

Basically what it does is try to help you write code faster and with less typing.

IntelliCode now predicts the next chunk of code based on your current context, and presents it as an inline suggestion to the right of your cursor. If you like it, just hit tab-tab to accept it; otherwise simply keep on typing to adjust the completion further.

Take the following code for example. I have a string array declared. In my btnGet_Click method I typed “foreach (“ and Visual Studio showed my the code in gray as a guess of what I wanted to write. In this case, it was right and by hitting the tab key the code was in place. Continuing to type would have replaces the suggestion.

For me this has been awesome. It's helped me start all sorts of loops and even helped build Boolean expressions. What does it mean for the classroom and beginners? That is the big question for teachers.

I know that teachers are divided on Intellisence which helps with understanding and suggestions with variables and methods. I suspect that if you don’t want your students using that sort of predictive information you’re going to really hate IntelliCode. Even if you like Intellisence, as I do, you may have concerns about IntelliCode. I admit to having some concern myself.

My first impression was that it could prevent a lot of typos and badly formed code. It does have that potential. On the other hand, will students put too much faith in the AI and assume code it suggests is correct for their particular program? That could be a big problem. I have had students blame to tools for their own mistakes for years.

Teachers can use this for a good discussion of artificial intelligence. What do you think of the information was used to train the AI? (Spoiler – lots of code in GitHub) How well does the AI really understand the context of a specific student project?

Clearly, students need to be prepared for using this feature. Students need to know that it is not prefect and that they need to be careful what suggestions they accept.

It does look like this feature can be turned off by specific area of help. Maybe there will be a way to turn it completely off easily on release. It’s on by default right now. So what do you think? A helpful feature for beginners or more potential for harm than help?

Monday, August 23, 2021

Hexapawn–An Interesting Programming Project

I'm cleaning up and finding interesting things. Well, actually, interesting books. One find is called "A Collection of Programming Problems and Techniques." Copyright 1972  So obviously, continued cleaning up is on pause while I code up solutions to some of the problems.

One of the problems in the book is Hexapawn (Hexapawn on Wikipedia) I remember this being a sort of challenge program when I was an undergraduate student. I didn’t take it on back then and forgot about it until running into it the other day.

I decided to take this on. I think it will be a good project for students. As did my old professor.

Hexapawn is played on a grid, often a 3 by 3 grid, with “pawns” on the top and bottom rows. Pawns, as in Chess, can move one square forward or diagonally right or diagonally left to capture pieces belonging to the other player.

 

A player wins by advancing their pawn to the opposite side of the grid or by preventing the other team from making a legal move.

It’s a simple game to play but takes some work to program.

One of the issues is that there are some tricky edge cases to be aware of. While pawns in the center column need to check for three possible moves, pawns in the left and right columns only have two possible moves. That can be a lot of special casing. It gets even worse if one uses larger boards. Trying to check for a move to the left for the left most pawn will create an error in many cases.

Years ago I ran into a boundary condition like this and a member of my team made a suggestion that I have used many times since. She suggested boxes outside the visible grid that, along with not showing, were marked as illegal moves. This means that one can check for straight, left, and right moves for all pawns without getting a subscript out of range error.

An other project I have used this technique is with the lights out game. In that game there are four squares that have to be checked in interior squares, three for edge squares, and only two for corner squares.

Using an outline of invisible squares outside the main set of squares allows the same code to be used for all squares.

I wrote a bit about the Lights Out project some years ago at The Complex Question of Complexity in Programming by the way.

I’m not quite done with my Hexapawn project but I am really understanding how it makes for a good programming project. One can set student requirements low or high. One can assign a two player game or ask students to write an artificial intelligence to play against a computer. It’s a game that lends itself to creating a heuristic program (think machine learning) for more advanced students. Low floor, high ceiling.

Friday, August 20, 2021

Playing With Code–Recursion

Recursion was never a big part of my toolbox but I am starting to appreciate it more recently. Regular readers know that I have been writing about and writing code for some older, simpler cryptography systems. For one of them I needed a list of letter in the alphabet without duplicating previous letters.

I needed to take a letter from the alphabet (I had a string of it) and see if it was in a list of used letters. If the letter was used already I wanted to check the next letter. It’s pretty straight forward if you can assume that not two letters in a row are used in the previous string. There is probably a decent iterative way to do this but I was coming up blank. Until it occurred to me that a recursive solution might be just what I needed.

I came up with the following code. It checks of the letter at location k in the alphabet list is in the string to check. If it has not been used it returns the index of the letter to use. If it has been use the same function is called again looking at the next letter index. This continues until we find an unused letter.

private int getNext(int k, string check)
{
     if (check.IndexOf(alpha.Substring(k, 1)) < 0)
         return k;
     else
         return getNext(k + 1, check);
}

I really like this solution because it emulates the way I think about the task. It’s also easy to understand. Recursion is not always hard and confusing. Sometimes it really makes things easier.

Program note: The nice people at Feedspot have compiled a Top 20 Computer Science Blogs list. Yes, I made the list but there are a lot of very good blogs on that list. They cover computer science more broadly and many will be worth a follow.

In cryptography news, the NSA Codebreaker Challenge 2021 is now open.

While you are here, I have been regularly updating my Tiny Book of Simple Cryptography. The current list includes:

Caesar Cipher
Vigenère cipher
One Time Pad
Polybius Square
PigPen Cipher
Columnar Transposition Cipher
Keyword Columnar Transposition Cipher
Random Block Transposition Cipher
Steganography
Bacon’s Cipher

Monday, August 02, 2021

IoT, Python, and Raspberry Pi–Oh My

Trying learn too many things can be a risky proposition. But sometimes it feels like the way to go. Regular readers of this blog know that I have been trying to learn Python and that I have been experimenting with the Internet of Things with Phidget devices. Mixing the two is a pretty obvious step but since I really want to set up some autonomous systems without tying down my laptop, it seems like the Raspberry Pis I have accumulated would be the way to go. So mixing a new programming language (Python), with a new development domain (IoT) with a new operating system (the Raspberry Pi OS is built on Linux) seemed like something I should give a try.

Fortunately for me, the Raspberry Pi OS installation comes with the Thonny, Python IDE for beginners and the Phidgets software has downloads and installation instructions for the Pi and Thonny. I had a little trouble getting the Phidgets library to install at first but the Thonny IDE had the ability to get the library and install it for me which was a big help.

Thonny feels like a very nice IDE for beginners BTW. I am surprised I hadn’t already known about it. It installs in Windows, Mac OS, and Linux. And it is free which is also nice. Visual Studio Code also installs on Raspberry Pi so if you are using that on other platforms it could be an easy move on the Pi.

My experiment involved using the Phidget Plant Kit because water and electronics go so well together. Seriously though I like the idea of having a computer controlled watering system for plants. That’s something I have wanted to do for a while. Plus it is something that lends itself to cross curricula work in schools.

Initially I plugged in a monitor, mouse, and keyboard. Not a bad desktop if a little slower than I am used to but fine for what I am needing. Next step was connecting over the network with VNC (Virtual Network Computing). This is the step I need for setting the Pi up without tying up my monitor, keyboard, and mouse.

Well, I have some more experimenting to do. More posts when I have some projects fully completed.  I’d love to hear what other people are doing with Raspberry Pi and IoT as well as where you like to go for connectable hardware.

Thursday, July 29, 2021

Playing with Bacon's Cipher

Bacon's cipher is a fairly well-known and simple cipher. Its considered a form of steganography. Unlike most steganography, the code is hidden in the text and not an image. The format is a 5-bit binary encoding where each letter of the plaintext is replaced by a group of five of the letters 'A' or 'B'. This binary code has A as 00000 or "aaaaa" and Z is 11010 or "bbaba". There are variations and the original version used the same codes for the letters "I" and "J" and for "U" and "V". The usual implementation is to use one type face for "a" and a different type face for "b".

Often this is done with a serif and a sans serif font. Other options, and the first one I use below, uses italics and non-italics.

thequickbrownfoxesjumpedoverthelazy

One other option I have used is mixing upper and lower case letters.

The QUicK brOwn FoXes JUmPed ovER tHe lAZy

The big disadvantage of using mixed case letters is that it is not very subtle. It’s almost obvious that there is something special going on. Italics is less noticeable. Serif and Sans Serif are even more subtle.

One semi-famous example of the use of serif and Sans Serif fonts is the Cipher on the William and Elizebeth Friedman tombstone. The biography of Elizebeth Friedman,The Woman Who Smashed Codes: A True Story of Love, Spies, and the Unlikely Heroine Who Outwitted America's Enemies,is a seriously recommended read BTW.

I’ve been experimenting with coding and decoding using this method using a computer program. The upper/lower case combination is pretty easy both to encode and decode. C# has a nice Char.IsUpper method that was very handy for decoding. Encoding with different font faces was trickier for me. I finally used HTML for output.

Parsing an HTML file is not to bad, though I haven’t coded that at this time. The obviousness of this method still rules this out as a serious method for me. If fact just making a raw HTML file available, no matter what sort of type facing one uses, just feels to obvious for me. I suppose that getting an image of the message and posting that would work pretty well. It doesn’t lend itself to computerized decoding however. Maybe some AI pattern recognition would work well?

Speaking of images, there are examples of using this encoding in pictures of groups of people. Some people facing straight ahead and some turned to the side. Just about any possibility of two different options would work. Its a pretty flexible system.

This is not the sort of encryption that holds up to serious attack but I had some fun playing with it.

I have updated my Tiny Book of Simple Cryptography with a chapter on Bacon's Cipher. This is the seventh chapter with a simple cryptography technique.

Monday, July 19, 2021

Pluses and Minuses of the Unary increment Operator

There has been a conversation on Twitter about the unary increment operator (++) and related (+=, –, etc.). I tend to gloss over these when teaching beginners. Especially those in a first programming course. A friend of mine disagrees. It started with:

Would you ever write, or teach a beginner, a = a + 1 if your language supports a += 1 If so, why?

Now obviously professional programming and beginner programming are not exactly apples and apples but we should probably be teaching best practices. Right? On the other hand, there is thing called cognitive load. There are really  at least four ways (in most C-style languages) to ad one to a variable.

  1. a = a + 1
  2. a += 1
  3. a++
  4. ++a

I generally teach options 1 and 3. I mention the others but don’t really expect students in a first class to use them all. Cognitive load. It’s enough for students to remember two ways to do something and they don’t need all four.

The first one has an advantage that it follows a general form. A value is added to a variable and saved in the original variable. This works for a lot more than adding one. Now arguably a += 1  does the same thing but the other format is a building block for more complicated  assignments with out the complexity of figuring out where += fits into the order of operations.

Now the pre and post increment (and decrement) operators are sort of special. It makes a difference which one you use;

foo = bar[I++] and foo = bar[++I] give very different results.

Personally I don’t want beginners using either except as a standalone statement. So I teach it for incrementing loop control values but don’t talk much about using it other places. Now obviously there are cases when using these operators in other places is a good idea. But I think beginners have enough trouble as it is without adding some unneeded complexity.

As time goes on and students become more comfortable with the language and the art of programming, by all means, show them the cool stuff. But remember that code should be readable by people as well as computers. When I was doing code reviews as a professional developer I always looked to readable and easy to maintain code. That’s how I want my students thinking as well.

Agree? Disagree? Jump in in the comments below.

Friday, July 16, 2021

Observations on #CSTA2021 Virtual Conference

The CSTA 2021 Virtual Conference is in the books. I really did enjoy it and I learned a lot. Virtual conferences are different from in-person conferences and I plan a post on that. But for now I want to talk about this year.

First off, the conference program was pretty awesome if I can say that as part of the conference committee that selected them. Not only was content good but the presentations were very well done. At  least the ones I sat in on were. I wonder if the experience of teaching online as so many have had to do played a role in preparing teachers to present at a virtual conference. Thoughts on that?

Secondly, the chat feature in Hopin got a lot of use. As one person pointed out, yelling things out in a live presentation is rude but adding questions, comments, or additional resources in a chat windows is not. More than that it adds to the value of the presentation.

Sessions for grades younger than high school are growing in number. This is hugely important in my opinion. This year, Nifty Lessons had a lesson for the very young grades. There were not many teachers of those grades to hear it though. I would love to see more nifty lessons for younger grades. Elementary school and middle school teachers are doing amazing things and we need to share them.

I ran two monitors during the conference. One monitor was on the conference itself while the second was split screen between the Slack channel the conference staff and committee used to handle things behinds the scenes. The other window was following the #CSTA2021 Twitter hashtag. I don’t have data but it felt like the Twitter stream was less busy than most years. I suspect two causes. One the aforementioned chat activity in Hopin and the other the fact that computers and phones were occupied with attending the conference rather than social media. Is this god, bad, indifferent? I don’t know. Being virtual we had many more people AT THE CONFERENCE so maybe we don’t need as many Tweeting for the people not there?

There was a clear theme of equity in CS education in this year’s conference. Given the last few years, equity is and will continue to be an awfully important topic. The keynotes were all on that topic and at the risk of taking criticism, was that necessary? I love people talking about how they bring equity into the teaching. I will listen to Amy Ko again in a heartbeat for example. The last keynote at CSTA 2021 had some inspiring stories. It was great to hear the success of students from students. We can probably all do even more to bring equity to teaching CS. I would just have liked a little more variety in the keynotes.

I have been thinking about what else I would like to see in keynotes for next year.

One is talk about the need for ethics in CS education. I am not sure what form this keynote should be given or who should give it but ethics in computing is a critical topic in my eyes.  We’re seeing ransomware and cracking into systems all the time. We need to make sure we are bringing ethical thinking into our teaching. Students need to ask “should I?” as often as they ask “can I?”

The second thing I would like to see is pure inspiration. At this point in the year teachers are tired, drained  and most of us could use some excitement. The future of technology is amazing and hearing about the possibilities and ideas that we can share with students to encourage them would be a great thing. Again, I am not sure who is the person to bring it but I want to hear a positive and exciting message about the future. I want energy!

So what do you think? How was the conference for you? What was great or not so great? What do you want to see next year?


BTW, my daily notes on the conference are at:

Notes on Day Three of #CSTA2021

No morning help desk duty for me today so I watches the whole “Morning Java” session. For those of you not at CSTA, Moring Java was an introduction to the day with our conference chairs and guests. Today.Michelle Lippoli, Senior Operations Manager (Events and Membership) for CSTA, talked about all the work that goes into running a conference like this one. And it is a lot of work! Next year CSTA will be in-person in Chicago. There is a lot of excitement about being able to meet in-person but I hope we have the virtual option as it makes the conference possible for so many more people.

First session of the day for me was Nifty Assignments. Though I was tempted by Python and Micro:bit…on a Calculator? and I will look for the video in the future. Nifty is a conference favorite. The idea started at SIGCSE (See more on that here) and I have used projects from previous sessions at CSTA and SIGCSE.

Michele Lombardi - Unplug the Internet!  9-12
Review internet vocabulary, how messages are sent, and introduce potential cyber attacks using this unplugged internet simulation.

I’ve done something similar but I love the forms she uses and the other information about things to do.

Cindy Gonzalez - Bring your 3D world to life!  K-5
Design a 3D design in Tinkercad, upload your design to Cospace, code your design & enter your 3D world using the DoInk Green Screen app

Talk about making students creators and not just consumers. I love the cross curriculum opportunities.

Roger Jaffe - RSA Encryption Without the Math  9-12
How to teach RSA encryption without having to teach the math

I struggle with teaching public key encryption so this set of resources looks very exciting to me. I can see using this lesson in Advanced Placement Computer Science Principles.

Learn more about CSTA Nifty Assignments at: https://sites.google.com/site/cstaniftyassignments/

After Nifty Assignments, I attended Teach Cybersecurity. Change the Future/ (Slide deck here) Did you know that there are guidelines for what to teach about cyber security? There was a lot of discussion about teaching cyber security in the chat. A lot of teachers are, not unreasonably I think, worried about students misusing the knowledge. The Teach Cyber program, and every other program I have looked at, included ethical thinking integrated into the curriculum. This is a curriculum worth looking into if you are thinking about adding a cyber security course.

Last mini session of the day for me was My CSP Experiment – teaching Advanced Placement CS Principles with two different programming languages at the same time (JavaScript/AppLab and Python) This teacher developed a detailed scope and sequence with dates and time and then mapped the concepts to unites from different curriculum programs (code.org, CodeHS and others) Concepts were taught largely with pseudo code and unplugged activities. That was a lot of work. I really admire her skills. (Slides are here)

Well, that’s a wrap for me. It’s been a great conference and I learned a lot. I’m glad I don’t have to travel for hours to get home.

Thursday, July 15, 2021

Notes on Day Two of #CSTA2021

Today started, for me, with help desk duty. While I was there no one needed any help which I suppose says good thi8ngs about the HopIn platform CSTA is using. The other committee member on duty, the amazing Myra Deister, and I spend most of the time catching up. We’ve known each other through CSTA for a long time. It was just like a “hallway track” time for us. I’d love to see tools specifically for that sort of thing.

First session of the morning I was bad. Well, fidgety I guess. I hoped in and out of a number of sessions the whole time.

I started with Misconceptions as Learning Opportunities (slides here) and learned some good things about assessment. An area I frankly need to learn more about. I will be watching the whole session when the videos are available.
I next hopped in to Introduction to Micro:bit with MakeCode just to see what they were presenting. I did pick up a couple of links to related research that I  read later.

https://aka.ms/MakeCodeResearch ,https://aka.ms/PhysicalComp, https://microbit.org/research
Release notes: https://makecode.com/blog/microbit/2021-release

BirdBrain Technologies dropped in to the session to say that they “ loved the micro:bit so much that [they] based the newest version of [their] products on it! US educators can try a free demo of [their]micro:bit based robots: at https://www.birdbraintechnologies.com/demo

I spend most of the rest of the time at Block-Based Machine Learning and AI with mBlock  “ mBlock is a powerful programming environment that combines the familiarity of Scratch with cutting-edge technologies like Google’s Teachable Machine and Microsoft’s Azure Cognitive Services.” (Slides here) I should have started here and I will definitely be watching the full video when available. BTW,
If you are looking for resources about teaching AI check out https://ai-4-all.org

Next up was the keynote by Dr. Amy Ko. I have been familiar with her work from both social media and published papers so I was really looking forward to hearing her speak. Follow her on Twitter (https://twitter.com/amyjko) and read her blog posts (https://amyjko.medium.com/) Dr. Ko gave a great talk which showed all of the levels involved in where things can go wrong in encouraging students to take and continue in computer science. Talks like this are a reminded for me of the many forms of diversity that I have to be aware of and how I need to adapt to meet the needs of people who are not like me. Dr. Ko posts her talks on her web site. This one should be there soon if it is not there right away.

Updated: with links to Dr. Ko’s talk:

Video: https://youtube.com/watch?v=p7IzFIDfyKY Slides: https://faculty.washington.edu/ajko/slides/CSTA2021Keynote.pdf

CSTA Keynote

After the keynote, I hopped into Teaching Exciting Computer Science Frontiers in High School for some ideas about advanced courses and students. The talk introduced me to NetsBlox which is a visual programming language and cloud-based environment that enables novice programmers to create networked programs such as multi-player games. Network programming, yeah! The system also connects to a variety of databases online. So a lot of possibilities for data science or cross curricula projects.  I need to look into this a lot more.

Next up was Selecting and Supporting a New CS Teacher. (Slides here) This mini-session was part of the administrator tack. Love that there is an administrator track BTW.  In any case, there was a lot of good information for administrators including some helpful links in the slide deck.

Teaching with YouTube with Oscar Velizin was next for me. Oscar Velizin has a YouTube channel with videos that mix math and CS. No surprise. One of the takeaways for me was the idea of providing access to the code that is demonstrated via GitHub or some other online system.  (Slide deck here) He had some good reasons for using PowerPoint compared to some other presentation tools.  Specifically the ability to screen capture, to rerecord individual slides, the built in Equation editor, and the ability to easy export videos.

Don’t tell anyone but I skipped the Birds of a Feature. Enough screen time and I wanted to be rested for the last keynote of the day.

The afternoon keynote as Zaretta Hammond who talked about Changing the Complexion of Computer Science Education. Yes, equity was a big focus at this year’s conference. I that that was wonderful. As we look at the events of the last few years we can see that a lot of work needs to be done to promote Computer Science for everyone.

A note of process. Yesterday I took notes in a text document. Today I took my notes in Open Live Writer which is my blogging tool. I filled things in during breaks between sessions. That made it easier for me. I like having my notes in blog form both to share with others and to return to for my own follow-up on sessions.

Wednesday, July 14, 2021

Day One–#CSTA2021

Today was the first day of the Computer Science Teachers Association conference. All online of course. It was a pretty cool day. I got myself set up with a two monitor system, headphones, and a notepad for notes. Being on the conference committee I had some specific commitments. The two monitors made that easier. I spend the first hour working the help desk so I missed some of the opening keynote and welcomes. It felt good to be able to help out that.

My first session of the day was AI and Machine Learning with Code.org with Daniel Schneider , a Code.org Curriculum developer. His Slides are at https://bit.ly/csta2021-aiml. One expects a high level of production quality from Code.Org and this program seem to have that. The curriculum can be used several ways as a stand alone or modules can be used in a larger course. If you are looking to teach about artificial intelligence and machine learning this is a great place to look for materials. Code.org AI/ML Curriculum

Next you was Secret Coders Teach Computational Thinking with Dr. Rachelle Haroldson and Dave Ballard Slides at  https://bit.ly/2UUPDUf They started with an introduction to as 6book set of books for younger students called Secret Coders. Now K-5 is not my usual thing but I have a grandson who just finished kindergarten who is already interested in computers so … After introducing the books they presented some good exercises to go along with the stories. Some were offline like the one at Fun-with-Coding.pdf which I can totally see adapting for older students as well. And some were online interactive. Overall, I thought it was a pretty good program for younger students.

The mid-day keynote was from Tim Bell, the man behind CS Unplugged, You know its going to be a good talk when the presenter starts by playing a huge  pipe organ. Dr. Bell is a great presenter. He had a lot of good things to say. For example, "We write programs for people to use. There may be a few people that need that memo."  The big learning for me though was him saying  that Combining unplugged activities with coding activity works better than unplugged along. Having students do an unplugged activity should be followed with some actual coding activity. Makes me think a lot about how I use unplugged activities.

Next up for me was  a session on the Carnegie Mellon University (CMU) CS Academy curriculum  Link to presentation slides. CMU has several courses of different lengths and for different levels of complexity. Course are Python based and have been developed and well tested in actual classrooms. The demos show some great production values with a lot of thought given to teacher tools.Courses start at the middle school level and into high school. Some of the modules will fit nicely into the coding parts of Advanced Computer Science Principles. And its all FREE!

Last session of the day for me was Coding with Scratch Junior in the PreK–2 Years. Looking for ideas for my grandson again. This session provide a slide deck of resources and a Slide deck. Scratch Jr is an Android tablet app that look crazy easy for students in PreK to grade 2. I think my grandson will like it. There are many ways it can be used cross-curriculum as well. Pretty cool stuff.

There were a bunch of sessions I would have liked to attend but one can only be in one place at a time. Thank goodness that all sessions were recorded and I will be able to watch them come August.

Tomorrow I will be back in the Help Desk at 10:30 Eastern US time. I’m looking forward to a bunch of great sessions after that.

Tuesday, July 13, 2021

Learning My nth Programming Language

They say that the second programming language is the hardest to learn. That’s mostly because one learns how to program using their first language but each language has its own idiom.  I was lucky in that before I completed my BS degree I had learned enough of at least six programming language to write usable programs. So when at my first professional programming job they handed me a language reference manual and a functional specification and asked me to develop on a new (to me) operating system I got on fairly well.

I continued to learn new programming languages over the following years and have lost count of them all. But having a project, a good reference manual, and usually some good sample code I had a lot of fun learning.

This spring I had to reconnect with Java and learn the Processing system. To be honest I used the code students had written before I took over the class for some of how I learned Processing. Syntax is new but concepts change a lot slower and experience (in this case with XNA) was very helpful. Having a wide range of experience sure does help. And I used Bing a lot

These days I am attempting to learn Python. I have a number of Python books written for beginners. They look great for beginners but for me they just don’t work. There is to much about how to program in general and finding what I need becomes tedious. Programming language documentation has changed over the years. For the most part that’s probably good. For me, well, let’s just say I miss the old dead tree simple language reference manual.

Finding good sample programs for what I want to learn has been a struggle as well. Search engine AIs are not as good as we need them to be yet. What to do? Well, this is were community comes into play. I asked for samples on the Computer Science Educator group on Facebook. Some brief conversations and Lisa Hines, a CS teacher from Canada, shared two wonderful samples that look like they should give me a real start. The Internet sure has made for some great community building for computer science teachers.

Monday, July 12, 2021

Avoiding Tour De Force Sample Code

Sample code is a wonderful way to teach and learn coding.  The problem with a lot of sample code is that it is just too complicated and to fancy. I call it tour de force code because it seems like the authors are trying to show off how awesome their coding skills are. That’s probably a bit harsh but I feel like using 1,000 lines of code to show off every single feature of a concept/API/Class or what ever is overwhelming. It is the sort of thing that sends beginners a message that things are over their head.

I’ve always tried to avoid over complicated examples that I write for students. Far too many of the samples one finds from major vendors are either too complicated or leave out important information that beginners are not likely to have. Of course most samples on the internet are written for professional developers so that’s understandable. Beginners (students) requirements are far different from those of professional developers.

It doesn’t have to be that way though. The Phidgets website (see my post on Phun with Phidgets for context) has a sample code generator that I really like. (https://www.phidgets.com/?view=code_samples ) There are a number of options depending on how much a developer wants to do themselves and how much they want generated. Any way you do it there will be lots to do to make your final program. The samples are very basic but they do let one test a device and see some of its features. I wish more companies did things like this.

Over the years I have written some code generators myself. In fact, one of my masters degree projects was a simple “compiler” that generated code in multiple languages to work with a user interface library.  It generated very basic code that handled the most repetitious and tedious parts of the code so that a developer could focus on the interesting parts of code. It had the advantage that it used as input the markup language for the documentation system. It’s a shame that commercial systems like that don’t exist today.

I’m starting to think that writing code generators might be an interesting project. Something like a user interface that asks for variable names and things like loop parameters and generates code snippets. Some provisional IDEs, Visual Studio for example. provide help with generated snippets but I think that coding a generator might help students understand the code they use better. It’s just an idea at this point but I want to think more about it.

Monday, June 28, 2021

Phun with Phidgets

Recently I requested a free (for educators) starter kit from Phidgets. Phidgets are small controllers and sensors that are easy to use and with a helpful API. The starter kit includes a bunch of things to introduce the platform.

The Getting Started Kit provides an introduction to students and teachers. We offer a self-guided, online curriculum with challenges and projects for students.

• Programming languages: Python, Java, C#, Swift
• Device compatibility: Windows, macOS, Linux, iOS, Android
• What's in the box: VINT Hub, Push Buttons (2), LEDs (2), Humidity Phidget and all required cables
• Suitable for school grades: 9 – 12

I spent some time with the starter kit today. What I was looking for was pieces that were easy to assemble and sample code that was reliable and easy to use. That’s what I found.

The first thing I did was assemble a sort of control box with two push buttons and two LEDs. I plugged the controller in to my laptop with a USB cable and fired up Visual Studio.  There are samples and tutorials in Python, Java, Swift, and C#. The systems work with Windows, Mac OCS, and Raspberry Pi. Projects are available in a wide variety of IDES including Processing, Eclipse, NetBeans, and Visual Studio among others. That;s a lot of options. IT looks like more languages are supported less directly.

So anyway, I followed the starter tutorials to get a feel for both the type of tutorials supported and to get a feel for using the Phidgets themselves. They were very easy to follow with a lot of code you can copy and paste to get started. In a classroom I would spend some additional time explaining the code in more detail. Students could use this on their own but would really benefit from the sort of deeper explanation a teacher can provide. I do like that there are suggestions of next steps without sample code for the student. That should encourage students to experiment a bit. Solutions are available to educators on request though.

Besides the buttons and lights I ran though the sample code for the temperature and humidity device as well. Equally easy to use. I was gifted a couple of other devices – a Power Plug Phidget and a Distance Phidget. I have some Raspberry Pis around here somewhere so my plan is to try these Phidget devices with one of them. That will give me a chance to learn something about the Pi devices as well. I can see a lot of potential for interesting projects combining Raspberry Pi and Phidget devices.

These feel like the sort of devices I have been looking for to do a variety of hardware and software mixes. In other words, physical computing. There are classroom sets available that while not cheap are in range for a lot of schools. You can’t give hardware away for free and these devices are high quality and well worth the prices. IMHO.

Note that I got the kit and devices for free but without any expectations of quid quo pro. I really like this stuff.

Friday, June 25, 2021

Is Picking a First Programming Language the Hardest Problem in CS Education?

All of a sudden the subject of the first programming language is getting discussed everywhere. OK, maybe not every where but it is in Twitter, Blogs, and Facebook. At least. Mark Guzdial gets part of the blame (credit?) for this with his conversation starting post on the Blog@ACM Why Did We Ever Think the First Programming Language Didn't Matter? It’s hard to find the conversations on Twitter but several of the CS education groups on Facebook have conversations around this post. For example, the Computer Science Teachers group here.

Now this a a topic that comes up regularly. I’ve made reference to it myself several times. Back in 2017 I asked the question How important is the first programming language really? and answered that I thought it was important but that curriculum and the teacher were more important. The language has always mattered though.

In 2016, I posted a link to an article called How Your First Programming Language Warps Your Brain One can find similar opinions widely spread on the Internet with special attention paid to Dijkstra

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.

I think we have always known that a person’s first programming language has a major impact on how they view programming. My first language was FORTRAN and it took me a long time before I stopped writing FORTRAN programs in different languages.

What does this obvious importance of the first programming language mean for CS educators? Well, its complicated. For one thing,Elementary and middle school have different constraints than high schools which have different constraints from universities.

I had a conversation with a middle school student recently. She attended after school programs at a university near her that taught her Scratch. She loved it. At the same time she saw older students (she’s a rising 7th grader) using a text based language and found it intimidating. She’s not convinced that she can handle what she called “real programming.” I tried to encourage her but one conversation only goes so far.

Research tells us (the professionals) that block based language are a good first programming experience but if students don’t see it as authentic they may think that is as far as they can go. While block based languages give many the confidence and concept base to move on and advance are some students falling into the trap that it is not real enough? I don’t know.

I’ve taught a number of language as a first programming language over the years. Visual Basic, Java, C#, PASCAL, and I’m probably forgetting some language.I am not ready to say that there is one best first language though. It really depends on ones goals.

Selecting the right language is important. Important decisions are seldom simple or uncomplicated.

Monday, June 21, 2021

Why Are Arrays So Hard For Beginners?

Beginner programmers often, dare I say usually, struggle with arrays. Sometimes it is hard for experienced programmers like myself to understand why but with years of using them in many languages they’re second nature for us

Beginners have trouble differentiating between the index and the contents of a part of an array.That seems to be the most common issue. Somehow the idea that the index is, in some sense, part of the name and not the value being stored is hard for some to grasp. Though come to think of it, I never talked about an index as being like a name. Perhaps I should but as a very experienced programmer with a background in Assembly language words like index and offset are natural to me. Beginners should not need to know how arrays are stored and accessed at the Assembly or machine language levels. Perhaps I will discuss indexes as part of the name next time I teach arrays. What do others think? Or what sort of language do you use?

While vocabulary is important, and students should understand words like offset and index, perhaps we need vocabulary that is meaningful to beginners before we teach them the vocabulary of experts. It’s a thought.

And then there is the whole “index values start at zero” thing which I have written about in the past. Zero Zero Indexing Considered Harmful

The other think I have been thinking about that seems hard  for some beginners is the need to initialize an array. They tend to assume that if one declares an array the elements in it should be assigned some sort of default value. Of course some programming languages do this for some data types. Numeric types get set to zero for example. It’s seldom a good idea to depend on this action and most of us do teach students to initialize the elements in an array. It’s a great way to tie arrays and loops together early in the learning process. I wonder why there are not library routines for this sort of thing. The .NET Framework has Array.Sort, among other things, so why not Array.Initialize? That’s probably not practical for arrays of many types but for some of the built in types why not?

On Twitter last week someone suggested that perhaps the problem was with arrays themselves. That seems reasonable but solving that problem is for people smarter than me. I’m just asking questions.

Tuesday, June 15, 2021

Getting Excited for CSTA 2021

As a member of the CSTA Conference Committee, I attended the first of two presenter training sessions today. Wow! CSTA 2021 will be good. Now I have read most of the proposals for presentations and helped select them so I had a pretty good idea this is going to be a great conference but today brought home a couple of things for me.

The big one is the shear number of online tools that teachers are using to make online (and probably in-person) teaching more interactive and engaging.  I taught online last spring and in a mix of online and in-person this spring but I never had the time to lean about all of these tools. That is mainly because I retired at the end of the 2019/2021 school year and didn’t spend last summer learning about teaching online. I kind of wish I had though.Never say never even about returning to the classroom. But that aside, I am really looking forward to learning at the conference this summer.

CSTA 2021 is going to be awesome! Hope to see you there. So much to learn!

Friday, June 11, 2021

Exploring the Ternary Operator

I’ve never had a lot of use for the ternary operator. Until recently, I think I under appreciated it. I Don’t recall ever using it in professional development though that may be largely related to using languages that didn’t support it. I never taught it to beginners either. Between time available and topics to be covered it never rose to a high enough priority for me. I’m starting to rethink that. But first, what am I talking about?

In C-style languages the syntax is:

(expression-1) ? expression-2 : expression-3

There is a Boolean expression inside the parenthesis, followed by a ? and a value for a true case, a : and a value for a false case. For example:

(Player == WHITE) ? "White" : "Black";

Other languages have different formats. For example, in Python the true option comes before the Boolean expression.

[on_true] if [expression] else [on_false]
>>> x, y = 5, 6
>>> print("x" if x> y else "y")

We actually see this sort of thing in spreadsheets though I never really thought of it as a type of ternary operator. This example from Excel is really a ternary operation

=IF(G10 <  G11  ,"big","small")

Back in the day we had something not all that different in FORTRAN. There was (probably still is) an IF statement in FORTRAN that branches to one of three lines depending on if an arithmetic value is less than, equal to, or greater than zero.

IF ( N ) 10, 20, 30 

But enough history. What really changed my mind about this operator? As is typical for me I revalued it when I found a good use for it. I have been writing a version of the Reversi program in .NET and C#. I borrowed a bunch of Java code from my friend Tom Indelicato (read about that program here) Steal from the best is my motto and Tom is an outstanding programmer. Along with the syntactic changes moving from Java to C# I wrote a lot of code to make the game work in a graphical user interface. I made some different design decisions as well which changed how some things are handled. I created a user control class for the game squares for starters. As part of this I used three different integer values to indicate whether the square held a black disk,a white disk, or was empty.

In the past I have often used a Boolean value to indicate which of two players was the current player. Switching players is pretty simple with a Boolean value.

currentPlayer = !curentPlayer;

That wasn’t going to work if my player indicators were integers. I decided to use the ternary operator because I didn’t want to write multiple lines of code for something that simple. So I wrote:

Player = (Player == WHITE) ? BLACK : WHITE;

WHITE and BLACK are defined constants. The next thing I knew, I was finding uses for this operator in all sorts of places. The really cool thing (ok for a geek like me) was that I could use this statement inside other statements.

message = “No legal moves for " + ((Player == BLACK) ? "Black" : "White");

I guess this old dog can learn new (to him) tricks. Do you use/teach this operator? Are there other language features you have ignored until one day you realized they would be just right for something you were doing?

Thursday, June 03, 2021

Trip Report: Teaching as a Long Term Sub

Well, this is not actually a trip report but its something like it. I spend the last couple of months teaching at Phillips Exeter Academy as a long term substitute. It was an interesting experience for many reasons. Not the least of those was the pandemic precautions.  Everyone wore masks inside and out, there were clear dividers between all of the seats around the table (more about that table in a minute), and for most of the time faculty were tested for COVID twice a week. I was fully vaccinated before I started there and the school ran vaccination clinics for faculty and students during the term.

Phillips is different from most other schools. It is the literal definition of an exclusive New England boarding school for a start. With a very competitive admissions process one is not surprised that the students are smart and highly motivated. Many of the students I talked to were looking for more academic rigor than their local schools. Needless to say classroom management was never even close to an issue.

As I alluded to earlier, classes at PEA are taught around a table. It’s a big table but class size is limited to about 13. None of my classes were larger than 12 and two sections were 10 students. Yes, that’s wonderful for a teacher. Between the small class size and teaching around a table it is not easy for a student to get lost. Teaching around a table forces a more conversational method of teaching. Its very interactive. I really enjoyed the format.

Another part of the system there is something they call METIC. I forget what that stands for but basically what it is is a mid-term check in. Students in the class are given some time without the teacher present to discuss what was going well in the class, what is not going well, and what students and teacher can do to make the rest of the term go better. Now this can be hard on the ego for some teachers especially if students are hard on them. My students, and from what I hear  most students at PEA, are very respectful and honest. Following time without the teacher, the teacher returns and the items the students brought up (written on the white board) are discussed. For me as a new comer to the particular school environment this was extremely valuable. This is something I wish had happened earlier in my teaching career. I think it would have made me a better teacher.

Everything was not all smooth sailing of course. I took over the course in the fourth week of the term and my students had two other teachers in the first three weeks. Figuring out what students knew and didn’t know took me a while. I also had to figure out a plan for the rest of the term. Fortunately, other members of the CS department were incredibly helpful and supportive. I was give full access to curriculum from a previous time these two courses had been taught. This saved immeasurable amounts of prep time.They were also always available for my many questions about the courses and the school’s processes.

As I alluded to in my earlier post (Back in the Classroom Again) I had to reacquaint myself with Java and learn my way around two IDEs (Eclipse and Processing) that I had never used before. Its tough answering questions about IDEs when you have no real experience with them. Fortunately I am good at exploring menus and looking up things on the Internet. I’m far from expert at either IDE but I’m not totally lost either. I found Processing and its graphics library fun and interesting. My old experience with XNA from years ago helped me out there. Though I do wish Processing had some built in collision detection. Probably good for students to figure out and code that for themselves but I’ve been spoiled by .NET. I would use Processing again for Java.

Overall, I had a great experience. I learned a lot, got to work with great teachers, and teach some awesome students. I’m not unhappy about getting back into retirement though.

Thursday, May 27, 2021

Othello/Reversi for After the APCS Exam

My good friend and former teaching partner, Tom Indelicato posted about his end of year project for his AP CS A student recently. With his permission I share it with you.

I said goodbye to my seniors today (last day of classes for them). We wrapped up the post-Exam project (I gave them the framework for a Reversi / Othello game, and they wrote an AI for it) by having them play against each other. I put up a randomized tournament bracket, and awarded a $10 Dunks card to the winner.

An incredibly good class of students, they told me that they thought this was the greatest final project ever! I'm gonna miss them.

Tom also generously shared his framework code at https://1drv.ms/u/s!AmXKuaTMPmyCpVBNCyiB0h3t5uWi?e=j9Gv1N

Interestingly, a similar project was in the Nifty Projects session at the CSTA Annual conference in 2018. Unfortunately the GitHub code repository that was associated with it seems to have disappeared. There are other related and useful resources still there at https://sites.google.com/.../roger-jaffe-othello-competition

Most likely Tom's framework would fit along with it with a few minor tweaks.


Tuesday, May 18, 2021

Learning From My Students

Being back in the classroom has been a learning experience for me. For one thing I have had to learn a bit of Processing (the IDE) as students had been using it prior to my coming in as a replacement teacher. That’s been fun actually. And learning Processing has been on my to-do list for a while. It’s a pretty useful tool and makes graphics programming in Java almost as easy as C#/Visual Basic and the .NET library.

I have had to get reacquainted with Java as well. That’s more of a refresher than a new learning but students have given me some fresh insights into using it. One of the disadvantages of having programmed for so long is that my mindset is, to some extent, stuck in old ways of thinking. Take for loops for example. I am rather stuck in the idea that the comparisons in a for loop are just simple single Booleans when of course the Boolean expression can be a lot more complicated than that. My students are not as stuck so they suggest various options. That has been helpful in broadening my thinking.

CodingBat is a web site I have come to appreciate as well. I’ve known about it for a long time of course but never used it before because I wasn’t teaching either Java or Python. It includes a lot of very good projects that make for great homework being web based. It’s a little like Code Hunt, which sadly no longer exists. CodingBat is easier for beginners to use though which is a plus.  I found it very useful and recommend it to other teachers.

For one course I have had to review my knowledge of some data structures. Again, a refresher rather than all new learning but I think I picked up some things I either forgot or never knew. (Memory is a fickle thing)

I’ve also learned some things about teaching but that will be another post at a later date.

Thursday, May 13, 2021

Which Sort Do You Use?

My algorithms class is studying sorts this week. I felt like we needed a little hands on sorting to get an understanding of how some sorts related to the types of sorting people do. I had a number of decks of playing cards and their easy yo hand out and to sort. I don’t have one deck for each student and watching others sort is boring. You really want to avoid boring this close to the end of the year so I decided that I could split the decks by suit and have enough small decks for each student. Faster is often better anyway.

My students had been assigned some reading on Insertion, selection, and bubble sorts. I was interested to see if they would relate any of these to their chosen sort methods. Not bubble sort though. I wonder if we should even teach that one. But I digress.

The students were asked to sort their deck which they all did pretty quickly. Than I asked them if they used a selection sort or an insertion sort. About half of the students choose each one. This led to a good discussion of the two methods. It made for a good exercise introduction.

As a side issue, I had my beginner class separate the decks into suits. This was part of a discussion about While loops and the need to properly plan for data storage (the four output files), That it meant I didn’t have to do the separation was a nice side benefit.

In both classes, we had a brief talk about parallel processing and breaking a problem up into parts that could be run in parallels by separate processors. I take my lessons where I find them.

Sunday, April 25, 2021

Back in the Classroom Again

“What would motivate you to come out of retirement to teach during a pandemic?” That was the question I was asked during an interview for a long term substitution position.  My retirement last June had been planned for a year or more. I was very content in retirement. I wasn’t bored, COVID restrictions were not being particularly hard on me.So why was I considering this opening?

My wife and I were fully vaccinated so going back was not as scary as it had been but that just made the decision possible. There were really two reasons I was open to the idea. One is that the schools was Phillips Exeter Academy.  They have small classes (I am now teaching two classes of 10 and one of 12) and they teach around a Harkness Table. I’ve long been curious about that style of teaching. The other reason was that they really needed someone in a hurry. The person they initially hired to fill in for a teacher on sabbatical resigned after a couple of weeks into the semester. I guess I am a sucker for that sort of problem.

So what is it like for me? Well, I feel good about the COVID precautions. There are Plexiglas partitions around the table, students and faculty wear masks everywhere, and faculty are tested for covid twice a week. I believe students are tested often as well. Teaching with a mask is awkward and sometimes it is hard to tell which student is talking because I can’t see anyone’s lips move. But teaching more conversationally around a big table is pretty nice.

I have two students attending via Zoom which takes some getting used to but the students are good about it.

The hardest part is jumping in to without a clear idea of what students already know or don’t know. And figuring out how to move forward. The classes are in Java using Processing and Eclipse as IDEs. Both IDEs are new to me and it has been a while since I taught Java. AP teachers may remember the Marine biology Case Study? That was when I last taught Java. Catching up on the IDEs has been interesting. Returning to Java makes me appreciate C# and .NET even more. But we’re managing. Having smart, motivated students and small classrooms helps a lot.

So, how is your school year going?

Friday, April 16, 2021

CSTA 2021 Scholarships

Are you looking to attend the CSTA 2021 Conference but funding is an issue? There are a great many scholarships available that can help. Visit the scholarship site for full details and application information. I copied a lot of the information below.

Note that there are scholarships for international attendees and not just US based teachers. Applications close on April 30, 2021. So apply soon so you don’t miss out!


CSTA prides itself in promoting equitable access to the CSTA Annual Conference, our premier professional learning program for K-12 CS teachers, by offering scholarships that subsidize 100% of the program cost. These scholarships are intended to support teachers whose limited financial resources may prevent them from attending.

Our goal is to support as many teachers as possible. We currently have funding available for 325 scholarships for U.S. teachers but expect to secure additional funding. We will first prioritize awarding scholarships to: Black teachers and other teachers of color, those who teach marginalized students (BIPOC students, low-income, rural communities), and first-time conference attendees.

If you have a disability or require assistance completing your application, we are happy to help. Please reach out to conference@csteachers.org.

Applications close on April 30, 2021.

To be eligible for scholarships to the 2021 CSTA Conference, you must:

  1. be a CSTA Basic or CSTA+ member,
  2. directly teach computer science to K-12 students, and
  3. not have access to funding from your school or organization to cover conference registration fees.

Conference presenters and chapter leaders already receive complimentary conference registration and need not apply.

Monday, March 29, 2021

Learning To Teach To Learn

A blog post by Eugene Wallingford  (TEACHING YOURSELF THE MATERIAL) reminded me of some things. As he says, “A common complaint from students is that the professor makes them teach themselves the material.” During a graduate course I took in distributed Operating systems the professor assigned each student a topic to research and then teach to the class. I had a couple of peers who complained (privately) that it was his job to teach not theirs. I took it as an opportunity to dig deep in my topic and came away thinking it was a great learning experience.

As a teacher myself, I assigned topics to students to research and teach to the class on several occasions. I’m not sure if students complained behind my back but they were pretty good in my hearing. I found that this was beneficial to the students as well as to myself. In several cases students found features or uses that I had not considered. Students seem to lesson to peers more closely than to their teacher.

I also asked each students to write a couple of quiz questions (with answers) for me to use in a quiz for the whole class.The quality of the questions was mixed as one might expect but they also gave me insights into what students saw as the important part of their topic.

One thing I should have done is to have more rounds of this sort of thing. Students need to practice how to present material. One would like to think that they have enough examples of how to present from sitting through presentations day after day but that doesn’t seem to be the case. Students definitely need some more formal training in presentations than most of them get.

Do you assign students to research and teach topics? How does it work for you?

Tuesday, March 23, 2021

Too Many Ways to Add One

Someone posted a questions asking which sort of programmer one was from a list of ways to add one to a variable:

X++
++X
X+=1
X = X + 1

Actually the initial question didn’t include ++X but it soon showed up in replies. With all these ways to do what appear to be the same thing it is no wonder students get confused.

Daniel Moix replied to my Facebook post with X = X++ This doesn't work (at least not in C# or Java). While one might expect that the value in X would be increased by one after the statement executes it is in fact unchanged. X = ++X does work as you would expect though. It’s not surprising that students, clever people that they are, come up with variations that should work in their eyes but do not work.

Why do we have so many ways to add one? I can’t speak for the language designers (I assume most of this started with C or some earlier language) but lots of us like shortcuts. And it seems like every programmer has his or her own idea of how things should be done. There are few programs that have been around for any length of time that have only one way to do anything.

All of this is great for experienced programmers but can be a nightmare for novices. I used to debate in my head if I should even show all of the ways above.  X=X+1 and X++ covers most cases for beginners. Why confuse them?

I usually did briefly talk about X+=1 because a) students are likely to see it in other code and b) it is useful when adding (and other operations) where one is not changing by one.

This all adds some cognitive load. I think that teaching all the various ways at one time can be a bit much. It may be better to add things as they are needed. For example, maybe waiting until teaching loops to introduce X++ and X+=1. That context and specific use may be helpful. I didn’t do that before but I wonder if I should have. Opinions are welcome.

Wednesday, March 17, 2021

Programming using Text or Blocks? Why not Both?

Continuing my look at papers from the SIGCSE 2021conference. The papers are available for free for a limited time. Get them while you can. In this post,  I take a look at Dual Modality Instruction & Programming Environments: Student Usage & Perceptions.

This paper took a look at the usage of Dual Modality IDE with students. Dual modality means that the IDE is capable of switching between text based programming and block based programming. The authors used the JetBrains plug-in Amphibian which creates Java code. While teaching AP CS Principles using the code.org curriculum, I used AppLab from code.org with students AppLab is also Dual modality though with JavaScript rather than Java.

I was curious to see if the author’s conclusions matches my far less rigorous observations. They basically did. That is to say that they saw students using the blocks to learn concepts and gradually move to text. Blocks often become a reference for learning concept and less for developing program solutions. I noticed much the same thing. Students might also use blocks to learn and switch to text when writing final solutions.

In my course, I did not mandate either blocks or text but let students switch at will. What I noticed is that students with a prior programming background in text moved to mostly text much sooner than students with no prior programming. Some students seldom used text even near the end of the year. This did not seem to impact final grades in my classes. As the authors of this paper found, I saw even the very comfortable with text students use the blocks to explore new concepts.

If you are thinking about dual modality environments (or not) I recommend this paper. I think you will find it supports the value of this sort of environment.

Are you using a dual modality environment? What are you seeing with it?

Monday, March 15, 2021

Zero Indexing Considered Harmful

As the old computer geek joke goes. the three hardest things in programming are naming things and off by one errors. Lately I have been thinking about off by one errors and wondering if having array and similar indexes start from zero rather that one is contributing the off by one errors by novice programmers.

I understand why many programming languages start indexes at zero. It’s a natural outgrowth of pointer arithmetic. After all if the pointer is to the beginning of an array or other data structure the first element is an offset of zero. The language could hide this though. In fact, FORTRAN and several other languages do start at 1. I used to use a version of BASIC (Basic-Plus) where not only was the first element an index of 1 but a programmer could specify the low and high index of an array at what ever numbers they wanted. Individual characters in a string could be accessed as if they were in an array as well. The first letter was at index of 1. An index of zero held the length of the string.

So we don’t have to start at zero. Does it matter? I don’t have any studies or data (someone please research this for their PhD) but I suspect that starting from zero promotes off by one errors especially for novices.

Getting beginners to grok that the first element in an array is zero is a struggle. It seems like a great many of novice errors come from assuming that the first item is a list is item number 1. I see the same issue with loops. Going from zero to less that some value does not come as easy to beginners as from 1 to some value.

So there is my theory, starting from one is better than starting from zero and could reduce off by one errors. As the meme goes, prove me wrong.

Thursday, March 11, 2021

What’s Up with Novice Programmers and Comments

Continuing my look at papers from the SIGCSE 2021conference. The papers are available for free for a limited time. Get them while you can. I take a look at Usage of the Java Language by Novices over Time: Implications for Tool and Language Design.

The BlueJ tool for teaching Java has the (opt in) ability to collect data on language usage by the novices who use it. This is a valuable research tool and the authors of this paper have taken a good look at it for a number of research questions. I recommend the paper for more insights but I was particularly struck by one finding. Students, in large numbers, delete the comments that BlueJ inserts in code automatically.

BlueJ adds stub JavaDoc comments (which can be used to generate documentation) into objects that are created. Over 45% of projects analyzed had no JavaDoc comments in them Students had gone out of their way to delete them. Not answered in the paper but I suspect many of the comments were not expanded from the default either.

What is it with students and comments? In my own teaching I often created stub projects with comments as sub-goal labels. In several cases I saw those comments deleted before coding started. In other cases the comments were left completely separate from the code created in ways that suggest they were ignored. I know that students don’t see the value in adding comments to their code. Is that our (educators) fault? I know that most of us try to teach good commenting practice but at the same time the projects we assign are easy enough to understand (usually) without comments. But why ignore comments clearly designed to help students?

What’s going on here? This looks like a great research question to me. I wonder if anyone is looking at it? What do you think?