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

learn more… | top users | synonyms (1)

0
votes
0answers
7 views

Passing data from matlab to c interface

As the title indicates. I have a wrapper function in matlab function [status name] = GetCanCaseName(canNum) [status name] = calllib('Test','GetCanCaseName',canNum, 'temp',0); And the corresponding ...
0
votes
1answer
18 views

How do I use type assertions in Go when returning an interface type?

A struct I'm working on called fieldDefinition holds metadata about a field used by an object in my web app. One of the fields on fieldDefinition (it does get a bit confusing) looks something like ...
4
votes
4answers
235 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
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 ...
-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 ...
3
votes
4answers
203 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 ...
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 ...
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 { ... } ...
3
votes
1answer
111 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
170 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 ...
-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 ...
-1
votes
3answers
283 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
134 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 ...
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 ...
-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
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, ...
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 ...
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 { ...
9
votes
5answers
342 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 ...
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 ...
11
votes
1answer
408 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
2answers
112 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) { ...
1
vote
3answers
81 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
51 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 ...
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 ...
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 ...
9
votes
6answers
491 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 ...
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 ...
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 ...
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... } ...
1
vote
0answers
176 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 ...
4
votes
2answers
121 views

Is it considered good practice to declare base interfaces without mutators, supplying mutatators in a sub-interface

I asked a question on StackOverflow on how to properly implement an ImmutableMap that abides by the SOLID principles. Due to Java's Map interface containing put and putAll, it violates the interface ...
2
votes
3answers
143 views

Many different classes that need similar functionality. Best approach?

I have many (at the moment around 30) different message classes in an application I am creating. Each of these messages need to be serialized and deserialized. However, the process of serializing and ...
3
votes
0answers
95 views

License that encourages improvements to the original version rather than own forks? [closed]

I'm looking for a license that should encourage changes to my original open source rather than encouraging forks and uncontrolled random redistribution. This is because of the nature of the code; it's ...
3
votes
3answers
321 views

“One of some”-type

Say that you have some different classes that does not really have any functionality in common, but somewhere in your program, you need one of them (which one is not necessarily important) because ...
1
vote
4answers
297 views

When to make a method part of an interface or a concrete implementation? [duplicate]

I create an interface for database access to a MySQL database. Currently, this is the only way to access day, but to make it easier to test and in the event that the data access might change, I used ...
0
votes
1answer
110 views

Can you refer to the callback function as an API?

A system design is decoupled into two layers say layer A and layer B. The interaction between layer A and layer B occurs through an interface that is exposed by layer B in form of an API. This ...
5
votes
1answer
204 views

Sometimes, “programming to interfaces” introduces possible (and avoidable) runtime exceptions?

Please consider the com.google.common.collect.ImmutableMap Programming to its interface, Map , creates a bug that could blow-up in the runtime as such: Map<String, Integer> myMap = ...
16
votes
5answers
3k views

Do enums create brittle interfaces?

Consider the example below. Any change to the ColorChoice enum affects all IWindowColor subclasses. Do enums tend to cause brittle interfaces? Is there something better than an enum to allow for ...
2
votes
2answers
83 views

How do you maintain protocol of function return value in dynamic language?

In dynamic programming language like Python, Javascript, it's very easy to make a function return an object: def make_vector2(a, b): return {"x": a, "y": b} The 'signature' of the returned ...