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

learn more… | top users | synonyms (1)

4
votes
3answers
139 views

What level of detail to use in an interface members descriptions?

I am extracting interfaces from some classes in .NET, and I am not completely sure about what level of detail of description to use for some of the interface members (properties, methods). An ...
9
votes
2answers
452 views

Is there an “ask for only what you need” interface principle?

I have grown into using a principle for designing and consuming interfaces that says basically, "ask for only what you need." For instance, if I have a bunch of types that can be deleted, I'll make ...
6
votes
3answers
339 views

Use cases for “private” interfaces?

I was wondering if there was a valid use case for being able to properly define the specific internal properties and functions of a class in a way similar to how an interface defines the public ...
2
votes
1answer
544 views

Why this code create object as interface?

In am reading Spring in Action (3rd edition) and here a snippet from it: ApplicationContext ctx=new ClassPathXmlApplicationContext("springidol.xml"); Performer ...
6
votes
3answers
478 views

What do you call an interface with no defining methods used as property setters

In ASP.NET and C# I've ran across this before. Your class needs to implement interface ISomething in order for something in the super class to supply something to you. I can't remember the details, ...
5
votes
2answers
148 views

Using a openid in a “closed system”

I would like to publish a website for certain family members only. Simply put, like a mishmash of family photos and videos. I want it to remain private, however. I was considering using openid for ...
8
votes
4answers
2k views

Return interface or class

