You are previewing Practical Object-Oriented Design in Ruby: An Agile Primer.

Practical Object-Oriented Design in Ruby: An Agile Primer

Cover of Practical Object-Oriented Design in Ruby: An Agile Primer by Sandi Metz Published by Addison-Wesley Professional
O'Reilly logo

Chapter 2. Designing Classes with a Single Responsibility

The foundation of an object-oriented system is the message, but the most visible organizational structure is the class. Messages are at the core of design, but because classes are so obvious this chapter starts small and concentrates on how to decide what belongs in a class. The design emphasis will gradually shift from classes to messages over the next several chapters.

What are your classes? How many should you have? What behavior will they implement? How much do they know about other classes? How much of themselves should they expose?

These questions can be overwhelming. Every decision seems both permanent and fraught with peril. Fear not. At this stage your first obligation is to take ...

The best content for your career. Discover unlimited learning on demand for around $1/day.