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

learn more… | top users | synonyms (1)

7
votes
2answers
138 views

Optional features: default method or separated interface

Dedicated interfaces seems to be a good way to expose the optional features in a domain-specific type hierarchy. However, they impede the use of decorator and composite patterns, which is also common ...
4
votes
4answers
234 views

Should an application configuration interface be broken into multiple interfaces to reduce feature creep?

My windows service is neatly separated into 5 components - each with their own interface and pulled together by a bootstrapper. One of my requirements is to provide configuration options in my ...
0
votes
1answer
76 views

JEE MVC, controller calls the interface instead of the interface implementation

I'm following this tutorial: http://wiki4.caucho.com/Building_a_simple_listing_in_JSP It creates a basic web application in Eclipse using the MVC pattern with Resin as the web container. Here's the ...
0
votes
1answer
74 views

Should I separate the interface or use single one [closed]

I'm developing a game, I will generate objects. I have create an interface called IObject which has the following properties: String tag // Tag for the object Vector3 position // Where the element is ...
0
votes
2answers
64 views

Implementing a component that provides interfaces in a component-based framework [closed]

I'm currently trying to develop a small white box component-based Android framework, but I have a doubt about which is the best way to implement my components and interfaces. An architecture of one of ...
105
votes
19answers
63k views

Why are interfaces useful?

I have been studying and coding in C# for some time now. But still, I can't figure the usefulness of Interfaces. They bring too little to the table. Other than providing the signatures of function, ...
1
vote
4answers
338 views

How can I avoid the use of strings?

I'm implementing a program where the user can 'create a musical scale' from a variety of notes (identified by their names), and the program will generate music from this scale. I want to implement a ...
3
votes
2answers
161 views

Design interface for WebService to access several MySQL databases

I am currently trying to design an interface for a WebService that can access several MySQL databases. There will be 4 operations available, Add(), Read(), Update() and Delete(). The WebService just ...
9
votes
5answers
341 views

Separate interface for mutation methods

I've been working on refactoring some code, and I think I may have taken the first step down the rabbit hole. I'm writing the example in Java, but I suppose it could be agnostic. I have an interface ...
2
votes
2answers
111 views

Correct approach for creating api contract

