The single-responsibility principle (SRP) is a computer-programming principle that states that every module, class or function in a computer program should have responsibility over a single part of that program's functionality, and it should encapsulate that part. All of that module, class or function's services should be narrowly aligned with that responsibility.
Most developers interpret to mean that a class should perform only one task. But it's not only classes, functions you implement in code during development should also perform only one task. So one should interpret it as meaning that an implementation should perform only one task.
One class can perform multiple tasks, there is no question of that, but it's not going to provide quality / better output.
So to get good quality/better output of work, one method should do one task at time.
- What the single responsibility principle is
- Why the single responsibility principle is important
- How to use the single responsibility principle
- How to spot violations of the single responsibility principle
- Clean: clean and standard code
- Maintainable: Manageable and easy for maintenance
- Scalable and redable: Easy to refactor or change and readeble code
- To many small modules/classes
- Take more time for development and increases project cost