13
Clean Classes
by Jeff Langr
In Chapter 7, “Clean Functions,” you learned how to best organize code statements and expressions in the form of functions or methods. Hopefully you learned these important things about clean functions:
Functions provide a way to declare, invoke, and reuse pieces of logical behavior, or concepts.
While nothing prevents you from aggregating multiple concepts into a single function, you’re much better off if you compose methods that capture small, discrete concepts.
In this chapter, you’ll hear echoes of the advice from Chapter 7 at the next-higher-up organizational construct: classes or modules.
Your programming language allows you to group concepts into a single construct—a class, if you’re coding with an object-oriented ...
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