Re: Property or get/set methods ?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: David Browne (meat_at_hotmail.com)
Date: 12/14/04


Date: Tue, 14 Dec 2004 16:48:43 -0600


"Rachel Suddeth" <rachel@bldhound.com> wrote in message
news:uGPhtbh4EHA.1524@TK2MSFTNGP09.phx.gbl...
> Also, if you have a case where you want to be able to set, but not get,
> then personally I think a write-only property is weird and confusing, and
> I would make that a set method.
>

Agree on both. Properties should only be used as a replacement for a
getter, or a getter/setter pair, where the methods are:
-Not resource intensive
-The getter does not change the state of the object in any visible way
-The setter does not change the visible state of the object, except for the
value returned by the getter.

I don't like properties at all where you have to set PropertyX before you
can run MethodY. This should be a constructor argument or an argument to
MethodY.

David