Sponsored Link •
|
Advertisement
|
interface
?
Canine
has one method, howl()
, that is abstract
Canine
is an abstract class, then expect subclasses like Dog
, Wolf
, etc...
Canine
is an interface, then could get implementations like Blender
It's really a tight-knit family thing. In the Java programming language, people can always use inner classes, which is a short hand of using composition, to get around multiple inheritance of implementation. If it feels more like a small family, go for the abstract class.
You force Canines into the Canine inheritance hierarchy. You limit client choices. What you are saying is that class Canine is a more narrow idea than interface Canine. If you use an abstract class, you are saying the concept is much more narrow, an interface, much more broad.
Sponsored Links
|