This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Posted by thura on October 21, 2001 at 10:32 PM
> hi..I would like to know the advantages and weakness of polymorphism, encapsulation,inheritance, and a has a relationship.
> thank you
This is for you to refer about the weakness and strength of encapsulation.
In Java Design, when using inheritance, encapsulation is inherently
weakened within a class hierarchy. They talk about a specific risk : Inheritance connotes strong encapsulation with other classes, but weak encapsulation between a super class and its subclasses. The problem is that if we inherit an implementation from a super class, and then change that implementation, the change ripples through the class hierarchy. This rippling effect potentially affects all the subclasses. At first, this may not seem like a major problem; however, as we have seen, a rippling effect such as this can assure unanticipated problems. eg. Testing can become a nightmare.
Encapsulation using objects is that the object need not reveal all its attributes and behaviors. In good Object-Oriented Design(at least what is generally accepted as good), an object should only reveal the interfaces needed to interact with it. Details not pertinent to the use of the object should be hidden from other objects. It is really the fundamental concept of Object-Oriented. Whenever the interface/implementation paradigm is covered, we are really talking encapsulation. This encapsulation pertains equally to data and behavior.
- OOD roy yu December 20, 2001 at 5:44 AM