Hi,
On Sat, Jan 17, 2009 at 9:30 AM, Chris <
chrisj...@gmail.com> wrote:
>
> Thanks Steve and Alek. As I mentioned wrappers delegating access to a
> containing class and simple copy to from a business class is what we
> do today and its a mess, its error prone and its totally manual, am I
> missing something? Every new attribute needs to either have a few
> lines more added to the business class to get and set its values.
Typically, a business class should not expose all the internal state
(i.e. the attributes of the underlying data) in the first place. You
should be very specific which attributes you expose.
Anyway, having said that, you might consider just returning a
reference or pointer to the protocol buffer kept in the business class
in case you _really_ have to access the internal data
business_object->data().get_foobar().
This way you don't have to modify anything in case you add fields to
the data. However, this way you always expose all properties of the
internal data which is a bad idea - but again, this would have
happened with the inheritance approach as well.
On advantage as well is that the access code looks sufficiently ugly
that users will avoid using internal data fields directly :)
> In
> a prior job I did use a system where persisted classes were generated
> as *Base classes where you were expected to implement the * extending
> *Base. This worked very well and reduced maintainability.
You said the right thing here, but I guess you meant to say 'reduced
maintenance' .. ;)
-h