Posted By: aza | May 20th, 2004 @ 3:38 AM
page 1 of 1
Comments: 3 | Views: 3163
aza
aza
Hi All,

FxCop displays particular vehemence towards static constructors: it actually displays vehemence towards a lot of things but time is short. The argument proposed by the FxCop documentation is that, "Initializing static data in explicit static constructors results in less performant code.", which is fair enough. But what if the static constructor is being used for more then just initialising static data?

For example I use a static logging class and initialise the logger in the static constructor. The logger is thread safe and I prefer to have a one stop shop for logging to make it for application wide changes. But back to the original question, why does FxCop object to static constructors when they present a valid useful purpose? Is there a reason why thread safe static constructors should be avoided?

Regards,
Aaron
I also have a question about FXCop.. it picks on naming conventions when I have named something that is a 3 letter acronym followed by capitalization of the next work. For instance FTPAddress.. it doesn't like that, but is FtpAddress actually preffered? I have seen some member names in the FCL that are named this way.. but since the rule was for acronyms up to 3 letters you capitalize, I am not sure.
JParrish wrote:
I also have a question about FXCop.. it picks on naming conventions when I have named something that is a 3 letter acronym followed by capitalization of the next work. For instance FTPAddress.. it doesn't like that, but is FtpAddress actually preffered? I have seen some member names in the FCL that are named this way.. but since the rule was for acronyms up to 3 letters you capitalize, I am not sure.


The design guidelines state: "When using acronyms, use Pascal case or camel case for acronyms more than two characters long. For example, use HtmlButton or htmlButton. However, you should capitalize acronyms that consist of only two characters, such as System.IO instead of System.Io". I believe FxCop is trying to enforce those guidelines.
Aha.. that is obvious now. I had thought it said 3 letters.. thanks for the correction =)
page 1 of 1
Comments: 3 | Views: 3163