View RSS Feed

Java Object

Object-oriented programming in Java.

  1. Consider composition instead of subclassing

    by , 04-26-2012 at 06:16 PM
    Composition might be considered as subclassing’s alternative.

    Composition :
    • is simply implemented by all call forwarding to object field.
    • consists of zero dependence upon the object field’s implementation details.
    • is considerably much more flexible, as it is dynamically defined at the runtime instead of compile time


    Subclassing issues are :

    • Encapsulation is violated since the implementation of subclass & superclass gets tightly
    ...
    Categories
    Composition