SECTION 06 / 6
Choose the right solution
When choosing a design approach, first identify the problem described in the sections: overall system organization (architecture), class responsibilities and dependencies (SOLID), object creation (creational patterns), interface compatibility or subsystem simplification (structural patterns), or object communication and algorithm selection (behavioral patterns). The comparison below summarizes these distinctions.
| Situation | Likely concept | Why |
|---|---|---|
| Search site receives browser requests | Client–server | Request and response |
| Compiler processes code in stages | Pipe-and-filter | Sequential transformations |
| UI should not contain data rules | MVC | Separate view, model and control |
| Large Seller class mixes unrelated tasks | SRP | Separate responsibilities |
| New product category changes Product every time | OCP | Extend rather than edit stable core |
| SMSNotification cannot use notify(…, email) | LSP | Preserve substitution behavior |
| E-book order forced to implement packageOrder() and deliver() | ISP | Avoid irrelevant interface methods |
| Seller code creates BankAccount directly | DIP | Depend on PaymentAccount |
| Choose a courier implementation | Factory Method | Select a concrete product |
| Create Book with many optional fields | Builder | Stepwise construction |
| Order placement requires four service calls | Facade | One simple entry point |
| Product cannot call ConversionCalculator directly | Adapter | Translate incompatible contracts |
| Traverse many books | Iterator | Hide collection representation |
| Notify subscribed buyers | Observer | Publish updates |
| Choose FIFO or priority processing | Strategy | Swap algorithms |
