Questions tagged [interfaces]
Questions about `interface` related design considerations, and also "programming to the interface instead of the implementation"
742 questions
0 votes
2 answers
142 views
A class that implements two interfaces that extend the same interface [duplicate]
I'll get straight to the point. I want to implement a class structure in Java similar to the one in the image. Am I falling into bad practice with this kind of diamond-shaped interface implementation?...
3 votes
7 answers
555 views
Do I need to create an interface for every service class to follow good design principles?
I'm working on a custom Magento 2 module in my internship, and I'm trying to follow SOLID principles in my code. Right now, my controller actions handle everything: getting request data, processing it,...
3 votes
4 answers
408 views
When wouldn't I want to allow polymorphic deletion in C++?
When designing a pure virtual base class (interface) in C++, in what cases would I not want to allow polymorphic deletion via a pointer to my base class? I've seen questions about why you should make ...
1 vote
2 answers
229 views
Interface with member interface?
Let's say I am coding an C++ application which needs to drive some motors with some hardware interface (USB, Serial...). There are several kinds of motors, which expose the same services, but with ...
2 votes
4 answers
479 views
Is casting a concrete type to an interface and using it if it successful bad practice?
I recently came across some code: val, ok := i.(SomeInterface) if ok { val.Method() } The above is Go, and attempts to cast to an interface and then runs the method for that interface against the ...
-2 votes
1 answer
221 views
Vanilla interface implementations. What should I call it? [closed]
Some may think I'm kidding, but I'm really stuck on this Suppose you have some UserDao interface that you want to implement What should you call it? Here are a few points I'd like to make I firmly ...
0 votes
1 answer
437 views
DTO Interfaces naming convention in PHP
It might be that my question would sound a bit stupid but I would like to find the best way for naming my DTO interfaces. In my PHP application I have following DTO types: Simple (which contains a ...
4 votes
2 answers
308 views
Interface + Trait vs Abstract Class
While developing my application I faced an interesting situation: I have multiple DTO's which are almost identical in terms of methods, only properties are different. For example I have AccountDTO ...