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

learn more… | top users | synonyms (1)

2
votes
1answer
174 views

Design of interface for finding one of something or a list

I am developing a telephony call model and thinking about how best to design the interface. One basic idea is that a call has a unique call identifier. I have a list of calls and finding a specific ...
1
vote
1answer
78 views

Generic service control interface

I need an interface to a back-end service, mostly for control commands (stop, status, cancel, reload config). The service might be in Python, Perl, Java, or whatever, and runs continuously. The ...
0
votes
0answers
147 views

Pattern or solution for using classes with different interface the same way

What I would like to achieve is to use classes (now two, later more) with different interface the same way, so I would like avoid using decisions based on the interface on upper levels for instance, I ...
2
votes
4answers
205 views

Why should IQueryProvider implementations throw NotSupportedExceptions?

Searching the web, we can find plentiful examples of various ORMs (nHibernate, EF, LinqToSql, etc.) that implement but don't actually support the full IQueryable<T> interface, throwing ...
2
votes
1answer
93 views

What to name a new interface that is replacing an existing one?

We're redesigning our application's plugin interface, so we're using the Adapter pattern with our proof-of-concept design to show that the new interface will function without committing to using it in ...
4
votes
1answer
266 views

Is using protected inheritance to hide (but exploit) implemented interface from the public ok?

Recently, we had a discussion about code using protected inheritance in order to hide the fact (to client code) a class inherits from a specific base class but to exploit this fact in the ...
-3
votes
3answers
382 views

Programming to interface in Java [duplicate]

What is the real use of interfaces in Java? What is meant by programming to interfaces? I heard these things several times but I don't know what it is and why it is used.
1
vote
4answers
462 views

Explanation of the definition of interface inheritance as described in GoF book

I am reading the first chapter of the Gof book. Section 1.6 discusses about class vs interface inheritance: Class versus Interface Inheritance It's important to understand the difference between ...
2
votes
3answers
90 views

Can certain expectations of behavior be part of an interface's contract?

Given the following code: public interface IUserDataProvider { ICollection<SomeClass> getSomeClassRecordsForUser(int idUser); } Is it possible to define (via documentation) an ...
3
votes
2answers
587 views

Collection interfaces in C#, coming from Java

In Java, I'm used to declaring collections using the most-abstract interface possible and then constructing them using the concrete implementation that makes sense at the time. It usually looks ...
3
votes
2answers
620 views

C++ class with only pure virtual functions: what's that called?

So i'm looking for some input/consensus on what terminology we should be using to describe something that looks like this: class Printable { public: virtual void printTo(Printer *) = 0; ...
8
votes
4answers
676 views

When to use interfaces (unit testing, IoC?)

I suspect I've made a schoolboy error here, and am looking for clarification. A lot of the classes in my solution (C#) - dare I say the majority - I've ended up writing a corresponding interface for. ...
1
vote
1answer
260 views

Interfaces, Adapters, exposing business objects via WCF design

I know there have been countless discussions about this but I think this question is slightly different and may perhaps prompt a heated discussion (lets keep it friendly). The scene: I am developing ...
2
votes
2answers
870 views

Programming against a protocol in Objective-C

I stumbled accross the SOLID principles. There is one burning question. Should I always use protocols? I never saw someone using them in the way that a Java developer would use them. I tried it in a ...
4
votes
5answers
266 views

How does the concept of a class change when passing data to the constructor instead of method parameters?

Let's say we're making a parser. One implementation could be: public sealed class Parser1 { public string Parse(string text) { ... } } Or we could pass the text to the ...
1
vote
1answer
121 views

How do you distinguish your public API interfaces from the interfaces you use for testing/mocking?

Mocking frameworks are useful for creating mock objects that isolate the code under test from its surrounding software environment. Some mocking frameworks cannot mock non-virtual methods, so they ...
28
votes
4answers
3k views

