Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [interfaces]

Questions about interface related design considerations, such as programming to the interface.

1
vote
0answers
89 views

Should every class in my system have an interface? [duplicate]

Should every single class in my system have an interface? I understand that interfaces provide an abstraction from the implementation of a class and so changes to the implementation do not affect ...
1
vote
1answer
577 views

Is it correct to think of a Java Interface as a “contract” that a class must implement?

I just want to check that my current understanding of Java interfaces is correct. If an interface says it must include public void increase(int amount), then does that just mean the class that ...
4
votes
3answers
289 views

Is an interface with two collection properties, where the second filters the first collection, idiomatic for C#?

I had an interesting discussion with a coworker that revolved around how people interpret the use of properties and methods on an interface. For example, let's say we have a blog with posts in various ...
-7
votes
2answers
298 views

Why are interfaces in Java called that way?

I have been a developer for past 3 years and I have been seeing interface in most of the places as a contract for the developers to write their own implementation or a marker (eg. Serializable). But ...
1
vote
1answer
131 views

Refactoring List abstraction - C

Below is the working List abstraction design, List is a generic abstraction holding any type. Below is the code directory structure. Currently symbol table(ST) and file api fileIO is using List ...
3
votes
3answers
547 views

How to remove dependencies on internal classes in the interface

I have a software component that is a part of a bigger software product. The software component lives in its namespace Component. Also the component has an interface (some part of it is below) that ...
14
votes
5answers
693 views

How to apply the Interface Segregation principle in C?

I have a module, say 'M', which has a few clients, say 'C1', 'C2', 'C3'. I want to apportion the module M's namespace, i.e. the declarations of the APIs and data it exposes, into header file(s) in ...
8
votes
1answer
1k views

In a multi tier project where should interfaces be defined?

I have a multi tiered project made up of three sub projects, i.e. Data access project, Business Logic project and Presentation project, where should interfaces be defined? I'm guessing that there ...
7
votes
6answers
890 views

How do large engineering teams describe the interface/contract between a web service and client JavaScript code? [closed]

I'm looking for a formal way for a front-end and a back-end team to communicate on the shape of a JSON web API. For example, let's say you are on a client-side team writing the JavaScript & HTML ...
3
votes
1answer
385 views

Contract interface/class with inner classes/interfaces

Brief description of my project structure. I have some base classes like BaseView, BasePresenter ... . Also my project consists of modules, module represents one complete part of the application. ...
4
votes
2answers
2k views

Library IO: Use Interface classes or Callbacks?

I'm building a smallish library (few kLOC) which processes stream data in C++. From the streamed data (comes in packets) the library compiles a database piece by piece and naturally has to convey that ...
5
votes
2answers
1k views

Interface extension method returning the interface type in C#

Programming against interfaces is an often-heard good practice in software development. Together with extension methods, this provides a great functionality. However, in C#, there are limitations to ...
90
votes
12answers
18k views

What is meant by the phrase “Software can replace hardware”?

Studying beginners course on hardware/software interface and operating systems, often come up the topic of if it would be better to replace some hardware parts with software and vice-versa. I can't ...
6
votes
5answers
253 views

Is there something wrong with having one interface to be implemented multiple times in inheritance chain?

interface IUser {} interface IConcreteUser : IUser {} abstract class UserBase : IUser {} class ConcreteUser : UserBase, IConcreteUser {} As you can see, ConcreteUser inherits IUser two times - one ...
3
votes
1answer
947 views

Is Design by Contract the same as using Interfaces to create a “contract”?

Does an OOP design that uses a Design by Contract mean the designer is using interfaces to create a "contract." The term "contract" is used quite often when discussing OOP interfaces, so I didn't ...
4
votes
1answer
105 views

Message publishing interface when deferring until transaction is committed

Suppose I have the following interface used for publishing messages onto a message queue: interface IMessageProducer { void Publish<TMessage>(TMessage message); } Normally, an implementer ...
3
votes
1answer
312 views

