HFDP - Single Responsibility

Accordingly to the Single Responsibility Design Principle we should strieve for give to a class only one reason to change.

Any responsibility represents also a reason for possible changes. If a class has more than one responsibility, it would have also more than one area of changes.

Tending to the single responsibility paradigm helps us to design the class with an high cohesion. We say that a class has an high cohesion when it is designed around a set of related functions.

This is the principle that guided to the Iterator pattern, since it extracts that functionality from the relative collection, giving it an heigher cohesion.

In chapter eight of Head First Design Patterns, by Freeman, Freeman, Sierra, Bates, is said more on this design principle.

No comments:

Post a Comment