Check out the SOLID series:
- Single responsibility,
- Liskov substitution,
- Interface segregation and
- Dependency inversion
SRP: Every class should have a single responsibility. If we have a class ‘Person’, which can be a fundamental class for a software; should contain information and not the other operations.
In this example class, we have used the class just to store the values from the instance of the class. If we have to allow any operation, for ex CRUD (create, read, update and delete), we have to write another class ex PersonManager class which will do this operation.
One can create a GOD class/method, which will have all the functionality in the same large file. But in this way the software will be tightly coupled. Hence, for adding new feature or re-usability of the code will be very difficult and might leads to the duplicity of the code.
In basic class designing, encapsulation is implemented by making the member variables private and the accessing methods get/set as public. Thus a class can be controlled and data can secured from the outer world. A small functions not only prevents the modularity of the logic implemented, but also can be easily extended without rewriting the existing logic.
Single responsibility principle is a first step to move to SOLID programming by avoiding the STUPID methodology.