-
April 30th, 2005, 06:34 AM
#1
public static readonly vs accessor properties
I have several public static readonly variables
accessor properties are preferred over plain public fields, but is there any reason to wrap a public static readonly when it cannot possibly be written to anyway?
-
April 30th, 2005, 09:34 AM
#2
Re: public static readonly vs accessor properties
I would say "NO", because what you are trying to achieve is to have some constants. You could move them into a seperate class and declare them as constants if you like (some people do that).
Properties are really for "attributes" of your class. Given, a constant could "belong" inside your class as well, but I cannot see benefit in wrapping them in mutator methods (properties). The benefit of properties really come in the ability to manipulate or validate the data before saving it.
Another textbook answer would be that encaptulation is enforced by wrapping attributes as properties. Then again, I don't see myself why constants should fall in this catagory.
But that's only my view. - Cheers
-
April 30th, 2005, 10:12 AM
#3
Re: public static readonly vs accessor properties
public static readonly is the same as const... and no. I agree with jdt. const's are needed, and its completely worthless to create accessors for constants.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|