1. Before writing code
E.g. UpFrontDesign, UnifiedModelingLanguage (UML), ObjectOrientedAnalysisAndDesign (OOAD), ArchitecturalSpike
2. While writing code
E.g. TestDrivenDevelopment, or just normal improvisational coding
TDD implies that tests (a form of system definition, and thus part of its design) are written before code
3. After writing code
E.g. ReFactoring, RefactoringToPatterns
See also SoftwareDesign