Re: Property or get/set methods ?
From: David Browne (meat_at_hotmail.com)
Date: 12/14/04
- Next message: Bruce Wood: "Re: fastest way to parse a file; Most efficient way to store the data?"
- Previous message: santanbo: "Re: How to I do a http post from within a webform"
- In reply to: Mike Newton: "Re: Property or get/set methods ?"
- Next in thread: Ravichandran J.V.: "Re: Property or get/set methods ?"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 14 Dec 2004 16:38:50 -0600
"Mike Newton" <MNewton@discussions.microsoft.com> wrote in message
news:%23gkdA0h4EHA.2192@TK2MSFTNGP14.phx.gbl...
>I don't expose public class variables at all. It's a bad idea, and breaks
>encapsulation. It's easy to take a ref from a public class variable and
>turn it into something that it shouldn't be. Properties make sure that
>your vars are yours.
>
> Personally, I believe that exposing public variables is just a sign of
> laziness.
Yes. I am lazy. And I agree that exposing public variables is just a sign
of laziness.
But laziness in programming is a vice in inverse proportion to the type
safety of the language.
For POD types, private types, and "friend" types, the cost of variable
encapsulation is not always worth the effort.
David
- Next message: Bruce Wood: "Re: fastest way to parse a file; Most efficient way to store the data?"
- Previous message: santanbo: "Re: How to I do a http post from within a webform"
- In reply to: Mike Newton: "Re: Property or get/set methods ?"
- Next in thread: Ravichandran J.V.: "Re: Property or get/set methods ?"
- Messages sorted by: [ date ] [ thread ]