Note on FlagArgument via Martin Fowler
My general reaction to flag arguments is to avoid them. Rather than use a flag argument, I prefer to define separate methods.
class Concert... public Booking regularBook(Customer aCustomer) {...} public Booking premiumBook(Customer aCustomer) {...}My reasoning here is that the separate methods communicate more clearly what my intention is when I make the call.
The main reason, for me, to avoid flag arguments is because it makes a single method “do” multiple things. That makes it harder to read, harder to reason about, harder to test, etc.
Reference
- Notes
- software-engineering, code-snippets
- FlagArgument
-
Permalink to
2025.NTE.043 - Insight
- Edit
| ← Previous | Next → |
| Note on Tiny Fish via Disturbances | Note on Hierarchy of Controls via Hillel Wayne |