Hi Chris,
Could you help me with the following: our API for PGObject-based classes has only one constructor (the regular 'new' constructor). Many (but not all) classes can be passed a single 'id' value. The constructed object sometimes has a 'get' method.
In some cases, this 'get' method returns a new instance, in other cases, the getter initializes fields in the 'current' instance.
I'm thinking:
* The fact that the getter sets up the current instance makes me want
to use the getter with the 'primary key' (id) to retrieve the object from
the database. However, this means we can't require any fields in the
object.
* If the 'get()' method would be a class-level constructor (like new), always
returning a new instance, we could start requiring fields in our classes
(because the getter will make sure that required values are retrieved from
the database before the field checks happen)
Would it be an idea to require a minimum number of methods and class methods to be implemented on a LedgerSMB::PGObject, like the ones above, but maybe also "save", "remove" (not delete, as that's a reserved word in Perl), ... (any others?)
The API for the getter would include some kind of database connection as the argument, as well as a hash (to request a single object) or an array of hashes (to request multiple objects).