What did Rich Hickey mean when he said, “All that specificity [of interfaces/classes/types] kills your reuse!”

In Rich Hickey's thought-provoking goto conference keynote "The Value of Values" at 29 minutes he's talking about the overhead of a language like Java and makes a statement like, "All those interfaces ...
1
vote
2answers
170 views

Violating the Interface Segregation Principle?

I currently have an interface named InternalEntityIdTransformer, which has a getInternalId method, that given an external id returns the corresponding internal one. Now I am working on functionality ...
-1
votes
1answer
62 views

serving up future-proof kinfolk - extensible contract interfaces [closed]

Ok, I have this human here, but what can it do, how would you discover its special abilities? And when you find out what kind of expert you've got then how would you actually make use of its unique ...
1
vote
5answers
547 views

The need for adding an interface to every class [duplicate]

My coworker and I are arguing very hard about this topic. He's thinking that every single class should have an Interface that the class implements (also Single-Implementations). He uses this design ...
1
vote
3answers
167 views

Coarse grained remote interface vs encapsulating business logic

I'm writing a Web Service that will be consumed by a Mobile client. The Mobile client has to make several chained requirements checks to determine whether the user may initiate a request, and if so ...
5
votes
6answers
3k views

Is there any difference between interfaces and abstract classes that have abstract methods only?

Let's say we have an abstract class and let this class has only abstract methods. Is this abstract class different from an interface that has same methods only? What I am looking to know is if there ...
2
votes
1answer
262 views

How does dependency inversion principle work in languages without interfaces?

In C#/Java, the dependency inversion principle is often demonstrated by high-level classes that depends on an interface/abstraction (that it owns). Low-level classes will implement the interface, thus ...
2
votes
3answers
216 views

Implicit optimization versus explicit optimization

To explain what I mean, let me start with an example. Consider a deque that supports O(logn) concatenation with another deque and O(n) addition of n elements at one end. This dequeimplements a ...
6
votes
1answer
273 views

Term for a Class with Multiple Interfaces

Say I have a class that implements multiple interfaces. I pass the same instance around using a different interface, depending on what the consumer is interested in. I am trying to remember what this ...
0
votes
1answer
68 views

OO Design: hint EntityManager to preload some datasets

say I have an EntityManager that can read(PK) a dataset from the DB and return it. I have an application that will process multiple records, iterate over them and for each, use the EntityManager to ...
4
votes
2answers
197 views

Should I make package private my DAO interfaces?

I have several DAO classes that implement an interface. In the other hand, I have Service classes that use those DAO implementations. So far all the DAO interfaces are public and I was thinking if ...
12
votes
5answers
1k views

What is the functional-programming alternative to an interface?

If I want to program in a "functional" style, with what would I replace an interface? interface IFace { string Name { get; set; } int Id { get; } } class Foo : IFace { ... } Maybe a ...
7
votes
3answers
164 views

Rules about the concreteness of method parameter types, return types and property types

Some time ago I read a kind of "rule of thumb" about the concreteness of method parameter types, return types and property types, but I just do not remember it. It said something about keep your ...
0
votes
2answers
390 views

1 Interface 2 Implementations and an EJB exception

In my JavaEE project I have an interface like this: @Local public interface DataAccess { ... } And two stateless beans implementing it: @Stateless public class DataAccess_Online implements ...
1
vote
1answer
145 views

Class inheritance and extra parameters

Im trying to create an SMS gateway .. I have a request coming in from a client (web form or API or database record) that I need to process and forward on to a 3rd Party API - or SMS provider. So that ...
4
votes
1answer
192 views

Can a common interface be defined for Cartesian and Polar coordinate data?

I'm rewriting a set of file readers that a former-colleague of mine created that read raw-point data of XYZ (Cartesian) coordinates or RTZ (Polar) coordinates. Currently the data is stored directly in ...
5
votes
1answer
205 views

Why aren't there Dimension and Point interfaces?

