in reply to OO: Building an object of the right type based on a parameter

something seems strange about storing a class name (eg storing code) in a field. Feels brittle, perhaps.

I think that's eminently reasonable, and do it all the time.

For another layer of flexibility, you may want to use some other identifying string and then provide a hash that maps those strings to package names; using Class::Factory as lachoy suggests is a sensible implementation choice.

  • Comment on Re: OO: Building an object of the right type based on a parameter