Lay out what good programming style consists of for your class to encourage good style and make debugging easier.

  • Explain why good style is important to your students. For instance, good style:
    • ensures there is no confusion when grading assignments.
    • improves readability of code, so it will save them a lot of time in the long run 
    • prevents bugs and makes it easier to debug.
      • It is not just meant to make the code look nice.
  • Good style practices include:
    • Proper Indentation and position of curly braces
    • Descriptive names for classes, methods and variables
    • Initializing variables and using named constants
    • Structured commenting.
    • Strategic use of white space.
    • Breaking up code into smaller, logical chunks.
  • Students should be coding with good style throughout the programming process, not simply implementing good style after the fact.

More about this tip

External Source

Tips from Deborah Power Carter The College Board’s AP Computer Science Teacher’s Guide.

Interview with Cynthia Lee