I mean something along the lines of: public interface Dimensioned { int getWidth(); int getHeight(); } and public interface Positioned { int getX(); int getY(); } There are a ...
2
votes
3answers
111 views

Adding Methods In Addition to an Interface

Let's say I have ThingImpl and IThing. The former is an implementation of the latter, which is an interface. IThing has 1 method: do(arg1) Is it considered a hack/bad practice to add a method in ...
8
votes
3answers
1k views

Should I implement an interface directly or have the superclass do it?

Is there a difference between public class A extends AbstractB implements C {...} versus... public class A extends AbstractB {...} AbstractB implements C {...} I understand that in both cases, ...
1
vote
4answers
347 views

Switch interface implementation using configuration [closed]

We want to allow the same core service to be either fully implemented or, as other option, to be a proxy toward a client legacy system (via a WSDL for example). In that way, we have both ...
3
votes
7answers
622 views

What problems will I face if I remove the concept of interfaces from my code?

I have been programming for many years but I am still not comfortable with the concept of "Interfaces". I try to use interfaces but many times I don't see a mandatory use for it. I think this is ...
1
vote
2answers
111 views

Interface extension

Suppose that I have an input stream interface, which defines a method for reading data. I also have a seekable interface which defines a method for seeking. A natural way of defining a input file is ...
5
votes
2answers
588 views

How to create contracts in python

I am currently learning Python (from Java) and have a question on contracts. Example: an application defines an interface that all plugins must implement and then the main application can call it. ...
0
votes
0answers
125 views

Where are the Interface information stored?

I would like to know whether the information in an interface such as the variables which are final and the methods which are abstract and static would all live in method area ??? And what would be ...
1
vote
3answers
219 views

Should I use an interface when methods are only similar?

I was posed with the idea of creating an object that checks if a point will collide with a line: public class PointAndLineSegmentCollisionDetector { public void Collides(Point p, LineSegment s) { ...
1
vote
2answers
623 views

Adhering to a protocol and being a subclass at the same time?

In objective C, I have a situation where I would like to have an abstract protocol (interface) with 5 methods and 4 properties, but at the same time, I'd like to have a common implementation of 3 of ...
2
votes
1answer
192 views

Use of interfaces to ease rapid development/prototypes

Recently I've started to put almost all of my data structures into interfaces, and many of the classes that contain pieces of logic code as well, depending on how much work they are. I find that this ...
8
votes
6answers
5k views

What are the differences between abstract classes, interfaces, and when to use them

Recently I have started to wrap my head around OOP, and I am now to the point where the more I read about the differences between abstract classes and interfaces the more confused I become. So far, ...
3
votes
6answers
578 views

Can interface be not abstract?

Friend of mine said that not every interface is abstract. I haven't chance to discuss that with him but it get me thinking of not abstract interface in any type of language. Is there a non abstract ...
3
votes
2answers
165 views

Developing JSON API for a Carpool Engine

I am developing a new set of API methods for carpooling/cab booking, so if a developer needs to develop an app or webportal for carpooling, he can call my JSON API. Basically making it easy for ...
16
votes
5answers
2k views

Use of keyword “Using” in C# interface

When I'm using C# to write some code and I define an interface using Visual Studio 2010, it always includes a number of "using" statements (as shown in the example) using System; using ...
6
votes
5answers
376 views

Everything has an Interface [duplicate]

Possible Duplicate: Do I need to use an interface when only one class will ever implement it? I am taking over a project where every single real class is implementing an Interface. The ...
4
votes
4answers
3k views

Instantiating Interfaces in C#?

I am reading/learning about interfaces in C# at the moment, and thus far I managed to understand how it differs from an abstract class. In the book I am reading the author explains that interfaces are ...
13
votes
4answers
446 views

Two interfaces with identical signatures

I am attempting to model a card game where cards have two important sets of features: The first is an effect. These are the changes to the game state that happen when you play the card. The interface ...