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


Groups > comp.programming > #4793

Two object oriented methods, which is better?

From Victor Porton <porton@narod.ru>
Newsgroups comp.programming
Subject Two object oriented methods, which is better?
Date 2014-09-18 21:40 +0300
Organization Aioe.org NNTP Server
Message-ID <lvf8uf$o09$2@speranza.aioe.org> (permalink)

Show all headers | View raw


[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?

(We program in Perl.)

The array is an array of images which we attach to a email message. We 
always attach some images, but these images are different for different 
subclasses. At the moment, the order of elements of the array is probably 
not important.

-- 
Victor Porton - http://portonvictor.org

Back to comp.programming | Previous | Next — 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