Coding Standard and Code Review
-
Anybody got around to putting a Coding Standard together for C# code, that can be used in code reviews. I'd like put one together but I've not written a lot of C# code yet. Does everybody write their code in the style of the MS samples? Michael :-)
-
Anybody got around to putting a Coding Standard together for C# code, that can be used in code reviews. I'd like put one together but I've not written a lot of C# code yet. Does everybody write their code in the style of the MS samples? Michael :-)
The style of the MS samples is what MS proposes as the standard (of course). The only change I've made that I'm aware of is I prefix private variables with _. I stick to one public class or public struct per file, excluding structs created for P/Invoke. If an enum is only used by a class/struct I stick it in the same file at the bottom of the file. Some say I should make an enum part of the class if it is only used by that one class --
public class foo { public enum bar { ... } ... }
-- but I like it being separate so if a later piece of code needs it I don't have to change all references to the typename. Take my standards with a grain of salt though, I'm the only person reading (most of) my source :-P James Sonork ID: 100.11138 - Hasaki "I left there in the morning with their God tucked underneath my arm their half-assed smiles and the book of rules. So I asked this God a question and by way of firm reply, He said - I'm not the kind you have to wind up on Sundays." "Wind Up" from Aqualung, Jethro Tull 1971 -
Anybody got around to putting a Coding Standard together for C# code, that can be used in code reviews. I'd like put one together but I've not written a lot of C# code yet. Does everybody write their code in the style of the MS samples? Michael :-)
Well, you can use the official .Net Design Guidelines as a starting-point. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconnetframeworkdesignguidelines.asp Kevin