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

1 Comment (+add yours?)

  1. Trackback: Teaching in the 36K Computer Lab, part 6 | Occasional Observations of Traveling Technology Coach

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

October 2021
M T W T F S S
 123
45678910
11121314151617
18192021222324
25262728293031
%d bloggers like this: