Doesn't seeking to mix a method in like that totally break
encapsulation though (and possibly offend our good friend Demeter)?
Why does the whole Car need to know anything about what the Engine is
doing except that it's doing what it needs to be doing and give it
facilities to do what is needed?

I know you're going for composition here, but maybe I'm not seeing the
benefit of it or this is a bad example?

--Jeremy

On Nov 17, 2007 1:32 AM, Thufir <hawat.thufir / gmail.com> wrote:
> On Sat, 17 Nov 2007 14:36:50 +0900, Raul Parolari wrote:
>
>
> > I do not like (at first view) the idea of this design; it leads to, as
> > Konrad has correctly observed, to start the car by saying:
> >
> >     vw_bug.engine.vroom()
>
>
>
> Fair enough.  This is pretty much how Java would do it, and, correct me
> if I'm wrong, Smalltalk would probably do similarly.
>
> Put another way:  there must be a non-contrived case of composition in
> Ruby?  Yes?
>
>
>
> thanks,
>
>
> Thufir
>
>
>



-- 
http://www.jeremymcanally.com/

My books:
Ruby in Practice
http://www.manning.com/mcanally/

My free Ruby e-book
http://www.humblelittlerubybook.com/

My blogs:
http://www.mrneighborly.com/
http://www.rubyinpractice.com/