Questions tagged [interfaces]

Questions about `interface` related design considerations, and also "programming to the interface instead of the implementation"

Filter by
Sorted by
Tagged with
-4
votes
0answers
22 views

Techniques for exposing a rest APi under development to a cloud hosted project also under development?

My specific scenario is I have a Spring boot based rest API published to a development server behind our firewall. Another team is developing a website on a cloud hosted Drupal system. They want to ...
0
votes
0answers
83 views

c# class structuring and appropriate coding techniques

I have 2 classes that share some properties public class SportsUser { public string errorCode { get; set; } //the sportsuser and SportsAdminUser is from a different database hence the long and ...
1
vote
0answers
94 views

How can I improve this API solution

Intro I'm creating an app and I'm not sure if the structure of the solution is correct. I have a BaseController that uses generics. This controller is inherited by others that do not have to ...
-2
votes
2answers
78 views

Does acceptinga a handler instead of returning a result have a name?

def create() -> sock.sock: ... return sock def create_(func: callable)-> None: ... func(sock) return What are the names of those two interfaces between* a socket creator ...
1
vote
2answers
146 views

Where should I start using Interface only?

The more that I'm reading, the less I know about this one. I'm actually working on a new website using Symfony. In Symfony, you have the concept of Entity. An entity represent basically an object and ...
-1
votes
2answers
106 views

What design/component principle did I apply? How can I further improve it?

I recently refactored a program for code feasibility and maintainability; however, I am totally unaware of what software principle I did implement. I just followed my feeling. The purpose for this ...
3
votes
2answers
124 views

How to handle additional parameter to existing interface

In my existing code, I have an interface like so: public interface IStudentService { T GetStudent(int userId); } This interface is called in many places, and the concrete implementation, let's ...
0
votes
1answer
85 views

How can I have two interfaces implement one interface?

I have device interface classes written in c# for electronic variable loads. They are mostly for DC devices. We got a new one that does loading for both AC and DC devices. I also have an interface ...
5
votes
1answer
379 views

Why were default methods introduced to Java?

Was introducing default methods to java inevitable? As far as I know multiple class inheritance was not introduced to avoid difficulties with the method signature clash in base classes. So we avoided ...
1
vote
1answer
143 views

C#: Should I define methods as async?

I have a C# (WPF) application which consumes a particular 3rd party API/tool (let's call this Tool A). My colleagues and I are trying to decouple that from our application, so that it is possible to ...
1
vote
2answers
129 views

Is there a difference between abstract data type and interface?

From what I understand, an abstract data type is basically some data and what we are allowed to do with that data (ex. a list with a set of data and an attribute size and the functions get(), set(), ...
-3
votes
1answer
80 views

What is meant by service? [closed]

We know there are services in windows but I am reading a book by Ed Snider and he uses the term “service” whenever his program requires a certain feature/functionality. Like he creates a navigation ...
0
votes
4answers
149 views

When to pass a concrete object, vs a way to obtain the object

Say there is some view that displays user details like name, age, email, etc. That view could maybe be constructed with the following pseudocode: UserView(User user); And that view would be able to ...
0
votes
4answers
202 views

Is it an issue to have multiple almost identical interfaces?

Is it an issue to have multiple almost identical interfaces? In our company we have 9 identical interfaces for 9 document types, like: Book, Contract, Person, etc. interface IBookInner { Book ...
1
vote
2answers
104 views

In C#, is it reasonable to use a #region when I need several members to implement a common interface?

I know that lots of people hate #regions in C#. IMO there is at least one legitimate use of them: Sometimes I have a class which, in addition to its core functionality, needs to implement a commonly ...
3
votes
2answers
128 views

Composing and Inheriting from the Same Type

To start off with an example: I have a read-only Repository used for getting arbitrary values. This behavior can be implemented multiple ways. I also want to allow opt-in mutation of the repository's ...
0
votes
3answers
70 views

Logically grouped interfaces have circular dependencies in call graph, tight coupling. Leave as is, break up CRUD interfaces, something else?

The problem I have relates to an existing system in a specific business domain. I've simplified it into a very similar 'Library/Book' relationship to articulate the problem. Answers such as 'why would ...
3
votes
1answer
187 views

Method call order dependency

I have two camera devices that are able to find a specific hardware illuminated point in an image, as well as measuring the physical distance to the surface (and some more stuff I chose to leave out, ...
18
votes
8answers
5k views

Is it ok to inherit a class without adding anything to the child, to respect the Open Closed principle?

To clarify the question, here is my context (or something very similar). I have an interface, that I call IDataSource. The implementing classes contain information to retrieve data. So I have multiple ...
-4
votes
2answers
97 views

IO stream interface in C

When writing a library (eg. for dealing with JPEG or PNG files), the first thing library author needs to provide is an abstraction over FILE* (to allow also reading from plain memory, pipe, socket, ...
3
votes
1answer
138 views

What do you call the interface design error that consists in splitting two public methods that should be called toghether?

Consider a poorly-designed interface in which there are two functions (say foo() and bar()) that can be called independently, but in order to get some expected behavior (or in order to keep the object ...
0
votes
4answers
357 views

Why have separate keywords for 'extends' and 'implements' in Java? [closed]

Short answer that I've come to accept: Firstly, it helps with readability, being able to see which is the superclass apart from interfaces. Secondly, though 'extends' and 'implements' do the same ...
8
votes
4answers
3k views

OOP Design considering no modifications to existing design

The question is: interface Animal { void eat(); } class Lion implements Animal{ public void eat(){ //do somethng } } class Test { public static void main(String[] args) { ...
0
votes
0answers
17 views

Including widgets of a specialized program inside another program

Let's say my goal was to write a graphical application (based on a game engine, or even raw OpenGL), which should be able to render arbitrary 3D graphics. Now let's say I want to annotate the ...
7
votes
3answers
681 views

SOLID, Does Liskov Substitution Principle (LSP) conflict with the Interface Segregation Principle (ISP)?

I am confused by the two principles of SOLID, liskovs substitution principle and interface segregation principle. It seem as though they conflict each other's definitions. How can a class that ...
0
votes
1answer
59 views

Architecture Layers - Interface project at the top

We have structured our application with typical layers. UI, Database access, services, Helpers etc. However, at the very top we have a project called "Interfaces" which contains the ...
1
vote
4answers
551 views

Why is an interface in Java called an “interface”?

I am not sure why an interface in Java is called an "interface", but I think it can be one of the following two reasons (or both): Reason one: This tutorial says the following: Methods form ...
1
vote
2answers
190 views

Is there a statically typed programming language that implements Polymorphism without using a superclass or an interface?

Is there a statically typed programming language that implements Polymorphism without using a superclass or an interface (if such implementation is even possible)?
-5
votes
1answer
130 views

What is the point of interfaces and abstract classes? [closed]

So I'm taking a course on java programming, and in the lesson about interfaces, they gave an example of an interface with a Bird class, along with Chicken and Sparrow subclasses that extend Bird. They ...
0
votes
2answers
116 views

Encoding const-ness on interfaces. Readers - Writers vs Const wrapper

This question is based on this separate question on stack overflow. I have a very low-level structure meant to compactly save presets on flash memory. For simplicity I am going to use stored_record as ...
0
votes
1answer
114 views

What is a not well-defined interface?

I keep reading about "well defined interfaces", as here, here or here, specially when talking about microservices. What's an example of the opposite, an interface that is not well-defined?
-3
votes
1answer
115 views

What's the argument against complex type hinting in interfaces in PHP?

The more I write OOP, the more I realize that besides reasoning & structure, there isn't much for me and things make more sense if I combine that with functional or just straight-up non-OOP. Not ...
-4
votes
1answer
60 views

Should I use interfaces in Python (so my code will be more testable and following good practices)?

I've never coded in Python. In languages like C# or Java a lot of people write interfaces for (almost) every class so the code can be more easily testable (by implementing IoC) or other reasons and is ...
4
votes
3answers
164 views

Should you use popular(e.g. OpenCV,boost, Eigen, Tensorflow) types on your interfaces?

Suppose you are writing a software where there is a popular existing library that does not have all the algorithms/features you want but provides some "vocabulary" (equivalents of std::vector/std::...
3
votes
3answers
253 views

Java interface design: where should I put a lot of duplicate code that will be used by all subclasses?

Java interface design: where should I put a lot of duplicate code that will be used by all subclasses? interface Tuple { void method1(); } class Tuple1 implements Tuple { @Override public ...
-2
votes
3answers
74 views

Behaviour that depends on two sides

I would like to have the following interface: Resource { public: void copyInto(Resource* src) = 0; } But in order to implement this, the implementation would need to know (or make assumptions about) ...
1
vote
3answers
144 views

What does Combinatoric Interface mean?

I am watching this talk by Sean Parent. He notes that: Choosing the same syntax for the same semantics enables code reuse and avoids combinatoric interfaces What does "combinatoric interface" mean?...
1
vote
1answer
55 views

Where to handle duplicate key exceptions in multy layer application

+-------------+ +--------+ +----------+ | repository +-------->+service +------->+controller| +-------------+ +-^------+ +------------+ +-------------+ | ...
1
vote
2answers
121 views

What goes on behind the scenes when data is passed through the use of interfaces?

I understand an interface is a contract and if a class implements that interface, it must define those abstract methods from the interface. What I don't understand is, how is data passed between two ...
2
votes
1answer
104 views

Is it allowed to include the composition in the compositor in the Strategy Pattern

I have a range of different animals in my zoo such as turtles, birds etc. As they all share a common trait such as either swimming, flying etc., I thought a strategy pattern would be appropriate to ...
5
votes
0answers
138 views

Fortran-Python Interface

Disclaimers: This question is reposted from SO upon SO user's suggestion to put it here since there is no specific code in question. This question is a subset of my larger theme of Fortran ...
3
votes
3answers
169 views

Issues with an interface treating a synchronous action as async

Let's say I'm trying to write a library that abstracts certain actions. In this example I want to turn a light on or off. There could be hundreds of different kinds of lights that are controlled in ...
1
vote
2answers
106 views

Is it a best practice or anti-pattern to export mock versions of functions for a library?

Context We are creating a library that makes an API (HTTP) request to a 3rd party. During testing we have written mock versions of the functions that make external requests so that we can test the ...
3
votes
1answer
426 views

Golang Interface Design for Multiple Parameter and Return Types

General question how can I design an interface that can support both // v1beta1.Deployment type Deployment struct { metav1.TypeMeta metav1.ObjectMeta Spec v1beta1.DeploymentSpec ...
0
votes
6answers
132 views

Adding client specific method to a listener interface is a good idea?

I'm using a listener pattern where a class A listens for events from various classes B, C, D with the help of a listener interface I Essentially the structure looks like: interface I { void ...
0
votes
1answer
125 views

Name of this enum-based design pattern to get the type

I have been using a pattern in a lot of places (mainly C#) that I would like to know the name of. Here is an example of it in C#: public enum ThingType { A, B, C } public interface ...
1
vote
0answers
33 views

subinterfaces redeclaring abstract methods

Why is it that some abstract methods in interface hierarchies are redeclared as abstract further down? iterator() for example, abstract in Collection is redeclared in Set and List, and again further ...
1
vote
0answers
125 views

How to design the interface method for the following case?

I am making an SNMP agent. In order to pass information to this SNMP agent, I need to periodically extract data from two different sources (and there may be more sources in future.) I am trying to ...
1
vote
1answer
76 views

Can this simple Bank example be considered as a valid Abstract Factory?

For teaching purposes, I'm trying to replicate in a more faithful way from this conceptual UML (from wikipedia): In a "so-so" real world example, in my case, families of Loans and Insurances: So, ...
4
votes
4answers
453 views

Do we really need interface classes for the dependency inversion principle?

As a practical example, imagine a Gripper class which represents a robotic gripper in a simulation. Gripper has a TryGrip method, which checks if there's a GrippableItem in the correct position (...

1
2 3 4 5
14