Rashmika is an ex Google SWE. She quits her job and now a 5 star rated Software consultant at Upwork. She wins a 6 month fixed contract of $250K from an US Client. She plans to buy her parents their dream home with it. But this gig is not typical software development. Rashmika was asked to fix, stabilise and upgrade an existing Library management codebase. Robert is the manager and Rashmika’s point of contact. Robert says “Rashmika, some freelancers have built our app. Whenever we make any change to the existing code, some other features gets impacted. The codebase is convoluted and other freelancers charge us a bomb for a small change.” Rashmika is a pro in client handling. She scopes down the problem and “Which specific area you are most worried about?” Robert “The User Management and Account Management, one change leads to other” Rashmika is shocked seeing the code. She finds an Interface called ILibraryManagement which has almost 70+ methods like 1/ loanBook 2/ catalogManager 3/ returnBook 4/ userProfiles… She sighs, “This is gonna be a long work day.” Rashmika to Robert “The problem is with the fundamental design of the system. There is a concept called Interface Segregation Principle. The interface segregation principle (ISP) states that no code should be forced to depend on methods it does not use. And this interface is bloated with unnecessary methods for some classes” Robert, “But that’s an interface how do that matter?” Rashmika, “When you hire other freelancer they create a sub-class of Library Management which has methods that they don’t need. They don’t change the interface. They include the unnecessary empty methods in there new class. The empty methods simple throws an exception when called. This has made the code 1/ cluttered 2/ very hard to unit test 3/ prone to errors Also violating Single Responsibility Principle but let’s not go there. So there is no segregation of features between freelancers and there is high chance that they are changing old code to make there new code work” Robert “Are you sure?” Rashmika smiles and says “ I have been in Google. I have seen codebases that literally runs the world. Robert, let's start with the fundamental problem then we work upward to find and fix bigger issues. How does that sound?” Robert, “Aye aye Captain!” — Few points to consider : 1/ There can be plethora of problems but if the fundamental structure of the code is weak it weakens the entire system. 2/ ISP was introduced to improve Code Understandability, Maintenance, UT 3/ ISP if not followed violates SRP and cascade of failure can happen. 4/ Rashmika is a fictional character 5/ There are many other ways to fix the given problem, but this story only explains the ISP in a closed context. — I am Sagar, Software Architect at McKinsey. I write these stories to simplify building software and your career. ⚡️ Follow me for more such content. Bonus: Don’t stop here, go and read the technical depth on Wikipedia.
@sagar_codes I can relate each and every statement explained here. A lot of developers don’t understand the principles of design, end up with such a mess. I’d say Interface Segregation Principle is something that led to the idea of Microservices Architecture as regards to APIs.
@sagar_codes Sirji Suprabhat, ISP and doing this is not a good coding practice I got it but if any class implements an interface and used a method which are not called anywhere. How can that create a problem.
@sagar_codes Nice storytelling Sagar!🙂 Keep going...👏
@sagar_codes interesting take Sagar, love these stories.
@sagar_codes Wow, this indeed was a great explanation ❤️. Following you right now to learn more concepts in form of stories 🙌❣️
@sagar_codes Did I understand most of what I just read? Nope, at some point, I got lost🥲 Was it interesting? Yeah😂
@sagar_codes Dammn! That's really awesome. Thank You for sharing
@sagar_codes You got the hook of the story right. Awesome man. Followed👍
@sagar_codes in a nutshell, DEAR SOFTWARE DEVS, DON'T JUST MUG SOLID PRINCIPLES, IMPLEMENT THEM
@sagar_codes Had to follow you for this amazing content
@sagar_codes Any books in this kind of topic? Please do recommend
@sagar_codes How the hell you again in my TL.. by the way good read
@sagar_codes Tch. She could create a composite that implements ILibraryManagement and save refactoring time.
@sagar_codes Very nice story, it revises the SOLID principles and how important it is for developers to know what exactly these principles are, and why to use them almost all the time. Keep posting more!
@sagar_codes man you are a master of this art ... u literally compelled a random reader ( me ) to follow you 🙌
@sagar_codes Well structured and nice explanation with fictional characters
@sagar_codes This is awesome, I love the way the story is told. Am following you and turning on the notifications bell for more stories ❤️