Skip to main content

Phase 2 -- Specify with Types

Chapters 47, 48, 49: Types as the Language of Intent

Your role: Specifier -- "I can tell AI precisely what to build"

In Phase 1, you learned to read Python: predicting output, building trace tables, catching bugs, and completing your first TDG cycle. You can look at code and understand what it does. Now you learn the language that lets you tell AI what to build.

Phase 2 teaches you the type vocabulary for writing specifications. You learn primitive types and expressions, strings and typed collections, and function signatures as contracts. By the end, you can write a type-annotated function signature with multiple parameters, default values, and a docstring that tells AI exactly what to build: no ambiguity, no guessing.

Every chapter builds toward your SmartNotes project. You start with typed variables for note fields, add collection types for tags and metadata, and finish with a complete set of typed function stubs that AI implements for you. The data uses dict[str, str] for now: functional but fragile. You will feel that fragility when typos in dictionary keys crash your code at runtime. That pain motivates Phase 3, where structured data models solve the problem.

#ChapterKey Focus
47Primitive Types and ExpressionsThe building blocks: int, float, str, bool, None, arithmetic, comparisons, type conversions
48Strings and CollectionsString operations and typed containers: list[str], dict[str, int], tuple, set
49Functions as ContractsFunction signatures as specifications: parameters, return types, defaults, docstrings