[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.programming

Object oriented array inheritance

Victor Porton

12/3/2015 5:25:00 PM

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://porton...