Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.albasani.net!.POSTED!not-for-mail From: Melzzzzz Newsgroups: comp.programming Subject: Re: Two object oriented methods, which is better? Date: Thu, 18 Sep 2014 20:46:16 +0200 Organization: albasani.net Lines: 35 Message-ID: <20140918204616.7a953d26@maxa-pc> References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net FCJZUXCRT6Tvtal9UlRjWiUpAdeOD9bs0BfxYxqv7xPhx/soYxQX5mmESAZe6yPkAJoDoEzHtkBjUfhasUWWMpIDT/zgwtaNHAvEhL6vzO5oa89YjoBUwLzECfTzIQuk NNTP-Posting-Date: Thu, 18 Sep 2014 18:46:16 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="uH7yUDZ14Tas2+zilLFgBSCF5bjEFLSZQMZAVKu64ur9qtC2/WgH1Rgz7YH4V/q8tV5mFFUuhtCsetB16W+MuFpgkCRKcwRtWqtsk93ZbUl1qn/8g5zxqOlrpQLVvr+B"; mail-complaints-to="abuse@albasani.net" X-Newsreader: Claws Mail 3.10.1 (GTK+ 2.24.24; x86_64-unknown-linux-gnu) Cancel-Lock: sha1:BxtMy1vWgMN6B4Sdi9sJcReT/3k= Xref: csiph.com comp.programming:4794 On Thu, 18 Sep 2014 21:40:19 +0300 Victor Porton wrote: > [Sorry for multiple postings, but traffic of comp.object is so low > (as I found after my posting there), that almost nobody will suffer > of my multiple posting.] > > If I want to push a specific (for a given subclass) value into an > array argument of a method, should I just pass the value of the > argument to a method which would modify it, or should I create a > method which just returns > the list of additional values (and use it in the first mentioned > method)? > > Pseudocode (with "#" starting comments) for a method f: > > # modify_array is a dynamic method > function f(object, array) { > object->modify_array(array); > } > > or > > # common_array_members is a dynamic method > function f(object, array) { > array = concat(array, object->common_array_members()); > } > > What is more object oriented? Which is better? First can do whatever with array, while second shows clear intent. I'll go with second since it is clearer what function does.