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

learn more… | top users | synonyms (1)

0
votes
0answers
68 views

Is java interface also good for defining core behaviors?

This comment says that: Interfaces are also good for defining core behaviors! with one of the example taken as interface List<E>. My point of view: Taken from reference, item-18: Interfaces ...
3
votes
1answer
70 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
64 views

What would this interface be called?

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 ...
1
vote
1answer
70 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
49 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
58 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
54 views

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

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
28 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 ...
1
vote
1answer
53 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 { ...
4
votes
1answer
101 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 ...
0
votes
4answers
250 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 ...
10
votes
1answer
296 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); } ...
1
vote
3answers
70 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
41 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
79 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
235 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
69 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
434 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 ...
26
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 ...
2
votes
2answers
97 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
78 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
126 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
110 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
132 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
317 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
225 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
102 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
200 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
80 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 ...
2
votes
1answer
89 views

Is Dependency Inversion a valid alternative to the pImpl idiom?

If I want to present to the user of my code an interface, that is unlikely to change, I can write only the public part of the classes in public headers and have a single private pointer to another ...
0
votes
2answers
118 views

Should I extend an interface or keep it independent?

I'm trying to decide whether to extend a base interface with additional methods or create several independent interfaces. I have a Task interface that looks like this interface Task { public ...
2
votes
2answers
96 views

Delegating work and programming to component interfaces

I have a MessageHandler class which receives and validates messages before determining which components in the architecture they should be delegated to so they can be processed. This involves calling ...
8
votes
2answers
1k views

Is using interfaces for datatypes an anti-pattern?

Suppose I have a various entities in my model (using EF), say User, Product, Invoice and Order. I am writing a user control that can can print the summaries of entity objects in my application where ...
3
votes
5answers
327 views

Implement multiple separate interfaces or interface hierarchy

I've been refactoring one of my projects recently and ran into a decision I have to make. I have several interfaces: Entity: Something in the game world Actor: An Entity that can perform actions ...
2
votes
2answers
230 views

When to use a SortedMap interface?

The rule in programming is to use the most general interface possible. But the difference between Map and SortedMap is more subtle. They compile to the same bytecode [I think] No additional safety ...
2
votes
2answers
86 views

Are single method interface and function type definition the same?

In a language where it is possible to define interfaces and typedefs (using Dart here): abstract class Receiver { void receive(int quantity); } typedef void Receive(int quantity); abstract class ...
2
votes
2answers
70 views

Interface design - Parameter choice

Situation: Is it better to have one or few parameters that supply more than enough information for the intended process or should you have more specific parameters that provide just enough ...
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 ...
7
votes
5answers
394 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 ...
0
votes
1answer
61 views

Implementing an interface already implemented by a parent class?

If a class extends a parent which defines an interface, should that class also explicitly implement the interface? As an example, is it better to include or remove the portion in square brackets ...
1
vote
1answer
64 views

Documentation of interfaces

I know how to document a function: /** * Prints a greet message to the web page */ function greet() { echo "Hi!"; } Or describe the usage of a variable: /** * @type string $name The user's ...
0
votes
4answers
234 views

How should nodes in a chain be connected?

Suppose you were building a system that receives data on one end and sends filtered data on the other end. The system is a chain of nodes, each receiving data from the node before and sending ...
0
votes
1answer
191 views

Interface or boolean?

I have a CustomObject class which has the abilities like being Clickable, KeyPressable and Movable. I created interfaces: IClickable, IKeyPressable and IMovable and make different CustomObject classes ...
5
votes
2answers
153 views

Is it good design to put abstract methods in an abstract class even though the methods are already defined in its interface?

Let's say we have an interface Foo with a method "public void someMethod()", and we have one or multiple abstract classes that "implement" Foo but don't necessarily themselves provide an ...
16
votes
4answers
2k 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
73 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# ...
1
vote
0answers
38 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
301 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 ...