[Newbies] delegation vs inheritance

Ron Teitelbaum Ron at USMedRec.com
Sat Aug 4 13:48:44 UTC 2007


Hello,

I have to ask is Grunt your real name?  Do you have a real name?  

Ok so your question is very vague.  I'll try to answer, but I'm not sure my
answer will be much help.

Stack is a specialization of Object

Stack has a linked list

Stack normally implements linked list as a collection of StackLinks.

StackLink is a specialization of Link

Link has a nextLink that normally points to an instance of Link (or it's
subclasses) to provide a linked list structure.  

Does that help?

Ron



> -----Original Message-----
> From: gruntfuttuck
> 
> 
> First of all I must apologise if I get some terminology wrong in this
> post.
> 
> I was rummaging around the collection classes earlier today and came
> across
> class Stack. I was interested to see that it makes use of class LinkedList
> through delegation with a instance variable rather than inheritance.
> I'm tyring to remember my Analysis and Design course here. I have a foggy
> memory about a is-a and has-a relationship. So a ford is-a type of Car, so
> that is a inheritance relationship and a Car has an engine so that is a
> delegation relationship. I also know that delegation is better for loose
> Coupling.
> 
> As you can see I'm a bit vague on all this. With class Stack what would
> the
> be the likely thinking to delegate as apposed to inherit? I think this is
> a
> very impotent subject and I would like to be clearer on it.
> --
> View this message in context: http://www.nabble.com/delegation-vs-
> inheritance-tf4216781.html#a11996570
> Sent from the Squeak - Beginners mailing list archive at Nabble.com.
> 
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners



More information about the Beginners mailing list