Tags: design interface
*Depend upon Abstractions*
Depend upon interfaces and abstract functions rather than upon concrete functions and classes. This principle is the enabling force behind component design.
Abstractions / interfaces are the design 'hinge points' - the places where the design can bend or be extended.
Every dependency in the design should target an interface or abstract class. This is draconian and we should allow ourselves to bend it - but only rarely. For example it is ok to depend on concrete classes from java standard libraries.
Object creation is the most common place this principle is violated - instead of constructing objects yourself use the AbstractFactoryPattern.
Interfaces that we extract and depend on should usually be put in the package that uses them rather than in the package that implements them.
Last published: Tuesday 11th May 2010
<<Previous Next>>