Questions about interface related design considerations, such as programming to the interface.
59
votes
20answers
11k 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, ...
57
votes
13answers
11k 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?
36
votes
11answers
3k views
Is it bad habit not using interfaces?
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 ...
30
votes
6answers
4k views
What is the point of having every service class have an interface?
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 ...
29
votes
7answers
15k 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 ...
24
votes
12answers
4k 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 ...
22
votes
9answers
2k views
Are abstract classes / methods obsolete?
I used to create a lot of abstract classes / methods. Then I started using interfaces.
Now I am not sure if interfaces aren't making abstract classes obsolete.
You need a fully abstract class? ...
21
votes
9answers
1k 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. ...
20
votes
4answers
5k 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 ...
20
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 ...
17
votes
3answers
1k views
Would adding award points or game features to workplace software be viewed poorly amongst the programming community?
So one of my responsibilities at work is to build an internal tool that helps the workers enter in all their information. It's an enterprise application that is similar to a Windows forms database ...
16
votes
5answers
1k 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 ...
14
votes
10answers
1k 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 ...
13
votes
4answers
391 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 ...
12
votes
10answers
2k 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 ...