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.


Keyboard Shortcuts

Key Action
o Source
e Edit
i Insight
r Random
h Home
s or / Search
www.joshbeckman.org/notes/865858244