Design principles
This chapter and the following sections cover object-oriented design principles, its characteristics, and the design patterns in detail. Each pattern section covers its need, design considerations, and best practices so that readers get the idea of patterns and its applications.
Let's start with a core principle usually referred to as an acronym "SOLID," in detail.
Single responsibility principle (SRP) – SOLID
In object-oriented programming style, the single responsibility enforces that each class should represent one and only one responsibility and so if it needs to undergo changes, that should be for only one reason, that is, a class should have one and only one reason to change.
When we design a class or refactor a class and if it needs more than one reason to change, split the functionality into as many parts as there are classes and so, each class represents only one responsibility.
Responsibility in this context is any changes to the function/business rules that causes...