Problem with Point property

Henning Hasemann hhasemann at web.de
Wed Mar 7 04:39:10 PST 2007


> The problem ´seems to stem from the often used breaking of the data 
> encapsulation in the class Foo.
> 
> I already wrote about my _feeling_ that using properties as substitutes 
> for field accesses is inherently wrong because it also breaks data 
> encapsulation.
> 
> Getters might be better seen as delegates, capable of answering 
> questions about the state of the instance they stem from at that point 
> in time when they were requested.
> 
> -manfred

So you're saying one should better write a setPosition method instead of a
setter?
Or how would you make it?

The semantic is, that Foo really has a position, but when it is changed,
it should inform another object because that holds Foo's sorted by y-position.

But that in turn is an implementation detail, a user of Foo should not
notice nor care about: Maybe later on I'll just resort the Foo's from
time to time or when I need them sorted or whatever.

Henning

-- 
v4sw7Yhw4ln0pr7Ock2/3ma7uLw5Xm0l6/7DGKi2e6t6ELNSTVXb7AHIMOen5a2Xs5Mr2g5ACPR hackerkey.com



More information about the Digitalmars-d mailing list