Chapter 9. Conditional Logic
It’s natural that object-oriented programming is focused on objects and their relationships, but the code within an object is important too. Classic books like Jon Bentley’s Programming Pearls [6] and More Programming Pearls [7] or Brian Kernighan and P. J. Plauger’s The Elements of Programming Style [18] can help inspire you to write good, clean code.
Conditional logic is often the trickiest part of such code.
• It’s hard to reason about, since we have to consider multiple paths through the code.
• It’s tempting to add special-case handling rather than develop the general case.
• Conditional logic sometimes is used as a weak substitute for object-oriented mechanisms.
In this chapter we’ll cover the following smells: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access