When adding a property to an interface in C#, is that consider major, minor, or patch using semantic versioning?

My team and I are trying to follow semantic versioning 2.0.0 to keep tabs on our library versions. We primarily use C# for our development and are currently in a situation where we are going to add a ...
166
votes
9answers
27k views

I changed one method signature and now have over 25,000 errors. What now?

I started a new job recently where I am working on a very large application (15M loc). In my previous job we had a similarly large application but (for better or for worse) we used OSGi, which meant ...
2
votes
0answers
58 views

Entity Framework - Old school save/update advice?

I've a query for you relating to best use of EF6 when using Winforms yet not having justification for changing things to something more modern. I've got half a dozen classes that are based on ...
6
votes
4answers
277 views

Evolving an interface that is not supposed to be implemented by the client

I'm about to write a Java library. Basically, this library provides something like this to its user: interface Foo { void doA(); boolean aWorked(); void doB(int value); } The user is not ...
9
votes
3answers
1k views

Is it OK for interfaces to depend on concrete classes?

I am creating interface in Java for custom error handler. Want to pass an argument error object but I need it to be child of Exception class. Is it okay to use my defined class name in an interface ?...
5
votes
2answers
2k views

Is it ok to have an empty abstract class to make concrete classes polymorphic

BEFORE: I have an interface that has one method definition public interface IDockable { void Dock(DockerContainerConfig config); } Everything is ok for my first implementation public class ...
2
votes
3answers
1k views

What does the following definition of an interface mean?

I am reading Real-Time UML Workshop for Embedded Systems and I do not understand what they are saying here. I have bolded the parts of the text that I do not fully understand. I am trying to ...
3
votes
1answer
211 views

Is Pairing a bloated interface with an Enum a good idea?

At work we have an interface that is getting bloated. The interface is designed to be easily implemented by an immutable object. So it looks something like this: //there is no behavior here, just ...
1
vote
0answers
103 views

Sending events down a tunnel, and bubbling them back up

I am working on developing an HTML canvas application, where I need to be able to do my own UI event processing. That's where the stem of this question comes from, but I'd really like to understand ...
2
votes
2answers
175 views

General approach to an interface that will resolve a dependency to a database library

Background I often write software for systems that are responsible for testing manufactured products. For every product that gets tested, we have to generate a report for the test-results. The way ...
13
votes
3answers
3k views

Is this bad OOP design for a simulation involving interfaces?

