
Boost : 
From: Peter Dimov (pdimov_at_[hidden])
Date: 20040524 06:52:17
Reece Dunn wrote:
> Peter Dimov wrote:
>> 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.
>
> Since the invariant is on both variables, neither can be set
> independant of each other, since you'd assume that changing one would
> invalidate the invariant. Therefore, the properties must be
> *readonly* to prevent modification. You'd have a function to set both
> values at the same time (e.g. moveto).
Exactly. Which is the C++ model: int x() const, int y() const, void set(int,
int). Some purists even omit the set(): p = point(4, 3);
You can, of course, use "read only properties" instead of x() and y() but
this changes nothing but syntax, not necessarily for the better, I might
add.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk