S — From SOLID principles 1/5

The single responsibility principle states that your classes and functions should have only one reason to change. To put it another way, your classes and functions should do one job at a time.
I’ve attached an image where I demonstrated by writing left side doing two different tasks in one class and function. Auth and Log. This clearly breaks the rule as one can change the function of this class for two reasons.
1) Authentication
2) Logging
Now see on the right side I split one class into two giving them a single job each. Clean. #CleanCode #SRP #SOLID_PRINCIPLE
Share this article

Written by : admin
Latest Articles
June 21, 2024
June 11, 2024
June 10, 2024
May 31, 2024
May 27, 2024
May 10, 2024
February 1, 2024
December 28, 2023
December 26, 2023
December 18, 2023
December 15, 2023
September 26, 2023
September 21, 2023
September 19, 2023
September 19, 2023
September 12, 2023
September 5, 2023
August 29, 2023
March 31, 2023
March 20, 2023
March 13, 2023
March 13, 2023
March 13, 2023
March 13, 2023
March 13, 2023