Grokking SOLID Design Principles
Vote

0% completed

What Counts as One Responsibility

The previous lesson said a class should do one thing. That is the usual way to state the Single Responsibility Principle, and it is the reason the principle is so often applied badly.

The trouble is that "one thing" has no fixed size. Is saving a user one thing? Is validating an email address part of registering a user, or a thing of its own? Two careful engineers can disagree all day, because the phrase gives them nothing to measure.

There is a sharper definition, and it is the one worth carrying into a code review.

One Reason to Change

A class should have one reason to change.

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%