I am trying to design an API. For creating contracts below are the two approaches: Approach 1: public class MyController { public void MyAction1(Dictionary<string, dynamic> input) { ...
-3
votes
0answers
13 views

Sand 3D Printer Slicing Issue [migrated]

For my doctoral thesis I am building a 3D printer based loosely off of one from the University of Twente: http://pwdr.github.io/ So far, everything has gone relatively smoothly. The hardware part ...
22
votes
4answers
16k views

Why were default and static methods added to interfaces in Java 8 when we already had abstract classes?

In Java 8, interfaces can contain implemented methods, static methods, and the so-called "default" methods (which the implementing classes do not need to override). In my (probably naive) view, there ...
94
votes
15answers
27k views

Do I need to use an interface when only one class will ever implement it?

Isn't the whole point of an interface to for multiple classes to adhere to a set of rules and implementations?
3
votes
4answers
201 views

Design: Lisp (or other scripting language) as an interactive interface for C++?

I'm working on a medium size C++ project (will probably end up around 50k lines) and I have to provide an interactive terminal interface. The program produces scientific data as an output and the ...
1
vote
2answers
122 views

Could changing the return type from void to string introduce breaking changes?

This SDK have an interface like this: public interface Contract { void update(..); void action(..); void delete(..); } Now, we need to change it to something like this: public ...
3
votes
4answers
139 views

Design strategy for wrapping exceptions

I'm implementing a type of Repository for a framework/library that has (roughly) the following: public interface FooRepository { boolean contains(String id); Foo fetch(String id); void ...
1
vote
1answer
134 views

Inefficient use of interfaces in OOP (C#)

In my code, I've got two interfaces, let's say IOpenable and IExaminable. IOpenable allows the user to Open or Close the object, and IExaminable allows the user to Examine the object. Now, we have ...
2
votes
1answer
83 views

Define an object with the interface as a type instead of class name [duplicate]

I try to practice with the design patterns and explore one of the possible implementations of the Observer Design Pattern in Java. I paid attention, that in this example the object is defined with the ...
11
votes
3answers
1k views

Is an interface considered 'empty' if it inherits from other interfaces?

Empty interfaces are generally consider bad practice, as far as I can tell - especially where things like attributes are supported by the language. However, is an interface considered 'empty' if it ...
1
vote
2answers
34 views

Declaring 'chained' interface inheritance

I assume this is largely language-agnostic, but I'm working in C# if it's not Let's say interface I3 inherits from I2, which in turn inherits from I1. I could write this: interface I1 { ... } ...
20
votes
4answers
14k views

Model-View-Presenter implementation thoughts

I'm trying to get a good grasp of how to implement good decoupling between a UI and the model, but I'm having trouble figuring out exactly where to divide the lines. I've been looking at ...
0
votes
1answer
63 views

What should this interface contain?

I am creating a schema for Doctrine but first I'm creating interfaces, abstract classes (models) which will be extended by the entities. I have a PresentationInterface which contain getter and ...
3
votes
1answer
110 views

Interfaces, abstraction, coding to an interface

Original question here I am learning OOP and SOLID. I have a 'main' class that performs some actions after reading variables from a config file. This 'main' class is not the focus of this question ...
1
vote
2answers
152 views

Convert this abstract class to an interface

I have a security method I would like to be able to sprinkle into other classes throughout my program. It is currently an abstract class but I feel it would be more appropriate as an interface. Can ...
12
votes
2answers
168 views

UnsupportedOperationException in java collections framework interfaces

Looking through the Java Collections Framework, I've noticed quite a few of the interfaces have the comment (optional operation). These methods allow implementing classes to through an ...
-1
votes
3answers
282 views

Why List<E> interface is additionally introduced in collection hierarchy? [duplicate]

Below is the diagram, where, if we just consider the implementations of List, AbstractList maintains the core behavior of list. To introduce the new implementation class MyList(say) one can ...
3
votes
1answer
13k views

Difference between spring setter and interface injection?

I know how constructor and setter injection works in spring. Normally I use interfaces instead of classes to inject beans using setter and I consider it as interface injection, but in case of ...
-3
votes
2answers
148 views

Advantages of these recommendations in ooprogramming using Java

Below are the recommendation from section 5.1 of this essay. While Java is not a pure object-oriented language, it is possible to program in a pure object-oriented style by obeying the following ...
3
votes
1answer
129 views

Creating an interface just to decouple from third party libraries

I'm currently developing the Authorization module on a framework of mine. I have the following class so far: public interface IAuthorizationManager<C> where C : ...
0
votes
1answer
73 views

What would this interface be called? [closed]

At work we have a java backend that talks to python on some mobile devices. The mobile devices have no GUI, it's just pure string manipulation. All contact is initiated by the python; the java is just ...
2
votes
1answer
76 views

How valuable is decoupling in proprietary software?

When developing with Symfony2 PHP framework I often see reccomendations to decouple code but most of the time that is accompanied by a 'if you want to release as a third party bundle'. Which begs the ...
1
vote
1answer
315 views

Static methods vs Interface implementation

Here is my problem: I stared to create an e-commerce web site info collector. So I created a parser for each site. The parser class is stateless. I have got methods like: getItemPrice(WebElement ...
1
vote
3answers
62 views

Programming to an Interface and Interface Segregation in the Context of a User Class [duplicate]

I try to program to an interface whenever possible, but its not clear to me how I could apply it to a model as broad as a user. Which can hold many disparate fields (name, age, phone number, ssn, ...
-2
votes
1answer
62 views

Programming to an Interface and Keep Testability in Unique Classes [duplicate]

I try to program to an interface whenever possible, but when I have a class that fulfills a very specific and unique purpose, one that can't be abstracted. Is it correct for me to say that I've ...
1
vote
1answer
45 views

Do my “dal” and “fileHandler” interfaces overlap?

I want my program to: read some input lines from CSV file write the output lines to plain string file read some input from the same file in (2) and compare it to some calculated data I want to ...
11
votes
1answer
406 views

Is it good practice to implement two Java 8 default methods in terms of each other?

I'm designing an interface with two related methods, similar to this: public interface ThingComputer { default Thing computeFirstThing() { return computeAllThings().get(0); } ...
2
votes
1answer
66 views

Repeating Interface inheritance declarations

Take the following example: public interface ISerialRVD { RouteValueDictionary ToRVD(); } public interface IViewModel : ISerialRVD // Here? { Int32 Page { get; set; } String Action { ...
7
votes
5answers
395 views

Should private functions be held to the same standards as public functions?

If I'm building private utility functions, should they be held to the same rigorous standards in terms of handling invalid data as public functions? Example:If I'm writing code to calculate the ...
1
vote
3answers
80 views

When is a event listener invoked during program execution?

I am using the Obervable-Observer Pattern. MyClass extends Observable{ invokeListeners(){ doSomething; setChanged(); notifyListeners();//This invokes onUpdate() in "implements ...
0
votes
1answer
50 views

Provide part of context to class using interface

Currently I have class Context which I inject in some places in my code, like: protected override object GenerateSomething (object input, Context ctx) Depending on Context, Generate method gives ...
0
votes
0answers
86 views

Addicted to Interfaces - Good or bad? [duplicate]

After 2 years of programming, I usually found myself using the following design pattern: public interface ISomeInterface { void SomeMethod(); void OtherMethod(); } public abstract class ...
0
votes
4answers
2k views

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

Amidst defining the hierarchy, firstly, one can think to embed the abstract method(behavior) in abstract class only because the derive concrete class possess that behavior as core behavior with it's ...
3
votes
4answers
1k 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: use code to keep clients from being able to tell that a class is not a java interface. If we ...
9
votes
6answers
489 views

Does it always make sense to “program to an interface” in Java?

I've seen the discussion at this question regarding how a class that implements from an interface would be instantiated. In my case, I'm writing a very small program in Java that uses an instance of ...
2
votes
2answers
242 views

Lesser of two evils regarding return types

I'm implementing a system in PHP where values are represented with objects that implement an Amount interface. I'm building two different implementations of this interface, one using a simple integer ...
16
votes
8answers
5k views

Interfaces on an abstract class

My coworker and I have different opinions on the relationship between base classes and interfaces. I'm of the belief that a class should not implement an interface unless that class can be used when ...
2
votes
1answer
96 views

Application plugin system - interfaces - adding new features

Imagine I have an application, which have plugin system. public class MyPlugin : Plugin { public override ExecuteImpl (Context ctx) { // do something... } ...
0
votes
0answers
72 views

Is using Interface implemented by single class a not recommended practice? [duplicate]

I have several classes in C#, not just POCO class but with methods and implementations. Each of those classes implement one Interface. e.g. IPerson implemented by Person class. Employee implements ...
27
votes
4answers
3k views

Why is .compareTo() in an interface while .equals() is in a class in Java?

I want to know why the .compareTo() is in the Comparable interface while a method like .equals is in the Object class. To me, it seems arbitrary why a method like .compareTo() is not in the Object ...
1
vote
0answers
174 views

Class Interfaces with Multiple Classes and Dependency Injection

NOTE ON QUESTION TITLE: I did not really even know how to phrase the title so if someone can edit and make it more articulate I would really appreciate it. QUESTION: Basically, what I'm trying to do ...