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

learn more… | top users | synonyms (1)

13
votes
4answers
1k views

Should a front-end developer ever specify JSON format for back-end developers?

I am taking the front-end role in a project. Should I be specifying for my back-end teammates the exact format of JSON that their PHP returns to my JavaScript? For example, should I be telling them ...
1
vote
0answers
71 views

How does one enforce the implementation of a static method? [duplicate]

Of course the answer to the question above is, "you can't". But I didn't have a better way of describing what I'm looking for. If I did, I wouldn't be asking this question. My problem stems from a C# ...
0
votes
0answers
29 views

Adding new Interface & Replacing Method with Interface Type

Let's say that I have 2 classes: Foo and Bar. `Foo` { List<Bar> bars String bippy() int boop() } `Bar` { int biz() String baz() } Observe that Foo's fields include a List<Bar>. ...
4
votes
3answers
230 views

Why use arg type `class Object` instead of `Comparable[]`?

In the code below, I believe it would look more appropriate to make the method argument be of type Comparable[] instead of Object[]. The first reason it would be more appropriate is that one can be ...
0
votes
2answers
141 views

Develop GUI and logic in a team the right way? [closed]

I am planning to start a small project with a friend. I will be developing the GUI using JavaFX in the MVC pattern and he will be responsible for the model/logic. My question is: how can we achieve a ...
0
votes
1answer
48 views

Interfaces between multiple projects

I'm slightly confused over the following: ProjectA -------- GetUsers (Implements IDBConnector) -------- IGetUsers -------- UserModel ProjectB -------- Main I have two projects one main project ...
1
vote
1answer
53 views

Do the implementations of the Node interface in Web API violate Liskov Substitution Principle?

MDN article on Node interface states that interfaces [that inherit from Node interface] may return null in particular cases where the methods and properties are not relevant. They may throw an ...
0
votes
1answer
83 views

Async properties in interfaces to cater for the possibility of expensive first-time evaluation: Is this a good idea?

First of all, sorry if this post is too long. I'll start with the… Short version: Is it generally advisable or a good idea to design an interface property as asynchronous simply because we cannot be ...
0
votes
4answers
636 views

Why 'List<E>' is an 'interface' but not 'abstract class'?

While defining the hierarchy, one can think to embed the abstract method(behaviour) in abstract class only because the derive concrete class posses that as core behaviour with it's specific ...
1
vote
2answers
303 views

Programming against interfaces in Java

Supposing I have an interface Foo and a given implementation FooImpl. public class FooImpl implements Foo If I want to define a new operation on this class that depends on the particular ...
0
votes
1answer
92 views

Cleanest choice for symmetric operations

I have a need to do some processing from a format A to a format B and from B to A. The job in one direction is very similar to its counterpart. Both formats are represented with an interface Msg. In ...
0
votes
0answers
27 views

Restructuring similar interfaces to one unified design

In my project, I have several types of Web API controllers (and their corresponding services and repositories). When I started out, I made an interface of a generic type that would describe the basic ...
11
votes
4answers
2k views

Is it permissible to use explicit interface implementation to hide members in C#?

I understand how to work with interfaces and explicit interface implementation in C#, but I was wondering if it's considered bad form to hide away certain members that would not be used frequently. ...
2
votes
4answers
214 views

Determining a class structure

I'm currently in the early stages of designing an e-commerce application. I'm working out some designs for my classes which have so far been fairly straightforward, but I've run into something of a ...
1
vote
3answers
227 views

Implements > extends, but what about variables?

It's preferable to write programs that depend on interfaces rather than on superclasses, but what when you want a class to have certain variables? Sometimes you want a class to implement a certain ...
0
votes
1answer
84 views

when would you wrap a service object with an interface? [duplicate]

I'm new to UT and some of the best practices and anti-patterns when writing testable code, made me think. I used to wrap any service object with interface. but I see many mocking frameworks can ...
14
votes
2answers
2k views

Illegal in PHP: Is there an OOP design reason?

