//Naming conventions and code-layout.

 

/// <summary>

/// This class is completely bogus

/// </summary>

/// <remarks>

/// MyClass is an example of how Bob Powell manages comments, naming conventions and code-layout

/// </remarks>

class MyClass

{

  //a field

 

  /// <summary>

  /// Private storage for the SomeData property

  /// </summary>

  int _someData;

 

  //A property accessing a field

 

  /// <summary>

  /// Gets and sets some data

  /// </summary>

  /// <remarks>

  /// This is bogus

  /// <font color="red">DEVNOTE: This inserts a red developer note into the remarks section. Other HTML can be used also</font>

  /// </remarks>

  public int SomeData

  {  //<< Braces on their own lines

    //simple accessor

    get{return _someData;}

 

    //complex acessor

    set

    {

      if(value>0 && value<101)

        _someData=value//<<indentation indicates scope

      else

        throw new Exception("Data must be in the range 1-100");

    }

  }

            //<<<<<There is whitespace here

  //A method

  /// <summary>

  /// Just some method

  /// </summary>

  /// <param name="someData">Some bogus data</param>

  /// <remarks>

  /// This is a remark about the method.

  /// </remarks>

  /// <example>

  /// Here is an example of how to use this method.

  /// <code>

  /// MyClass mc=new MyClass();

  /// mc.SomeMethod(21);

  /// </code>

  /// </example>

  public void SomeMethod(int someData) //with a parameter

  {

    //well, this is a strange comment but when I read it in four years time

    //I'll know it was just an example of how to write a comment rather than

    //a particularly interesting algorithm

    _someData=someData*4;

  }

 

  //variables

 

  /// <summary>

  /// This method illustrates how internally scoped variables even have their own naming conventions

  /// </summary>

  /// <param name="stuff">Almost totally bogus</param>

  /// <returns>A message from Bob saying "Goodbye".</returns>

  public string SomeOtherMethod(int stuff)

  {

    int internalStuff=stuff;

 

    //scan coordinates

    //Y by X

    for(int y=0; y<100; y++)

    {

      for(int x=0; x<100; x++)

      {

        //something meaningful happens here

      }

    }

 

    //variables for complex classes

    MyComplexAndCrypticClass ccc=new MyComplexAndCrypticClass();

    PrimaryFoobarThing pft=new PrimaryFoobarThing();

 

    return "Goodbye";

 

  }

 

}

 

 

 

Return to wherever you came from...