Emulating Multiple Inheritance in Java using 'Program To Interface' Design Principle, Object Composition and Method Delegation
In this post I will demonstrate the use of ?Program To Interface? Design Principle and Object Composition, to emulate Multiple Inheritance in Java. For a refresher on these topics, there?s a very informative post on Artima Developer where Erich Gamma, co-author of the landmark book, Design Patterns, talks with Bill Venners about two design principles: program to an interface, not an implementation, and favor object composition over class inheritance.
For our example, consider different type of Employment Roles available in a typical Software Consulting Firm. To simplify things a bit, assume there are 4 roles; Developer, Tester, Architect and Project Manager. All of these are Employee(s) of the Software Consulting Form i.e. the employer.

Click here to Read More



Subscribe to Code Of The Day via: RSS Feed | Google Friend Connect