> >It breaks the rules of encapsulation and data hiding,
> 
> If all you are doing is setting a private field and reading 
> it and it is the same type (as per the example posted) you 
> are not hiding or encapsulating anything but instead 
> compromising for the fact the .NET environment will break 
> binary compatibility if you later switch it to a read/write property.

        no. A get will result in a get_PropertyName() method, and a set
will result in a set_PropertyName() method. Adding a setter to a
property will not break compatibility, simply because you add a method,
which will not be called by older code which was build against the older
interface. 

        About hiding away: when you simply return a private member, it
is not hiding anything indeed. but you can, instantly, without breaking
the interface, for example do a calculation on the value before
returning it, or do a check before returning it or setting the value.
Especially the checks in a setter are important: you have one place for
the set-check logic still you do not have to give up private member
variables.

        FB

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com
NEW! ASP.NET courses you may be interested in:

2 Days of ASP.NET, 29 Sept 2003, in Redmond
http://www.develop.com/courses/2daspdotnet

Guerrilla ASP.NET, 13 Oct 2003, in Boston
http://www.develop.com/courses/gaspdotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to