41 / 80 · 12 Programming for QA · Functional Patterns for Testing← prev⊞ allnext →☰ Read as one page
5.7When to Use Functional vs OOP
| Situation | Approach | Why |
|---|---|---|
| Page objects, framework structure | OOP | State management, encapsulation |
| Data transformation in assertions | Functional | map/filter/reduce are concise |
| Pre-configured utilities | Closures | Capture configuration, return focused functions |
| Test data generation | Factories (closure) | Unique data with consistent defaults |
| Processing test results | Functional pipeline | Each step is independent and testable |
| Complex test setup | OOP (fixtures) | State lifecycle management |