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

learn more… | top users | synonyms (1)

38
votes
7answers
27k 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 ...
88
votes
19answers
37k 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, ...
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?
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 ...
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 ...
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 ...
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 ...
10
votes
6answers
6k 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, ...
1
vote
0answers
432 views

Understanding interfaces [duplicate]

Possible Duplicate: When to use abstract classes instead of interfaces and extension methods in C#? Why are interfaces useful? What is the point of an interface? What other reasons are ...
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 ...
7
votes
3answers
337 views

How do you find your way in deeply nested, interfacey code? [duplicate]

I know most people hate flat and long functions, and hate when code is not full of ISomethings. The problem is that I guess my mind works in different way, and I always have problems with that type ...
15
votes
9answers
5k 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 ...
2
votes
2answers
1k 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 ...
37
votes
11answers
3k views

Is it bad habit not using interfaces? [closed]

I use interfaces rarely and find them common in others code. Also I create sub and super classes (while creating my own classes) rarely in my code. Is it a bad thing? Would you suggest changing ...
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 ...
15
votes
10answers
2k views

Declaring interface in the same file as the base class, is it a good practice?

To be interchangable and testable, normally services with logic needs to have interface, e.g. public class FooService: IFooService { ... } Design-wise, I agree with this, but one of the things ...
10
votes
7answers
3k views

Interfaces on an abstract class

My coworker and I have different opinions on the relationship between base classes and interfaces. I'm of the belief that a class should not implement an interface unless that class can be used when ...
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. ...
2
votes
7answers
1k views

Architectural patterns for interaction beyond MVC? [closed]

We all know the venerable Model-View-Controller pattern used to design interaction [mostly] with human users. It is the de-facto standard in OOP environment. What are some other architectural ...
0
votes
3answers
180 views

Necessity of Interfaces for Small Projects

Is it necessary to use interfaces for small projects? I work at a shop writing small custom applications for clients, primarily data manipulation. I'm mostly self-taught but also took some programming ...
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. ...
3
votes
3answers
476 views

Why not apply Interface Segregation Principle to “extreme”

Providing that clients would typically consume just one method, though methods would be conceptually related, why not always apply the Interface Segregation Principle to the extreme and have [many] ...
3
votes
2answers
402 views

Implementing the Interface Segregation Principle

Does this IConvertible interface satisfy the Interface Segregation Principle (ie. the "I" in SOLID)? Here is the definition: public interface IConvertible { TypeCode GetTypeCode(); bool ...
1
vote
1answer
361 views

Interface Dependencies or Abstract Classes

I have a decision to make and I am wondering what would be the better solution. I am refactoring an older application and intend to really get into the nuts and bolts of it. There are 8 report types ...
1
vote
3answers
232 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) { ...
0
votes
0answers
87 views

How far to go when future proofing fluent-method-chained-DSL test code?

Is it worth implementing interfaces, or using the getThis() trick, or even static factory methods to future proof against the need to extend this DSL? The current design is a pair of thin ...
6
votes
4answers
467 views

Split up large interfaces

I'm using a large interface with about 50 methods to access a database. The interface has been written by a colleague of mine. We discussed this: Me: 50 methods is too much. It's a code smell. ...
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 ...
2
votes
4answers
6k views

Abstract class + Inheritance vs Interface

Hello fellow programmers, I am reading a book on C# and the author is comparing Abstract classes and Interfaces. He claims that if you have the following "abstract class:" abstract class ...
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 ...
0
votes
1answer
107 views

When is it suitable to use inheritance [duplicate]

I recently had a small "argument" about inheritance with a friend. I think people overuse it a lot. Intuition tells me that that the only good reason for class inheritance is polymorphism - when there ...