Hard to find good concrete examples of design trade-offs. But here is on a colleague of my recently pointed out in a code review.

Method takes a bool

func switchToChatTab(hasActivationFailed: Bool)

and then does something interesting. But if the thing that is changing is a struct or something else, pass that in instead.

func switchToChatTab(with entryPoint: EntryPoint)

Now this function is open for extension but close for modification. Even better if the struct captures the Bool you were passing around before.

Advertisement