Are Abstract Classes and Methods Obsolete?

Architectureinheritanceinterfacesobject-oriented

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? Create an interface instead.
You need an abstract class with some implementation in it? Create an interface, create a class. Inherit the class, implement the interface. An additional benefit is that some classes may not need the parent class, but will just implement the interface.

So, are abstract classes / methods obsolete?

Best Answer

No.

Interfaces cannot provide default implementation, abstract classes and method can. This is especially usefull to avoid code duplication in many cases.

This is also a really nice way to reduce sequential coupling. Without abstract method/classes, you cannot implement template method pattern. I suggest you look at this wikipedia article : http://en.wikipedia.org/wiki/Template_method_pattern