The below interface inheritance is illegal in PHP, but I think it would be fairly useful in real life. Is there an actual antipattern or documented problem with the below design, that PHP is ...
2
votes
1answer
126 views

Trying to get a better understanding of Interfaces

Im working on a small program and I thought i would use it as a chance to get a better understanding of things I haven't really used before, mainly Interfaces and Inheritance from base classes. ...
4
votes
1answer
101 views

Handling interface segregation in C++

I'm designing a "view" handling system for a game. The goal is to be able to have different "views" that can be shown in sequence or stacked on-top of each other. For example, the initial splash ...
3
votes
4answers
603 views

How to force “program to an interface” without using a java Interface in java 1.6

In java 1.8 they have wonderful new "default interface methods". In 1.6 how close can we come? The goal: keep clients (using code) from being able to tell that a class is not a java interface. If ...
0
votes
1answer
119 views

Static methods vs Interface implementation

Here is my problem: I stared to create a e-commerce web sites info collector. So i created a parser for each site. The parser class is state less. got methods like: getItemPrice(WebElement page) ...
3
votes
3answers
200 views

Should I denote that a method satisfies an interface?

When writing a class which has ("satisfies") 1 or more interfaces, should I note somehow (e.g. in an XML comment, or with an attribute) that a particular method was added for one of the interfaces? ...
0
votes
1answer
109 views

Android, using a Fragment to hold/edit complex object, accesible from any Activity

I'll do my best to describe the problem, but I'm still very new to several concepts that I think this problem requires to be solved (namely interfaces and threads). I should preface this by saying ...
0
votes
2answers
135 views

How to organise and label methods, intended for debug?

I have a class System, which uses a bunch of other classes, to achieve a complex signal processing. In debugging System, one needs to observe the output signal for patterns. This is not achievable by ...
5
votes
3answers
219 views

Does it make sense to split up an existing multi-method interface into several single method interfaces just to take advantage of lambdas?

Say I have an existing callback interface that has multiple methods. To illustrate my point I use a callback the likes that you would see in code that performs some HTTP client operations: public ...
0
votes
0answers
115 views

How far to go when future proofing fluent-method-chained-DSL test code?

Is it worth implementing interfaces, or using the getThis() trick, or even static factory methods to future proof against the need to extend this DSL? The current design is a pair of thin ...
0
votes
2answers
79 views

Possible design patterns for base function with possible additions

I have various interfaces i have to implement. Let's assume ITypeA, ITypeB. They have following methods: ITypeA Connect Disconnect GetData SetData ClearData ITypeB Connect Disconnect ...
3
votes
2answers
185 views

Are there alternatives to using an optional type in a multithreaded environment?

I'm making an MPMC queue in C++, and I would like to find out what the best interface for a try_dequeue method would be (I'm not concerned about its implementation). I'd like to provide a method which ...
0
votes
0answers
56 views

Pitfalls of combining dependant traits and exceptions in same file as interface in php

What are the potential pitfalls of combining related class like objects (interfaces, traits, custom exceptions) in the same source file? For code reuse and only loading what I need I always separate ...
23
votes
8answers
2k views

Interface design where functions need to be called in a specific sequence

The task is to configure a piece of hardware within the device, according to some input specification. This should be achieved as follows: 1) Collect the configuration information. This can happen at ...
0
votes
1answer
82 views

Prepared statement alternatives for this middle-man program?

I have an program that is using a prepared statement to connect and write to a database working nicely, and now need to create a middle-man program to insert between this program and the database. ...
0
votes
1answer
132 views

How to generalize a classes that has identical function plus some additional function

I have some designing problems with my project. To illustrate my problem, I'll use the following two classes from my project. public class RAM_UserManagement{ private Map<int,User> userList; ...
3
votes
1answer
102 views

Traits, Inheritance and Interfaces in Groovy, when to use them?

I'm learning groovy and I've just learned about the new feature added in 2.3, which is the addition of Traits. Now to me it seems like Traits allow you to do basically everything a super-class and an ...
1
vote
3answers
244 views

