Dependency Inversion Principle and Abstract factory Pattern
October 9, 2012 Leave a comment
DI Principle says high level components/classes should not directly depend on low level components/classes instead both should depend on the abstraction.
Object tree through abstraction
From these figures the object tree has been reversed which is dictated by DI principle.
Guidelines that help us avoid violation of DI principle:
- No variable should hold a reference to the concrete class
- No class should derive from concrete class
- No method should override an implemented method of any of its subclasses
Abstract factory patterns is an extension to the factory pattern which helps in creating families of related or dependent objects without specifying their concrete classes.
Recent Comments