Coding Standards for C#?
infinite9 asks: "I've been given the task of writing the coding standards for my corporation. I've been in IT for 12 years, so many things are obvious. Recently though, my employer has standardized on C# and .NET, and since I'm new to the technology (isn't everyone?) I'm not sure what to include. I've included a paragraph about signing assemblies with a standard key pair as well as a few other odds and ends. Apart from the obvious statements that apply to any language like good comments, good variable names, and maintainable code, can anyone suggest other C#/.NET related things that I should include?"
It's 10 PM. Do you know if you're un-American?
To work out some standards use what you know from Java, Python or any other language with a C based syntax.
The guys at ICSharpCode (http://www.icsharpcode.net/TechNotes/) have some nice documents on coding styles/standards for coding for #Develop (you don't have to follow them when coding using #Develop)
Also have a look at something like FX Cop from MS (http://www.gotdotnet.com/team/libraries) to help enforce coding standards.
t
I would also stress: use the inline documentation stuff a log (/// comments). Use NDOC to generate documents from the XML output. Make use of the using() {} statement to encourage early resource disposal.
Maybe you'll find this useful: White paper on resource management in components written for the Common Language Runtime (CLR).
-jk
Having an IT guy come up with coding standards is like asking the janitor to design an operating system.
(The fact that he's consulting with Slashdot regarding aspects of his job is kind of a hint.)
....several other readers. Take a look at FxCop.
It will help you check your code for conformance to design guidelines and point out possible usage errors, localization issues, security problems, and possible performance improvements.
Bullshit! That is nothing like how VS formats code. I just copied and pasted and this is how it formatted:
namespace Foo
{
public class Bar
{
void Bar()
{
if (foo)
{
bar(0);
}
else
{
bar(1);
}
}
}
}
I was in your shoes when I was using UltraEdit and the free .NET SDK for development. I had all kinds of macros set up to autogenerate a separate xml file where my comments would be extracted from the code and placed into, while placing the rest of the 40 or so cs files into a dll and running it, etc. I thought that the color coding was help enough with programming. I'd just assumed that VS.Net was just bloat-ware like every other MS dev. env. that I've used in the past.
.Net built-in class libraries in your brain and can compile code with warnings in your head on the fly, VS.Net will greatly speed up the development process. (It's much easier to hit ".", "(", or CTRL+SPACE, than to google MSDN for what I'm looking for.) Aside from all the other features already listed, its integration with VSS is pretty seamless.
However, unless you have the entire
You really have to use it for a day to realize it's potential. All the MS marketing fluff sites don't do it any justice. Ours at work was included with individual MSDN Universal subscriptions for all of our developers. We all got to upgrade from NT and whatever development tools we were using before (VS6.0, HomeSite, UltraEdit, notepad, vim).
THERE IS NO DATA. THERE IS O