Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-05-24 05:50:14


From: "Edward Diener"
> David Abrahams wrote:
> > "Edward Diener" <eddielee_at_[hidden]> writes:
> >
> >>> If you are making designs that would normally have a lot of getters
> >>> and setters, it suggests that they may have an insufficient level of
> >>> abstraction. Of course, that isn't neccessarily the case -- but it
> >>> does seem to be the rule in my code. I personally don't have a need
> >>> for this facility and I don't think I want a library that would
> >>> encourage that style.
> >>
> >> I don't see what getters and setters have to do with levels of
> >> abstraction. Needless to say I see nothing wrong with the style
> >> that uses properties, but since you didn't say what bothers you
> >> about that style I can't answer for why you don't like it. Care to
> >> explain ?
> >
> > When classes have a lot of getters and setters or, equivalently,
> > exposed properties that are just reflections of underlying data
> > members, they usually represent just a collection of exposed data
> > values rather than a higher level of abstraction.
>
> Properties do not have to be data members at all but just values may be
set
> anywhere, ie. a file on disk or a database, and a number of properties may
> refer to a single underlying object within the actual object having the
> property.

It doesn't matter. Properties represent degrees of freedom. They don't
describe dependent data well.

As a relatively simple example, consider a pair of integers (x, y) that has
an invariant of x*x + y*y = 25, and try to move from (3, 4) to (4, 3) by
using the X and Y properties.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk