A Live Developer Journal

Recapping Need For Oo Design And Making Sure Classes Have A Single Responsibility

The first requirement for learning how to do object-oriented design is to immerse yourself in objects; Once you acquire an object-oriented perspective the rest follows naturally.

We need object-oriented design so that we can write code for today that is easy to change later, because change is inevitable.

OOD is about arranging what code you have so that it will be easy to change.

An object-oriented designer has tools, principles (SOLID, DRY, LoD) and patterns (common problems solved in common ways).

Design is worth it if it pays off (e.g. if it takes half your time in the morning but pays off in the afternoon).

Insist that it be simple. Your goal is to model your application using classes so that it does what it is supposed to do right now, and is easy to change later.

It’s impossible correctly group methods into the right classes at the early stage of your project. You don’t know enough. So the only goal is to make things easy to change.

A class should do the smallest possible useful thing; It should have a single responsibility.

An application that is easy to change is like a box of building blocks; you can select just the pieces you need and assemble them in unanticipated ways.