Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

All Patterns: Quick Reference Card

📚 REFERENCE | All 20 patterns at a glance

Quick lookup for all patterns. Use this to find a pattern and jump to its full description.


Testing Patterns (5)

#PatternProblemSolutionLearn More
1AAA PatternTests are unreadableStructure into Arrange-Act-Assert
2Error Path TestingFailures aren't testedTest both success AND error paths
3Boundary ConditionsEdge cases are missedSystematically test limits
4Resource CleanupTests leak resourcesAutomatic fixture cleanup
5Real CollaboratorsMocks hide bugsTest with real implementations

Key: These 5 patterns are the foundation. Use them in every test.


Architecture Patterns (5)

#PatternProblemSolutionLearn More
6Generic Base LayerCode duplicationExtract generic abstractions
7Extension LayerCan't extend without modifyingAdd layers for safe extension
8Composition Over DuplicationDRY violationsCompose instead of copying
9Single Source of TruthData inconsistenciesOne canonical source
10Capability GroupingMonolithic modulesOrganize by capability

Key: These 5 patterns organize code structure. Use during architecture phase.


Design Patterns (10)

#PatternProblemSolutionLearn More
11Zero-Cost AbstractionsAbstractions are slowUse generics, compile away overhead
12Type Safety with GATsType errors at runtimeGeneric Associated Types
13Sealed TraitsAPI is too easy to misuseSeal traits to prevent misuse
14Compile-Time ValidationErrors caught at runtimeValidate during compilation
15Type State EnforcementState machines are error-proneEncode states in the type system
16Fixture LifecycleComplex test setupManage with sealed traits
17Builder-Driven Test DataBuilding test data is tediousFluent builders for data
18Timeout DefenseTests hang indefinitelyTimeout defense in depth
19Feature Gate SlicesFeature flags are unreliableSlice-based feature gating
20Macro Pattern EnforcementPatterns are easy to violateUse macros to enforce

Key: These 10 patterns provide safety, performance, and design tools. Use during implementation.


Pattern Organization

By Complexity (Learning Path)

Phase 1 - Foundation (Read First)

  1. Pattern 1: AAA Pattern
  2. Pattern 2: Error Path Testing
  3. Pattern 3: Boundary Conditions

Phase 2 - Production Ready (Read Next) 4. Pattern 4: Resource Cleanup 5. Pattern 5: Real Collaborators 6. Pattern 17: Builder-Driven Test Data

Phase 3 - Architecture (Advanced) 6. Pattern 8: Composition Over Duplication 7. Pattern 10: Capability Grouping 8. Pattern 9: Single Source of Truth

Phase 4 - Advanced Design (Mastery) 11. Pattern 11: Zero-Cost Abstractions 12. Pattern 13: Sealed Traits 13. Pattern 15: Type State Enforcement 14. Pattern 20: Macro Pattern Enforcement


By Category (Type System)

Testing Patterns: Patterns 1-5 Architecture Patterns: Patterns 6-10 Design Patterns: Patterns 11-20


By Problem Domain

Testing Problems: Patterns 1-5, 17 Code Organization: Patterns 6-10 Type Safety: Patterns 12, 14, 15 API Design: Patterns 13, 20 Performance: Pattern 11 Robustness: Pattern 18 Reliability: Pattern 19


How to Use This Card

  1. Find your problem in the Problem column
  2. See the solution in the Solution column
  3. Click Learn More to read the full pattern
  4. Bookmark the pattern for future reference

Want to...Go to...
Choose a patternChoosing Your Pattern
Learn testingTesting Learning Sequence
Learn architectureArchitecture Learning Sequence
Learn designDesign Learning Sequence
All 20 patternsThis page (you are here)

Pattern Dependencies

Some patterns build on others. Recommended learning order:

Pattern 1 (AAA)
  ├─→ Pattern 2 (Error Paths)
  ├─→ Pattern 3 (Boundaries)
  ├─→ Pattern 4 (Resource Cleanup)
  └─→ Pattern 5 (Real Collaborators)
       └─→ Pattern 17 (Builder Test Data)

Pattern 6 (Generic Base)
  └─→ Pattern 8 (Composition)
       └─→ Pattern 10 (Capability Groups)

Pattern 14 (Compile-Time)
  └─→ Pattern 15 (Type State)

Pattern 13 (Sealed Traits)
  └─→ Pattern 20 (Macro Enforcement)

Statistics

MetricValue
Total Patterns20
Testing Patterns5
Architecture Patterns5
Design Patterns10
Difficulty RangeBeginner → Advanced
Total Learning Time~10 hours
Estimated Implementation2-3 weeks

Pro Tips

💡 Tip 1: You don't need to learn all 20 patterns at once. Start with Testing (1-5), then add what you need.

💡 Tip 2: Patterns often appear in combinations. When you use Pattern 5 (Real Collaborators), you'll probably also use Pattern 17 (Builder Test Data).

💡 Tip 3: Look for patterns in the codebase you're reading. The more you see patterns, the better you'll understand them.

💡 Tip 4: Bookmark the Decision Guide. You'll return to it when solving problems.


Next: Choose your learning path or jump to a pattern you need right now!