>>>> Properties are a 1-to-1 relationship of a classes member and the state
>>>> it's representing,
>>>>
>>> which is a violation of encapsulation and promotes unnecessary couplings.
>>>
>>
>> That 1-to-1 relationship is the encapsulation, and it's actually
>> promoting the point.
>>
> Encapsulation is about information hiding. If you directly expose the
> type, you've violated encapsulation. Properties are good at the edge of
> a system where you are forced to expose internal state. it my my humble
> opinion that properties have little business away from the edges.
Encapsulation is exactly what properties provide. Take the following
encapsulation of member variable foo:
private int foo;
public int Foo {
get { return foo; }
set {
if (value < 0)
ArgumentOutOfRangeException("Value for property Foo must be >= 0");
foo = value;
}
}
-Brett
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---