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
2 votes
1 answer
816 views

Major or Minor Revision Change when Implementing an Interface

I am using semantic versioning 2.0.0. In my situation I have a concrete implementation of some interface A in one library. And I have the interface that's being implemented (call it B) in another ...
Snoop's user avatar
  • 2,748
3 votes
1 answer
2k views

Is it bad practice to perform an "optional" interface inheritance?

Say... you're trying to write a networkCallback code in java: public interface NetworkCallback { void onNetworkResult1(Object object); void onNetworkFailure(Object object); } you want to use ...
lawonga's user avatar
  • 139
-3 votes
1 answer
2k views

How to decouple a dependency

I am trying to decouple a dependency from Book Class to BookStorage, but got confused how to do this right. Can someone tell me how to decouple this correctly? Here is my code: public interface ...
GeekOnGadgets's user avatar
1 vote
1 answer
763 views

How to figure out what interface to cast to?

This question may be a bit subjective, but I have tried three different solutions and none of them has felt right. I will provide some context and the solutions I have tried. The issue I am facing ...
user1323245's user avatar
2 votes
1 answer
1k views

If polymorphism is the ability of different types to share the same interface, is there a name for a single type that fulfills different interfaces?

Consider this example of polymorphism. I have two different API, IWrite and IRead, and then a single implementation of these. interface IRead { Entity Find(int id); } interface IWrite { void ...
Adrian Iftode's user avatar
1 vote
0 answers
103 views

Receiving events through an interface

So I'm writing a game and using the Google Play Services framework to send and receive data. I have to implement the IRealTimeEventListener interface and override the functions below to receive ...
David's user avatar
  • 129
1 vote
0 answers
106 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 ...
David's user avatar
  • 129
1 vote
1 answer
1k 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 ...
Kye's user avatar
  • 21
4 votes
3 answers
379 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 ...
Greg Burghardt's user avatar
-6 votes
2 answers
454 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 ...
Raja Anbazhagan's user avatar
1 vote
1 answer
153 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 ...
overexchange's user avatar
  • 2,265
3 votes
3 answers
1k 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 ...
Konstantin's user avatar
15 votes
5 answers
1k 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 ...
work.bin's user avatar
  • 159
9 votes
1 answer
2k 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 ...
John S's user avatar
  • 201
9 votes
6 answers
4k 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 ...
user62575's user avatar
  • 285
3 votes
1 answer
534 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. ...
CROSP's user avatar
  • 1,558
5 votes
2 answers
4k 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 ...
Jan Krüger's user avatar
5 votes
2 answers
3k 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 ...
Timitry's user avatar
  • 161
96 votes
12 answers
20k 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 ...
Gabriele Scarlatti's user avatar
6 votes
5 answers
1k 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 ...
Pavel T.'s user avatar
4 votes
1 answer
2k 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 ...
johnny's user avatar
  • 3,679
4 votes
1 answer
122 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 ...
TheCloudlessSky's user avatar
3 votes
1 answer
871 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 ...
Snoop's user avatar
  • 2,748
169 votes
9 answers
29k 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 ...
user788497's user avatar
  • 1,321
3 votes
0 answers
72 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 ...
Richard's user avatar
  • 211
6 votes
4 answers
813 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 ...
Daniel Jour's user avatar
9 votes
3 answers
2k 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 ?...
8bra1nz's user avatar
  • 259
6 votes
2 answers
3k 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 ...
jmc's user avatar
  • 197
2 votes
3 answers
2k 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 ...
efox29's user avatar
  • 159
3 votes
1 answer
249 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 ...
Ivan's user avatar
  • 575
1 vote
0 answers
131 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 ...
David's user avatar
  • 119
2 votes
2 answers
271 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 ...
Snoop's user avatar
  • 2,748
13 votes
3 answers
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 ...
user3396486's user avatar
5 votes
2 answers
213 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-...
SWiggels's user avatar
  • 169
2 votes
0 answers
8k 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 ...
rpmansion's user avatar
  • 247
2 votes
3 answers
990 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'...
nix's user avatar
  • 533
5 votes
1 answer
6k 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(); ...
Ivan's user avatar
  • 575
3 votes
2 answers
169 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 ...
Jonathan Prates's user avatar
3 votes
3 answers
206 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. ...
user2738698's user avatar
5 votes
1 answer
2k 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 ...
ckerth's user avatar
  • 51
3 votes
0 answers
132 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(...
razzledazzle's user avatar
2 votes
2 answers
661 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 ...
user avatar
1 vote
1 answer
819 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 ...
Ofek Israel's user avatar
1 vote
1 answer
413 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 ...
Lennart's user avatar
  • 263
3 votes
1 answer
178 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 ...
dmux's user avatar
  • 151
15 votes
2 answers
3k 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 ...
David Campbell's user avatar
2 votes
1 answer
553 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 ...
Joseph Shih's user avatar
2 votes
1 answer
1k 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, ...
user avatar
7 votes
2 answers
392 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 ...
kalsowerus's user avatar
3 votes
2 answers
240 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 ...
Dan's user avatar
  • 33

1
5 6
7
8 9
15