Geeks With Blogs
SAM|NET »»» technology + aesthetics «««
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) http://home.comcast.net/~lancehunt/CSharp_Coding_Standards.pdf
http://www.idesign.net/idesign/download/IDesign%20CSharp%20Coding%20Standard.zip
    * 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) {
      	DoSomething();
      } else {
      	DoSomethingElse();
      }

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

      // 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)
      {
      	DoSomething();
      }

      // bad - same reason as above
      if (foobar) {
      	DoSomething();
      }
      else {
      	DoSomethingElse();
      }
      			

    * 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 [ http://sourceforge.net/docman/display_doc.php?docid=6080&group_id=31650 ]

Structuring Large Solutions
Developer Discipline: Stucturing your solutions
http://www.javaranch.com/build_standards.jsp
http://www.mikebroberts.com/blog/archive/Tech/ArticlesandPapers/Howtosetupa.NETDevelopmentTree.html
http://www.developer.com/tech/article.php/994991
http://www.ssw.com.au/ssw/Standards/Rules/RulesToBetterLargedotNETProjects.aspx
http://msdn2.microsoft.com/en-us/library/ms998208.aspx
http://msdn2.microsoft.com/en-us/library/ms998215.aspx
http://searchwebservices.techtarget.com/tip/0,289483,sid26_gci1011711,00.html
http://www.code-magazine.com/article.aspx?quickid=0405071&page=7
101 Samples for VS2005
http://msdn2.microsoft.com/en-us/windowsmedia/aa718334.aspx
http://www.code-magazine.com/article.aspx?quickid=0405071&page=1
Posted on Friday, March 9, 2007 1:14 PM Best Practices | Back to top


Comments on this post: Developer Discipline

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Prabhat Samuel | Powered by: GeeksWithBlogs.net