Re: Is this good use of Properties?
- From: Rick Elbers <rick.elbers@xxxxxxxxx>
- Date: Mon, 09 May 2005 16:47:09 GMT
Brett,
The disadvantage of both methods is that you encapsulate=do nothing.
Start thinking in objects means a lot of times do completely away with
accessors! It will really help you to be really critical about every
one of those.
Rick
On Mon, 9 May 2005 09:17:09 -0400, "Brett" <no@xxxxxxxx> wrote:
>If I do this without declaring a corresponding field, is it considered bad
>design? What are the advantages or disadvantages to either method? Notice
>there is not set.
>
>public string URL
> {
> get
> {
> return "www.somewhere.com/test.aspx";
> }
> }
>
>vs. a more common approach:
>
>
>private readonly string _URL = "www.somewhere.com/test.aspx";
>
>public string URL
> {
> get
> {
> return _URL;
> }
> }
>
>Also, if I only have a get accessor, is it necessary to declare the field as
>readonly?
>
>Thanks,
>Brett
>
.
- Follow-Ups:
- Re: Is this good use of Properties?
- From: Brett
- Re: Is this good use of Properties?
- References:
- Is this good use of Properties?
- From: Brett
- Is this good use of Properties?
- Prev by Date: Re: remove from listBox
- Next by Date: Colored SQL Editor
- Previous by thread: Re: Is this good use of Properties?
- Next by thread: Re: Is this good use of Properties?
- Index(es):