Questions about interface related design considerations, such as programming to the interface.
6
votes
4answers
1k views
Can I consider interface methods as abstract methods?
I was thinking about that, and I had some doubts.
When I declare an interface, for example:
public interface MyInterface
{
public void method1();
public void method2();
}
Could these ...
26
votes
12answers
5k views
Why does PHP have interfaces?
I noticed that as of PHP5, interfaces have been added to the language. However, since PHP is so loosely typed, it seems that most of the benefits of using interfaces is lost. Why is this included in ...
0
votes
0answers
29 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 ...
25
votes
3answers
2k 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 ...
2
votes
1answer
79 views
Programming against an protocol in Objective-C
I stumbled upon the SOLID principles. There is one burning question. Should I always use protocols? I never saw someone using them in the way a Java developer would use them.
I tried it in a demo ...
3
votes
5answers
161 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 ...
0
votes
1answer
81 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 ...
1
vote
2answers
105 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 ...
3
votes
4answers
255 views
As a tooling/automation developer, can I be making better use of OOP?
My time as a developer (~8 yrs) has been spent creating tooling/automation of one sort or another. The tools I develop usually interface with one or more API's. These API's could be win32, WMI, ...
4
votes
3answers
407 views
Switching from abstract class to interface
I have an abstract class which has all abstract methods except one which constructs objects of the subclasses. Now my mentor asked me to move this abstract class to an interface.
Having an interface ...
-1
votes
1answer
55 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
243 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
65 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 ...
4
votes
6answers
1k 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 ...
0
votes
1answer
121 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
164 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 ...
-5
votes
4answers
834 views
What is Interface in Java programming language? [duplicate]
Last week my lecturer was teaching us about interfaces in Java.
However, I failed to understand her explanation that well.
Does anyone have a good description, or explanation of Java interfaces, and ...
21
votes
4answers
1k views
Should interface names begin with an “I” prefix?
I have been reading "Clean Code" by Robert Martin to hopefully, become a better programmer. While none of it so far has been really ground breaking it has made me think differently about the way I ...
6
votes
1answer
260 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
55 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 ...
2
votes
1answer
163 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 ...
3
votes
2answers
143 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 ...
10
votes
5answers
653 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
106 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
68 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 ...
2
votes
0answers
64 views
Source and destination arguments order in methods [closed]
I have a rather simple question.
I'm planning file management interface, so I have two methods: put - to put file from source to some destination, and write - to write source data to some file ...
4
votes
5answers
2k views
How to Model a simple file-system by UML class diagram
I want to model a file system which contains both files and directories, and directories can contain either files or other directories.
This is what I have reached so far:
In OOSE book, however, a ...
6
votes
6answers
2k 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, ...
31
votes
7answers
16k views
When to use abstract classes instead of interfaces with extension methods in C#?
"Abstract class" and "interface" are similar concepts, with interface being the more abstract of the two. One differentiating factor is that abstract classes provide method implementations for derived ...
1
vote
4answers
195 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 ...
1
vote
1answer
123 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 ...
3
votes
1answer
269 views
Is this Hybrid of Interface / Composition kosher?
I'm working on a project in which I'm considering using a hybrid of interfaces and composition as a single thing.
What I mean by this is having a contain*ee* class be used as a front for ...
4
votes
1answer
165 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 ...
8
votes
7answers
2k views
Default vs Impl when implementing interfaces in Java
After reading Should package names be singular or plural? it occurred to me that I've never seen a proper debate covering one of my pet peeves: naming implementations of interfaces.
Let's assume ...
5
votes
1answer
158 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 ...
1
vote
3answers
190 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
1answer
150 views
What resources are there for facial recognition [closed]
I'm interested in learning the theory behind facial recognition software so that I can hopefully implement it in the future. Not just face tracking, but being able to recognize individuals. What ...
9
votes
4answers
2k views
The term “interface” in C++
Java makes a clear distinction between class and interface. (I believe C# does also, but I have no experience with it). When writing C++ however there is no language enforced distinction between class ...
2
votes
3answers
98 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
236 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
2answers
105 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 ...
3
votes
7answers
602 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 ...
57
votes
13answers
12k 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?
4
votes
2answers
209 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.
...
60
votes
20answers
13k 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, ...
3
votes
6answers
382 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 ...
0
votes
0answers
98 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 ...
2
votes
2answers
206 views
Need some advice on CLI design, I need to provide simple but powerful command line options
I am writing a utility that runs on RHEL5 command line. I need my command line options to be simple but powerful. I looked at the various UNIX utilities to get an idea of how simple command line ...
1
vote
2answers
147 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 ...
3
votes
2answers
131 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 ...

