Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should be included in a C# Programming Standard?

I've been tasked to write our department's C# Programming Standard (including guidelines). What sort of standards/guidelines should I include? I've already taken bits from various standards around the net (and pieces from Code Complete), but I'd like hear from developers in the field.

I've already got: Naming Conventions - General/Variables/Classes/Methods/Interfaces/Controls

General Programming Practices - Documentation (comments etc), [WIP]

OO Programming Practices - Encapsulation, [WIP]

What else would be useful? What shouldn't I include?

like image 648
ilitirit Avatar asked Nov 18 '25 22:11

ilitirit


1 Answers

Have you already suggested that everyone reads the "Design Guidelines for Class Library Developers"? That covers the bulk of it. Other than that, I'd want to hammer home:

  • You should very rarely be creating your own structs. Don't think of them as lightweight classes.
  • Structs should never be mutable.
  • Fields should always be private, apart from readonly fields where the type of the field is immutable
  • Only attempt lock-free programming if you're sure that a simpler solution will be too slow - and have evidence!
  • Readability is king
  • Be aware of cultural issues - in particular, read Microsoft's String Handling Recommendations

I'll add more as I think of them...

like image 121
Jon Skeet Avatar answered Nov 21 '25 13:11

Jon Skeet