Microsoft StyleCop - Source code analysis for formatting and style

by Dominic Zukiewicz 23. July 2008 14:23
Microsoft recently (on my birthday) released a tool to analyse coding structure and formatting. No - its not FxCop - StyleCop analyses syntactical formatting. Let me explain: Background When Microsoft released FxCop, some people cringed. I remember at my previous job when having a code review and the conversation following: Consultant: "Have you FxCop'd it?". Me: "No...." Consultant: "Hahahah - see you in 3 months!" Those days, for me anyway, have gone. I started to use it in my everyday coding and am now pleased I use it without a second thought. In my position with this com... [More]

Tags:

Good practices

Choosing the best way to compare text to empty strings

by Dominic Zukiewicz 3. July 2008 09:45
I don’t know about you, but when I’ve seen some string comparisons, some people use: string text = GetStringFromDB()   if( text != string.Empty ) DoThis(); This looks good, but its actually quite a long running process, as the CLR has to compare both strings character by character. It is much better to use String.IsNullOrEmpty to cater for this, or use .Length == 0 property, as this never changes and is computed when assigned. Here is what the String.IsNullOrEmpty method looks like: public static bool IsNullOrEmpty(string value) { if (value != null) { ... [More]

Tags:

Framework | Good practices

Powered by BlogEngine.NET 1.5.0.7
Theme by Interakting

Interakting

A full service digital agency offering online strategy, design and usability, systems integration and online marketing services that deliver real business benefits and ensure your online objectives are met.

Calendar

<<  March 2010  >>
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar