In an object oriented module describing a database, should I pass DB description data structures to the constructor in the constructors of derived classes, or should I instead create ("virtual" that is dynamic) methods which create the data structures and call them in the constructor?
These data structures are long (around 100 elements arrays).
A Python example follows:
class Base:
def __init__(data_desciption):
self.data_desciption = data_desciption
vs
class Base:
def __init__():
self.data_desciption = self.data_desciption_init()
or in C++:
class Base {
DataDescription data;
public:
Base(DataDescription &data_description) {
data = data_description;
}
};
vs
class Base {
DataDescription data;
protected:
virtual DataDescription &get_data_description() = 0;
public:
Base() {
data = get_data_description();
}
};
(probably not optimized for speed, but this is now irrelevant). (oh, I've forgotten that C++ constructors can't call pure virtual functions. Not used C++ for a long time. But this does not change the essence of my question).
In fact I am now programming in Perl.