Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #4794

Re: Two object oriented methods, which is better?

From Melzzzzz <mel@zzzzz.com>
Newsgroups comp.programming
Subject Re: Two object oriented methods, which is better?
Date 2014-09-18 20:46 +0200
Organization albasani.net
Message-ID <20140918204616.7a953d26@maxa-pc> (permalink)
References <lvf8uf$o09$2@speranza.aioe.org>

Show all headers | View raw


On Thu, 18 Sep 2014 21:40:19 +0300
Victor Porton <porton@narod.ru> 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.

Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Two object oriented methods, which is better? Victor Porton <porton@narod.ru> - 2014-09-18 21:40 +0300
  Re: Two object oriented methods, which is better? Melzzzzz <mel@zzzzz.com> - 2014-09-18 20:46 +0200
    Re: Two object oriented methods, which is better? Kaz Kylheku <kaz@kylheku.com> - 2014-09-18 18:59 +0000
      Re: Two object oriented methods, which is better? Melzzzzz <mel@zzzzz.com> - 2014-09-18 21:08 +0200
        Re: Two object oriented methods, which is better? Kaz Kylheku <kaz@kylheku.com> - 2014-09-18 19:26 +0000
  Re: Two object oriented methods, which is better? Kaz Kylheku <kaz@kylheku.com> - 2014-09-18 19:24 +0000

csiph-web