Heritage Vs Delegating

I'd like to have some opinions on each, what should be best used ?I'm a bit confused about wich should be used and when ... And what about Helper classes ?Thanks
[191 byte] By [Euphremea] at [2007-10-2 21:31:45]
# 1
inheritence implicit couples the classes
mchan0a at 2007-7-14 0:45:09 > top of Java-index,Other Topics,Patterns & OO Design...
# 2

Delegation couples a class with an interface; inheritance couples a class with an implementation. So you can say that delegation causes loose coupling whereas inheritance causes tight coupling.

Furthermore, you can use inheritance in delegation. You cannot use delegation in inheritance.

Delegation is usually better.

w^5

ktm5124a at 2007-7-14 0:45:09 > top of Java-index,Other Topics,Patterns & OO Design...
# 3
Thanks for this reply, and what do you think of Helper classes ?
Euphremea at 2007-7-14 0:45:09 > top of Java-index,Other Topics,Patterns & OO Design...
# 4

inheritance is good when a class really is an extended version of another class. In that case to delegate will just become a PITA. Especially in Java. Instead of 1/2 of this stuff they added in 1.5 they should have added some stuff to make delegation easier and more reliable.

Sometimes delegation causes all of these forwarded methods that I just hate.

_dnoyeBa at 2007-7-14 0:45:09 > top of Java-index,Other Topics,Patterns & OO Design...