I was reading a text about SOLID principles and Open/Close principle and it said that : “The main idea of this principle is to keep existing code from breaking when you implement new features” what it means by breaking code? Answer You “break” existing code when you modify it in a way that prevents it from working for existing or
Advertisement
Tag: solid-principles
Applying Interface Segregation Principle to service layer interface
Using the book as analogy, suppose I have a book resource with the following API (there are also update and delete etc but for simplicity only show two here) Each of these API would call other APIs to get the result, rather than the typical CRUD database operation. And based on the requirement / existing framework constraint, there are separate
Java – violation of Liskov substitution principle?
I have the following code: interface Ops{ void remove(); } interface BeforeRemove{ void doBeforeRemove(); } class A implements Ops{ @Override public void remove() { System….
How to create a self registering factory in Java?
Factory pattern violates the OCP principle because it uses if() statements, which implies that if any class is added then the factory class has to change, being against SOLID principles. Self …
Advertisement