Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #6012 > unrolled thread
| Started by | Victor Porton <porton@narod.ru> |
|---|---|
| First post | 2015-12-03 19:25 +0200 |
| Last post | 2015-12-03 19:25 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.programming
Object oriented array inheritance Victor Porton <porton@narod.ru> - 2015-12-03 19:25 +0200
| From | Victor Porton <porton@narod.ru> |
|---|---|
| Date | 2015-12-03 19:25 +0200 |
| Subject | Object 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
Back to top | Article view | comp.programming
csiph-web