Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Re: change object class during runtime

by knobunc (Pilgrim)
on Jun 19, 2001 at 18:07 UTC ( #89633=note: print w/replies, xml ) Need Help??

in reply to Re: change object class during runtime
in thread change object class during runtime

Yes it works. Yes it is okay. But is it really the abstraction that you want? Masem's solution is much more clean in terms of future expansion. You have to think about why you want to use OO and how you anticipate this will change in the future. In this case you pretty clearly want to be able to add new DB types to the tool. So you should minimize the number of places that need to know about the mapping between DB types and object types. You certainly don't want to have each object know about all of the types.

Whether you can do the detection dynamically and try to load the appropriate code at run time (do an eval based on some identifying attribute like DBI does when loading DBDs) or whether you have a hard coded mapping in some file that needs to be changed each time there is a new DB type is up to you (and the requirements of the problem). Also remember who your target is. If this is for internal use and only you and whomever comes after you need to use it you may want to use a static mapping since it is unlikely that the DB classes will need to be released independent of the main code. If you are going to write a generic tool to release to CPAN that may not be valid.


  • Comment on Re: Re: change object class during runtime

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://89633]
[huck]: my @aa; for my $key (sort keys %hash){push @aa,$key,$hash{$ke y};} print join(',',@aa)."\n ";

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2018-05-27 08:05 GMT
Find Nodes?
    Voting Booth?