Developer Discipline

The objective of coding rules is to reduce confusion among the readers. The key to that is consistency: consistency throughout a project, between projects and between authors.

    * Be consistent ? look at the existing code and make yours fit it.
    * Make the code so simple that its boring to read.
    * Follow .NET naming conventions (see SDK docs)
    * Prefix private fields with a _ character to look like: int _value;
    * Omit private scope declaration unless it makes the code clearer.
    * Use 4 space indents instead of tabs.
    * One class one file.
    * Class files stored in directories to match namespace.
    * Squiggly on same line as construct in all cases including classes and methods.
    * Always use { } even if statement is a single line.

      // good
      if (foobar) {
      } else {

      // bad - ommits { } - error prone
      if (foobar)

      // bad - same reason as above but requires more work to edit
      if (foobar) DoSomething();

      // bad - does not represent logical structure of code
      // read McConnell, Code Complete
      if (foobar)

      // bad - same reason as above
      if (foobar) {
      else {

    * GPL header on every source file.
    * Namespace starts with SourceForge.NAnt
    * Avoid ? : operations in all but the most trivial cases.
    * Avoid assignment in conditionals.
    * Avoid magic numbers, use a nested enum instead.
The above mentioned Coding Conventions are as mentioned at SourceForge [ ]

Structuring Large Solutions
Developer Discipline: Stucturing your solutions,289483,sid26_gci1011711,00.html
101 Samples for VS2005
posted @ Friday, March 9, 2007 1:14 PM

Comments on this entry:

No comments posted yet.

Your comment:

(not displayed)


Live Comment Preview: