Single Responsibility Principle
The Single Responsibility Principle states that objects should have one, and only one, purpose.
This is a principle that is very often violated, especially by new programmers. Often you’ll see
code where a class is a jack of all trades, performing several tasks, within sometimes several
thousand lines of code, all depending on what method was called.
To the new OOP developer, classes are often viewed at first as a collection of related methods
and functionality. However, the SRP advocates against writing classes with more than one
responsibility. Instead, it recommends condensed, smaller classes with a single responsibility.
Do'stlaringiz bilan baham: |