S - From SOLID principles 1/5
Image explaining Single Responsibility Principle

S - From SOLID principles 1/5

S - From SOLID principles


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

要查看或添加评论,请登录

Umair Khalid的更多文章

  • Github Page design

    Github Page design

    Hey devs, Check out my Github page. https://lnkd.

社区洞察

其他会员也浏览了