Suppose I have a method public List<User> GetBatchOfUsers(IEnumerable<int> userIDs) { List<User> users = new List<User>(); // some database stuff return users; } ...
13
votes
4answers
902 views

Is there a different usage rationale for abstract classes/interfaces in C++ and Java

According to Herb Sutter one should prefer abstract interfaces (all pure virtual functions) to abstract classes in C++ to decouple the implementation as far as possible. While I personally find this ...
70
votes
14answers
17k 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
1answer
281 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 ...
2
votes
2answers
252 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 ...
4
votes
2answers
521 views

Storing IEnumerable as instance variable - is it a code smell to expect it to change?

I have something that works like a fixed size list - it's actually called FixedSizeStack<T> in my program. I will use it to represent the X last occured events. This event list will then be ...
8
votes
9answers
1k views

What OO Design to use ( is there a Design Pattern )?

I have two objects that represent a 'Bar/Club' ( a place where you drink/socialise). In one scenario I need the bar name, address, distance, slogon In another scenario I need the bar name, address, ...
0
votes
1answer
179 views

The design of a generic data synchronizer, or, an [object] that does [actions] with the aid of [helpers]

I'd like to create a generic data-source "synchronizer," where data-source "types" may include MySQL databases, Google Spreadsheets documents, CSV files, among others. I've been trying to figure out ...
5
votes
3answers
526 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 ...
5
votes
4answers
355 views

Passing compound object for parameters

I have different data modules, which take a couple of parameters from a configuration list. Do you think it's ok to pass a configuration object as a whole module1(config) and let the module pick what ...
8
votes
4answers
778 views

Is it bad practice to use an interface for categorization only?

For example: Say I have classes A, B, C. I have two interfaces, lets call them IAnimal and IDog. IDog inherits from IAnimal. A and B are IDogs, while C is not, but it is an IAnimal. The important ...
3
votes
2answers
253 views

Is this a pattern? Proxy/delegation of interface to existing concrete implementation

I occasionally write code like this when I want to replace small parts of an existing implementation: public interface IFoo { void Bar(); } public class Foo : IFoo { public void Bar() { ...
3
votes
2answers
902 views

Is it a good programming practice to have a class with several .h files?

I suppose the class have several different interfaces. Some it shows to some class, some it shows to other classes. Are there any good reason for that? One thing I can think of is with one .h per ...
38
votes
6answers
7k views

What is the point of having every service class have an interface? [duplicate]

At the company I work at, every service class has a corresponding interface. Is this necessarily? Most of these interfaces are only used by a single class and we are not creating any sort of public ...
4
votes
5answers
4k 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 ...
15
votes
10answers
10k views

Why use an interface when the class can directly implement the functions? [duplicate]

Possible Duplicate: Why are interfaces useful? Like most faculty, my java faculty introduced interface without explaining or even mentioning its practical use. Now I imagine interfaces have ...
3
votes
4answers
1k views

How can I explain C# interfaces, and constructors to a 8 years old kid?

How can I explain C# interfaces and constructors to a 8 years old genius kid?
5
votes
3answers
834 views

Checking preconditions or not

I've been wanting to find a solid answer to the question of whether or not to have runtime checks to validate input for the purposes of ensuring a client has stuck to their end of the agreement in ...
3
votes
4answers
307 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, ...
1
vote
6answers
409 views

Interfaces: profit of using

First of all, my ubiquitous language is PHP, and I'm thinking about learning Java. So let me split my question on two closely related parts. Here goes the first part. Say I have a domain-model ...
1
vote
4answers
2k views

Teaching java interfaces to absolute beginners: What is a good example? [duplicate]

Possible Duplicate: Explaining interfaces to beginning programmers? I searched on stackoverflow and here for a good example to teach java interfaces in a beginners class. I found the ...
13
votes
5answers
2k views

How do you evolve & version an interface?

Say you have an interface IFoo: public interface IFoo { void Bar(string s); int Quux(object o); } In version 2 of your API, you need to add a method Glarg to this interface. How do you do ...
9
votes
4answers
7k views

Who extends interfaces? And why?

AFAIK, my class extends parent classes and implements interfaces. But I run across a situation, where I can't use implements SomeInterface. It is the declaration of a generic types. For example: ...
0
votes
2answers
472 views

Is this bad design for a Shape interface?

I'm creating a vector editing program in C++, and I need a Shape interface which other concrete classes will implement. There is a requirement that no implementation inheritance is allowed. The design ...
8
votes
5answers
2k views

Interface and Inheritance: Best of both worlds?

I 'discovered' interfaces and I started to love them. The beauty of an interface is that it is a contract, and any object that fulfills that contract can be used wherever that interface is required. ...
10
votes
4answers
5k 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 ...
4
votes
1answer
1k views

implicit vs explicit interfaces

I think I understand the actual limitations of compile-time polymorphism and run-time polymorphism. But what are the conceptual differences between explicit interfaces (run-time polymorphism. ie ...
33
votes
4answers
13k views

Why should I prefer composition over inheritance?

I always read that composition is to be preferred over inheritance. A blog post on unlike minds, for example, advocates using composition over inheritance, but I can't see how polymorphism is ...
21
votes
9answers
2k views

Interface naming: prefix 'Can-' vs suffix '-Able'

It's common to use '-able' as a suffix for interfaces e.g. Serializable Printable Enumerable Drinkable Shootable Rotatable I was thinking that 'Can-' might better because it may be more descriptive. ...
12
votes
8answers
5k views

What is the point of an interface? [duplicate]

Possible Duplicate: When to use abstract classes instead of interfaces and extension methods in C#? What other reasons are there to write interfaces rather than abstract classes? This ...
6
votes
1answer
131 views

Private interfaces within a package

This is basically the same as Coding to interfaces, but played out in the real world of com when there are various engineering complexities such as immutability of published interfaces and ...
1
vote
2answers
2k views

What other reasons are there to write interfaces rather than abstract classes? [duplicate]

Possible Duplicate: When to use abstract classes instead of interfaces and extension methods in C#? When I read and looked at codes using Abstract classes, I was able to justify it because ...
10
votes
3answers
734 views

How do existential types differ from interfaces?

Given the existential type T = ∃X.{op₁:X, op₂:X→boolean} and this generic Java interface: interface T<X> { X op₁(); boolean op₂(X something); } What are the fundamental differences ...
3
votes
3answers
333 views

Naming conventions for the only envisioned implementation of an interface

If you decide "Program to An Interface" trumps YAGNI and decide to create a supertype where you don't envision anything other than one obvious implementation - is there a convention for naming the ...
5
votes
3answers
322 views

Should I provide synonyms in an API?

I'm designing a small library and there is a strong temptation to provide synonyms to some of the exported functions. var foldl = function(){ ... }; var reduce = foldl; //reduce is a synonym for ...
2
votes
5answers
584 views

Design Methodology for Developing Interoperable Systems?

A bit of background The company I work for has been creating database applications since around 1980 and, until relatively recently, most of these systems have been stand-alone "silo" systems. ...
1
vote
2answers
216 views

How is this “interface”-like structure/pattern called? [closed]

Let's assume we have an XmlDoc class that contains basic functionality for dealing with an XML data structure and saving/loading data to/from a file. Now we have several subclasses, A, B and C. They ...
8
votes
3answers
8k views

Difference between various Collection Generic Interfaces in C#

I have been playing around with C# for Windows and ASP.net MVC development for some time now. But I am still unclear on a few areas. I am trying to understand the basic difference between and ...
32
votes
6answers
4k 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 ...
-5
votes
4answers
2k 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 ...
7
votes
4answers
3k 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 ...
9
votes
4answers
337 views

Are interfaces and method signatures copyright protected?

For example, is it copyright infringement if I write a class called Random with the exact same purpose and method signatures as Microsoft's .Net System.Random class? Does it make a difference what ...
1
vote
1answer
272 views

What's the best way to use a kinect with multiple software music synthesizers?

For the past few months I've been looking into developing a Kinect based multitouch interface for a variety of software music synthesizers. The overall strategy I've come up with is to create ...
5
votes
2answers
3k views

What is the proper way to implement the OnClickListener interface for many buttons

My Android Activity contains multiple buttons that all need an OnClickListener. I've seen lots of different ways of doing this such as:: Implementing the interface in activity class Creating a ...