ArticlesInheritance v/s Containment


Points to ponder:


With protected field access and overloading Inheritance is suitable to extend an server from an existing server. In containment the contained object would not allow access to the private data . So inheritance is more efficient.

If this is not the case then server extention will not suffer. It can be done through inheritance or through containment . But the client can get affected . In inheritance client can consider both the original and derived server as of same type. In containment the new server is not of the type of original server. Thus , the client's reusablility is affected.

The extended server "containing" the original server's reference can also work with the whole family of the original server. Whereas if extention is through inheritance this is not possible.

back

support@rajeshpatkar.com
Rajesh Patkar Institute Of Software Engineering
26/A Patel Shopping Center, Ground Floor, Sainath Road, Opp Malad Subway, Malad (W), Mumbai.
Tel: 9820860292, 9820396074, 30903720, 28076817.