Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #6012
| From | Victor Porton <porton@narod.ru> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Object oriented array inheritance |
| Date | 2015-12-03 19:25 +0200 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <n3pttq$fm7$1@speranza.aioe.org> (permalink) |
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 comp.programming | Previous | Next | Find similar | Unroll thread
Object oriented array inheritance Victor Porton <porton@narod.ru> - 2015-12-03 19:25 +0200
csiph-web