I'm relatively new to non trivial OOP programming and recently stumbled
across the idea of Factory classes that can create objects at runtime. I
know we can hard-code class definitions for use by our Factory classes...
just wondering if it's a common practice to drive class definitions from a
database. Somehow the possibility of doing this seems both very cool (that
it may be possible) and very dangerous ("just because you can doesn't mean
you should").
So, how would I go about automating the construction of runtime objects -
and have the definition of each object determined at runtime from a database
(in whole or in part).
Specifically (and for example) say I want to create Person objects at
runtime. Each Person has a FirstName and LastName property. Somewhere in a
database I store the fact that Person objects have a FirstName and LastName
property. Then tomorrow I want to cause Person objects to additionally have
a MiddleName property. What I want is to simply be able to update the
database and - Bingo! - the Person objects now all have a MiddleName
property.
Am I nuts or is this a reasonable thing to be attempting?
Thoughts? Opinions? Perspective on *how* Factory classes most reasonably
create runtime objects?
Thanks!