I am designing my own little OOP program to simulate Vampires, Wolves, Humans and Trucks and am trying to implement my own limited understanding of Interfaces. (I am still abstracting here and have ...
5
votes
2answers
199 views

How to bring others to understand your interface

I'm working in a corporation that has two products. One is a desktop application the other is a web-application. I'm in on the part as backend-engineer on the web-application. I design the web-...
1
vote
0answers
3k views

ASP.NET: Creating an interface for a controller

Would creating a controller's interface a bad idea? I have a controller that derived from ApiController, so knowing that you can only derived one class to a class but able to derived one or more ...
3
votes
3answers
428 views

How to decide, should I put methods to abstract class or to interface?

I'm writing an app it needs to have generic registration step item. It needs to be able to do some specific things (I use interface for that) and it needs to be a visual element (of Xamarin. It doesn'...
4
votes
1answer
3k views

Interface with multiple default methods OR Interface + Class

In a code base I am "starting from" there are a handful of interfaces with many default methods. They look something like this: public interface HasXY { double getX(); double getY(); ...
3
votes
2answers
151 views

Function acting as a shortcut to object's methods

I was reading Python's requests library's code to find out how it works. Since this library has a simple usage interface, it creates a more complex object beyond. For instance: requests.get(...) Is ...
3
votes
3answers
190 views

Is it good practice to create interfaces that limit usage?

So I'm coding a way to send events to multiple clients, and then having the clients decide how they want to handle it. I'll exclude the bits that don't lend themselves to explaining the situation. ...
4
votes
1answer
374 views

How to properly extend an interface with immutable properties to offer mutability via another interface

The following code snippets are simplified to demonstrate the context! The actual interfaces and classes are POCOs having additional properties. The types are part of library I am working on, the ...
2
votes
0answers
118 views

Interface Methods vs Data Objects

Building a UI editor for Android and basically there are interfaces such as this: interface Item { fun decorate() fun translate(x: Int, y: Int) fun rotate(rotation: Float) fun scale(...
2
votes
2answers
98 views

Modifying an existing class: should I extend it to a new class?

I'm working with a library (from an online source, not authored in-house) providing an interface as well as an implementation of it: interface FooInterface { // ... } class Foo implements ...
1
vote
1answer
134 views

Force implementation of an interface to use a function, to enable functionality that's transparent to the user

I am the designer of an interface IModel, which will be used by the implementer of a the controller (MVC). The interface contains funcA(). Another programmer needs to implement a specific class for ...
1
vote
1answer
175 views

Having the implementer as a property in an interface - is it bad practice?

I have an interface IFoo that only gets implemented by objects with a fairly high level (framework) base class. It would be very useful to me to not only get the Interface members, but also the ...
3
votes
1answer
134 views

Leo Brodie's “Interface Component”

On page 85 of Leo Brodie's book, Thinking Forth, he describes a component which he calls the "Interface Component." He describes its differences from, and benefits over a standard interface as follows:...
14
votes
2answers
1k views

Now that not all method declarations in a Java Interface are public abstract, should the methods be declared with these modifiers?

Starting with Java 8, default methods were introduced into interfaces. Effectively, this means that not all methods in an interface are abstract. Starting with Java 9 (maybe), private methods will be ...
2
votes
1answer
247 views

Is this a good way to keep track of subscription cycles and figure out if we need to charge the subscriber?

I'm working in PHP and building a subscription management system from scratch. I'm trying to figure out the required functions for the Subscription interface (OOP) that need to be implemented by ...
2
votes
1answer
612 views

What are mIa, mId and dIa interfaces?

This document on European Telecommunications Standards Institute website describes some Machine2Machine (M2M) communications protocols. I've seen mIa, mId and dIa interfaces in some research papers, ...
7
votes
2answers
257 views

Java redeclare inherited interfaces?

While working on a small class called FractionNumber I found asking myself if I should implement an interface that I am already implementing. Sounds stupid, I know, but bear with me. My class ...
3
votes
2answers
128 views

Defining reusable components while having a specific application in mind

Over the past several months I have learned a lot in software design and practices across several languages and frameworks. To me, the most attractive and useful designs patterns are those that follow ...
2
votes
3answers
784 views

Preemptive interfaces in Java - good, bad or “a matter of taste”

I frequently come across projects that strictly define an interface for each and every class. 90% of those interfaces feature only a single implementation. Proponents of these "preemptive interfacs" ...
0
votes
0answers
162 views

What is the meaning of the different interface types in Ian Sommervilles's Software Engineering?

Reading Ian Sommervilles's Software engineering, he mentiones there are following interfaces: Paramater interface: data or functions are passed from one component to another Shared memory interface: ...
0
votes
0answers
393 views

Using java interfaces to narrow the classes public interface

There is a lot of content on the web discussing if it is worth defining an interface if only one class implements it. The answers are mostly either "Yes, because you probably need to mock it anyways" ...
1
vote
3answers
483 views

Is interface containing every method of given class a good thing?

I'm trying to write a simple game and I really want to finally create something that would be "programmatically correct". I stuck with a problem like this: I have class public abstract class ...
1
vote
1answer
668 views

Inheritance is better or composition design pattern in this scenario?

Design and implement Cash Register: Given a number of items you will be required to calculate the total bill. Items are charged for in a couple of different ways: A given price for each item, e.g. ...
1
vote
1answer
362 views

Should we “prefer composition over multiple interface”?

Should we avoid multiple interface if possible? Because I think at most cases a class with multiple interfaces can be replaced with another version with composition and single interface only e.g.: ...