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


Groups > comp.programming > #6012 > unrolled thread

Object oriented array inheritance

Started byVictor Porton <porton@narod.ru>
First post2015-12-03 19:25 +0200
Last post2015-12-03 19:25 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.programming


Contents

  Object oriented array inheritance Victor Porton <porton@narod.ru> - 2015-12-03 19:25 +0200

#6012 — Object oriented array inheritance

FromVictor Porton <porton@narod.ru>
Date2015-12-03 19:25 +0200
SubjectObject oriented array inheritance
Message-ID<n3pttq$fm7$1@speranza.aioe.org>
My classes are associated with a (constant) array (specifying how fields of 
the data should be validated before storing to a database).

I need to make inheritance of arrays, that is in derived class adding some 
new elements to the array from the parent class.

In Perl syntax, it is possible to describe it in the following ways:

sub fieldValidators {
  my ($self) = @_;

  return (
    $self->SUPER::fieldValidators(),
    [ ... ],
    [ ... ],
    ...
  );
}

or:

sub init {
  my ($self) = @_;

  $self->SUPER::init();

  $self->addFieldValidator(...);
  $self->addFieldValidator(...);
  ...
}

Which of the two ways (using the array returning method fieldValidators() or 
constructor init()) is the best? Any other variants?

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

[toc] | [standalone]


Back to top | Article view | comp.programming


csiph-web