Questions tagged [interface-segregation-principle]

For questions about the Interface Segregation Principle (ISP) in object-oriented design, one of the SOLID principles enumerated by Robert C. Martin. It states that "clients should not be forced to depend upon interfaces that they do not use."

Robert Martin introduced the Interface Segregation Principle in 1996. It seeks to avoid coupling between different clients of an interface.

When clients are forced to depend upon interfaces that they don’t use, then those clients are subject to changes to those interfaces. This results in an inadvertent coupling between all the clients. Said another way, when a client depends upon a class that contains interfaces that the client does not use, but that other clients do use, then that client will be affected by the changes that those other clients force upon the class. We would like to avoid such couplings where possible, and so we want to separate the interfaces where possible.

Martin proposed the pattern as a solution to achieve interface segregation.

By making use of the ADAPTER pattern, either through delegation (object form) or multiple inheritance (class form), fat interfaces can be segregated into abstract base classes that break the unwanted coupling between clients.

Martin later included the ISP as the fourth of his .

See the ISP article under Principles of OOD.

57 questions
0
votes
4 answers

Trying to program to abstractions in C# but neither interfaces nor classes really work

I've been trying to apply SOLID principles more consciously on my current project. Using interfaces to create the abstraction and allowing classes that are handling the dependency injection to provide the concretions has really helped with…
0
votes
0 answers

Does the composite design patterm adhere the principles of SOLID (spacialy the L and the I)?

Does the composite design template adhere to the principles of solid? if all the compositing method are declared at the component its violation of the Interface Segregation Principle. if compositing method are declared at the composite its violation…
0
votes
1 answer

I need to understand how to use a strategy design on a project PHP Project?

Note: it's a PHP Project I have a situation where i use 2 API providers for my project. They are like similar with what info they (API) provides. I must set this right way since maybe tomorrow there will be some more APIs added. So my project will…
0
votes
1 answer

Does "Accept Interfaces" break deprecation tooling?

Deprecation The supported way of marking functions as deprecated is something like this: type MyStruct struct { } // MyFunc returns hello // Deprecated: Use YourFunc func (m MyStruct) MyFunc() string { return "hello" } Modern IDEs will highlight…
0
votes
1 answer

Interface Segregation Principle Problem where one interface inherits two interfaces that share the same parent

I have an application with the following types setup and in use. type CompanyFounder { name: string; age: number; salary: number; sharesHeld: number; getReasonStartedCompany: string; }; type NonExecDirector = { name:…
Andy
  • 2,124
  • 1
  • 26
  • 29
0
votes
2 answers

Cast EF6 and EFCore Entity to a single Interface?

Is it possible to join different version of Entity Framework (Core) Entities from two applications based on EF 6 (with .NetFramework 4.0) and EF Core 5.0 (.Net Standard 2.1) with the same DataBase into one Entity Interface instead of using the…
0
votes
1 answer

does default interface violate the Interface Segregation Principle?

in this question the author gives some reasons about why the default keyword is introduced into java language. One reason provided is to support the optional method. However, taking ISP into consideration, no client should be forced to depend on…
0
votes
1 answer

How to build stuff objects using the decorator pattern?

I have some questions regarding the decorator pattern. As I have understood it, the decorator pattern exists to add behaviour to an object, ie "decorating the object" so you can compose different objects without the need of implementing lots of lots…
0
votes
1 answer

Should I seperate test functions which throw error from test interface?

I am new at JUnit. I try to write unit test of a simple service class which is "ProductService". Here is my test codes for "ProductService" public interface TestProductService { void shouldCreateProduct() throws…
0
votes
1 answer

Violation of ISP

I asked a question about using the Strategy pattern and LSP, but the answer were mixed, and in the long run, it isn't good idea. However a comment at the bottom of my question stated that while I'm not in violation of LSP, I'm in violation of the…
user8753793
0
votes
2 answers

What is the difference between the ISP and the OCP?

I don't understand what the difference is between the Interface Segregation Principle and the Open/Closed Principle. What I understand is that the ISP must make everything depend on interfaces and the OCP on classes and I see that both of them can…
-1
votes
1 answer

Advantage of Using Interface in production application

I am programming in java for a while not much used interface. I just wondering what are the benefits of using interface. I read a article about loose coupling it states that Tight coupling makes it much harder to add new functionality. With loose…
1 2 3
4