A 2-3 day course for programmers that describes the basic attributes of well-written code.
- Programmers of all levels of experience who desire to improve the most fundamentalof their skills: Writing good, clean code.
- The two day version is weighted towards lecture and demonstration with a minimum of exercises.
- The three day version shifts the weight towards in-class practice and exercises, withoutdiminishing the lectures and demonstrations.
After this class students will be:
- ...able to recognize the elements of bad code, including within functions, classes,arguments, and comments.
- ...able to review code with an eye towards cleanliness and design.
- ...able to plan and execute code cleanup without risk to the application.
- ...able to incrementally improve bad design choices.
- ...much more aware of the quality of the code they, and their team-mates are writing.
- What does it mean to be clean?
This is a discussion of the motivation, costs, and benefits of keeping code clean.Several different scenarios and principles are discussed.
- The business cost of bad code.
- The Productivity Roller-Coaster.
- Race to the Bottom.
- The Grand-Redesign Myth.
- Why Does Code Rot?
- The Only Way to go Fast...
- What is Clean Code?
This section is based on interviews with many famous programmers. The conclusion is:
- The Boy Scout Rule: "Check the code in cleaner than you checked it out."
- Bad Code Dumpster Dive.
A 1-2 hour, character-by-character on-screen walk-through of some very bad code. The problems with this code, and the motivations of the programmer are discussed in detail.
This is derived from Tim Ottinger's famous paper describing naming rules for variables,classes, and functions. Among the topics discussed are:
- Name length for variables, functions, and classes.
- Revealing Intent.
- Ubiquitous Language.
- Optical Illusions and Disinformation.
- No More Hungarian Notation.
- Meaningful Distinctions.
This section is about functions should be structured and composed. Much time is spent onthe need to keep functions small and expressive.
- The Step-down Rule.
- Do One Thing.
- Extract till you Drop.
- Avoid Switch Statements.
- Arguments: Good and Bad.
- Side Effects
- Command-Query Separation.
- Code Duplication: DRY.
- Structured Programming
- Demonstration: Cleaning Code.
A 1-2 hour on-screen demonstration of how bad code can be quickly and competently cleaned; without fear..
This sections is about the good, the bad, and the ugly when it comes to comments. The overriding principle of this section is that comments are are not pure good.
- Examples of bad comments.
- Examples of good comments.
This section is about the proper formatting of source files. In it we discuss a statisticalstudy of many different projects, and the formatting rules that study implies.
- File size.
- Vertical Formatting.
- Horizontal Formatting.
- Coding Standards.
Techniques for practicing and improving good coding skills.
Several coding exercises and demonstrations as time permits.