Teaching in the 36K Computer Lab, part 5

Part 5, Beautiful Code

In the previous post, I had the students command the Bender Robot to walk to the light switch using only “turn left,” “turn right” and “move forward” commands.

I explained:

that “command” is both a verb and a noun: you command a robot to do something with commands.)

I explained:

that the list of commands it took to get me to the light switch (i.e., turn right, move forward two steps, turn left, move forward six steps, etc.) was called a “sequence” of commands, which is also known as an algorithm. (I wrote one or both of these vocabulary words on the smartboard depending on the level of the students).

I explained:

that it is better to stay “move forward ten steps” rather than “move forward one step” ten times.

I explained:

that less is more, that shorter code is more beautify code.

I explained:

“If, when commanding a robot, you can use either five commands to do something, or you can use four commands to do the same thing, it is better — it is more beautiful — to use four commands. And, if you can do the same thing with just three commands, it is more beautiful to do it with three. Fewer commands equals more beautiful coding.”

I explained:

“see my face? That is not the beauty I am talking about. I am talking about the beauty of using the fewest commands to accomplish something.”

This was the introduction to beautiful code, and I brought it up in subsequent lessons.

To be continued

November 2021
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930