Questions tagged [interfaces]
Questions about `interface` related design considerations, and also "programming to the interface instead of the implementation"
 742 questions
 
 - Bountied 0
 - Unanswered
 - Frequent
 - Score
 - Trending
 - Week
 - Month
 - Unanswered (my tags)
 
 
 0
 
 votes
 
 
 
 2
 
 answers
 
 
 
 140
 
 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?...
 
 
 
 
 
 0
 
 votes
 
 
 
 6
 
 answers
 
 
 
 289
 
 views
 
 
 
 
 
 Design pattern for exposing different parts of interface to different entities
 In a certain program I would like to have three objects, say, a, b, and c, with c being a shared private member (sub-object) of a and b. The data between the three objects shall only go this way:
a &...
 
 
 
 
 
 3
 
 votes
 
 
 
 7
 
 answers
 
 
 
 547
 
 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,...
 
 
 
 
 
 5
 
 votes
 
 
 
 2
 
 answers
 
 
 
 1k
 
 views
 
 
 
 
 Repository and Service Interfaces in an Accounting Software in Go with Uncle Bob's Clean Architecture
 I'm trying to get hands-on experience with Uncle Bob's Clean Architecture in Go, but I'm running into some issues. Also, I'm not yet familiar with all of Go's idioms.
For testing purposes, I'm ...
 
 
 
 
 
 3
 
 votes
 
 
 
 4
 
 answers
 
 
 
 401
 
 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 ...
 
 
 
 
 
 3
 
 votes
 
 
 
 3
 
 answers
 
 
 
 531
 
 views
 
 
 
 
 How to handle checked exceptions on interface contract in Java
 I am starting a project in Java and ran into the following situation. The application requires a persistence layer for a certain document type. This could be a MySql database, an AWS Dynamo DB ...
 
 
 
 
 
 1
 
 vote
 
 
 
 2
 
 answers
 
 
 
 226
 
 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 ...
 
 
 
 
 
 7
 
 votes
 
 
 
 8
 
 answers
 
 
 
 939
 
 views
 
 
 
 
 
 Why is "one function do more than one thing" a disadvantage of "boolean parameter", but not in "polymorphism"?
 According to Is it wrong to use a boolean parameter to determine behavior?, I know using boolean parameters to decide the behaviour is bad, for example, when using boolean parameters as the following:
...
 
 
 
 
 
 2
 
 votes
 
 
 
 4
 
 answers
 
 
 
 466
 
 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 ...
 
 
 
 
 
 0
 
 votes
 
 
 
 1
 
 answer
 
 
 
 428
 
 views
 
 
 
 
 Should I create interfaces for each entity, or should I use plain classes?
 I’m currently creating a class diagram to develop an application following the "Clean Architecture" guidelines by Robert C. Martin. I’m unsure about how to structure the "Entity" component, ...
 
 
 
 
 
 -2
 
 votes
 
 
 
 1
 
 answer
 
 
 
 220
 
 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 ...
 
 
 
 
 
 2
 
 votes
 
 
 
 2
 
 answers
 
 
 
 289
 
 views
 
 
 
 
 In Java Interface contracts, does the @throws tag order should be considered?
 Concrete example : https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/DataInput.html#readFully(byte[],int,int)
@throws NullPointerException if {@code b} is {@code null}.
is before
@...
 
 
 
 
 
 0
 
 votes
 
 
 
 1
 
 answer
 
 
 
 427
 
 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 ...
 
 
 
 
 
 2
 
 votes
 
 
 
 3
 
 answers
 
 
 
 271
 
 views
 
 
 
 
 
 "use auto" and "declare most abstract type", which guideline has higher priority?
 According to Why define a Java object using interface (e.g. Map) rather than implementation (HashMap), I know I should declare most abstract type when possible, for example, suppose I'm using an UI ...
 
 
 
 
 
 4
 
 votes
 
 
 
 2
 
 answers
 
 
 
 302
 
 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 ...