X-FeedAbuse: http://nntpfeed.proxad.net/abuse.pl feeded by 88.191.16.109 Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!nospam.fr.eu.org!usenet-fr.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!news.glorb.com!news.astraweb.com!border5.newsrouter.astraweb.com!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Re: Composition instead of inheritance References: <4dba22f3$0$29978$c3e8da3$5496439d@news.astraweb.com> X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney Date: Fri, 29 Apr 2011 13:50:53 +1000 Message-ID: <87k4edk95u.fsf@benfinney.id.au> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:WRHqHmwiB54G23agxcYYs02E2Mc= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Lines: 31 Organization: Unlimited download news at news.astraweb.com NNTP-Posting-Host: 03845ff4.news.astraweb.com X-Trace: DXC==OdkFHjNH2Y;0`5D\QI41SL?0kYOcDh@Z7^o:UA4R?cU=F@>lZn:30Y]G;2>V^?kWSbEW9A[5UK?UNZ[SL`C\KgS writes: > On Thu, 28 Apr 2011 15:35:47 -0700, Carl Banks wrote: > > > That's not what we mean by composition. Composition is when one > > object calls upon another object that it owns to implement some of > > its behavior. > > I thought that was delegation. As in, when one object delegates some or > all of it's behaviour to another object: > > http://code.activestate.com/recipes/52295 The difference being that, with delegation, the object being called is unrelated to this one. With composition, the object being called is not wholly separate, but is instead an attribute on the current object. The “another object that it owns” was, I presume, meant to communicate this “an object which is an attribute of the current one” relationship. > In mathematics, composition means to make a function by applying a > function to the output of another. The term “composition” in the programming sense comes from OO design, not functional nor mathematical terminology. -- \ “I don't like country music, but I don't mean to denigrate | `\ those who do. And for the people who like country music, | _o__) denigrate means ‘put down’.” —Bob Newhart | Ben Finney