Writing Correct Code
Map
Arrows point from what you learn first to what it opens. Point at a concept to light up its chain and where it comes back deeper. Right-click a concept (or press and hold it) for its lessons and stories.
- Proven to depth123
- Open
- Locked
- Comes back deeper
Learning path
In the order the concepts build on each other.
- Edge casesLockedInputs at the edges of what a program handles - exactly on a boundary, zero, a value that shouldn't happen - where most bugs in decisions hide.Opens after: Conditionals
- ExceptionsLockedThe way a running program signals that something went wrong, so that code can catch the problem and carry on, or stop with a clear message instead of carrying on with nonsense.Opens after: Type conversion, Functions in code
- Type annotationsLockedNotes in the code saying what type each parameter, return value or name is meant to have, so that people and tools know what a function wants and gives back.Opens after: None, Dictionaries
- Code readabilityLockedWriting code so that the next person, often yourself months later, can quickly understand what it does and why: clear names, docstrings, comments that explain, one shared style.Opens after: Type annotations
- Static and dynamic typingLockedWhether a program's types are checked before it runs, by a compiler or a type checker, or only as each line runs, as Python does.Opens after: Type annotations
- TestingLockedChecking that a program does what it should, by deciding the right outputs for chosen inputs first and letting code such as assert compare them every time the program changes.Opens after: Edge cases, Exceptions
- DebuggingLockedFinding out why a program does the wrong thing, by reading its error messages, guessing a cause, and checking the guess against the program's real values.Opens after: Error messages, Testing
Connections to other domains
- Exceptions leads to NoneData Types
- Testing leads to DecompositionFunctions
- Exceptions leads to EncapsulationObjects and Classes
- Exceptions leads to Files in codeOrganizing Programs
- Debugging needs Error messagesProgram Basics
- Edge cases needs ConditionalsControl Flow
- Exceptions needs Type conversionData Types
- Exceptions needs Functions in codeFunctions
- Type annotations needs NoneData Types
- Type annotations needs DictionariesData Structures