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
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
Does Interface Segregation Principle apply to data structures?
Lets imagine that we have a large data structure (lets call it Configuration) and various client classes (lets call them Services). Each service needs just one or two fields from Configuration. If we inject the whole Configuration object to the various Services, does this violate the ISP? Does the fact that Configuration is technically a data structure and not a
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 registering classes are supposed to address this problem according to this resource: http://www.jkfill.com/2010/12/29/self-registering-factories-in-c-sharp/. The problem is that i don’t know C#. Can someone make an example of this in