Small Group 2.1a - What does "good" code look like?

In this unit we want to reflect on the idea of code "quality." That is, "what does good code look like?" Ok, it isn't really that simple because it often isn't a binary between "good" code and "bad" code. There is clearly bad code and clearly great code. But there are also a lot of shades of grey in between. But no matter how we consider it, there are definitely elements of writing or presenting your code that makes some code "better" and some code "worse." In this unit we want to consider those issues and how/when you might teach about these issues.

To get us started with that I want to have you spend some time looking at code and considering which things make code better and which things make code less desirable. We will do this by looking at a wide variety of solutions to code that students have written in the past for homework in my class. I went through the submissions and grabbed anywhere from 3 to 6 solutions that were submitted for each one. Some solutions are clearly "better" but almost all of the solutions have good elements and "less good" elements. The purpose of this assignment is to have you look at the code with a small group and try to figure out what, TO YOU, makes code "good."

You will notice that I am trying very hard here NOT to use the term "bad" because that is such a judgemental phrase and implies that the student should have known better. You will notice that in FOP last fall I almost NEVER commented on HOW you programmed your solution. If it passed my tests then it was "good" code. Please do not take it personally if your code happens to show up in one of these examples and your group mates flag it as "bad." That is NOT the purpose. The goal is to start to consider what makes code easier to read, follow, process, and to a certain point, make it more efficient for the computer.

We will do this over the course of two class periods. Today we will focus on the code written early in the process of learning python and look at the homework assignments for conditionals and loops.

 

The assignment

For each of the 8 programming assignments that are listed above I would ask you to:

  1. Review the actual program requirements by looking at the "Original Assignment" page.
  2. Consider the examples listed for that assignment.
  3. For each of the examples identify elements of the solution that you think are "good" and elements that you thing are "less good" or "to be avoided" by programmers who are gaining skill at writing code.
  4. After you have completed each set on an individual assignment, start to identify elements of the code overall that makes code "good."