Make Return Type an Interface - Problem with Initialization

I would like to make the return type of my method an interface rather than a class for similar reasons stated in c# List or IList, however I am having trouble figuring out how to initialize the ...
1
vote
4answers
207 views

Should I put extension methods of an interface in the interface.cs file?

Imagine this set up: public interface IMass{ double Mass {get;} } public static class IMassExtension { public static double ToKg(this IMass massObject) { return massObject.Mass / ...
2
votes
1answer
104 views

How modularized should my interfaces be?

I stumbled upon a specific instance where it seems that modularity and simplicity are at conflict with each other. Usually that's not the case, so I was really unsure how to resolve it. Suppose I ...
7
votes
4answers
478 views

“Immutable” interfaces

I am confused about the notion of immutability. Consider the following structure of a simplistic calculator: Here are the interfaces: interface IOperationalInterface { int Sum(int a, int b); } ...
1
vote
1answer
112 views

Domain-specific Interfaces

Are there any real benefits of using interfaces over abstract classes in a domain model? Does anyone have any experience using interfaces in a domain model in a real project? From a technical ...
5
votes
3answers
1k views

Why does C# allow properties in interfaces?

In C#, the following code is valid interface I{ int property{get;set;} } Which doesn't make any sense to me. This seems to break one of the most important principles of interfaces: lack of ...
1
vote
2answers
128 views

Should an abstract class always abstract its methods to an interface?

I had learned sometime ago that abstract classes should always abstract their functions to an interface. So instead of having something like this - abstract class a{ public int i; public int ...
4
votes
1answer
130 views

Designing module interfaces

I'm studying software engineering and one thing I'm really trying to improve is my skill in software architecture. My question is quite broad, so I'll try to explain it with an example. Suppose you ...
2
votes
2answers
256 views

Does it make sense to use interfaces if you don't have polymorphism?

Suppose I have distinct classes that have the same behavior, which can be represented like this: public interface Behavior { void operationA(); } public class ImplementerA implements Behavior { ...
1
vote
2answers
91 views

How specific should be an interface about its implementation details?

Perhaps I should have picked a better title, but anyway... Basically what to do with two or more implementations that have the same public interface, but they are meant for slightly different ...
3
votes
3answers
502 views

Why not apply Interface Segregation Principle to “extreme”

Providing that clients would typically consume just one method, though methods would be conceptually related, why not always apply the Interface Segregation Principle to the extreme and have [many] ...
40
votes
9answers
4k views

Programming for future use of interfaces

I have a colleague sitting next to me who designed an interface like this: public interface IEventGetter { public List<FooType> getFooList(String fooName, Date start, Date end) ...
4
votes
2answers
734 views

Code re-use in C++, via multiple inheritance or composition? Or…?

I originally asked this question on StackOverflow, but I was directed here, and I think my problem is perhaps as much conceptual as technical, so here goes. If you’re defining a hierarchy of abstract ...
0
votes
3answers
318 views

Why do APIs generally consist of interfaces? [duplicate]

I am starting out in Java API design and in reading existing code bases, I have found that most APIs consist of interfaces only with their implementations bundled in a different package. Having read ...
6
votes
4answers
500 views

Split up large interfaces

I'm using a large interface with about 50 methods to access a database. The interface has been written by a colleague of mine. We discussed this: Me: 50 methods is too much. It's a code smell. ...
2
votes
0answers
110 views

The inheritance argument of zope.interface (providedby vs isinstance)

What limitations does inheritance of an interface through an abstract base class present that are addressed by zope.interface? In the following talk given in 2010 by Jeff Rush about interfaces, at ...
1
vote
4answers
273 views

Combinatorial explosion of interfaces: How many is too many?

I'm a relative newcomer to OOP, and I'm having a bit of trouble creating good designs when it comes to interfaces. Consider a class A with N public methods. There are a number of other classes, B, C, ...