C# code documentation by@xameeramir
5,691 reads

C# code documentation

Read on Terminal Reader

Too Long; Didn't Read


Company Mentioned

Mention Thumbnail
featured image - C# code documentation
Zameer Ansari HackerNoon profile picture

@xameeramir

Zameer Ansari
react to story with heart

image

credit

The golden rule of code documentation:

Try to document why (code design decisions) and avoid what (code design descriptions).

To keep up with the increasing complexity of the project, it’s very important to document the coding decisions. It’s one of the best practices.

Visual studio provides some elegant ways for code documentation to keep the code understandable. It can also understand the changes that one make on hard code.

Single or multi line comments

  • Short (or long) functional descriptions

    //single line comment

These are necessary to describe functionality in little.

/*multiplelinecomments*/

Avoid them. It is advisable to avoid writing essays about code. The end product shall be code not their long descriptions.

Collapsible regions

  • Summary of the functional block

    #region Some code block

    //some code here    	//some foo bar    	//Fizz Buzz    	//some unicorns    #endregion
    

Regions are collapsible. Just hover over the collapsed region and get a glance.

image

courtesy

Summary

  • Summary of the function or property

    /// <summary>/// Summary description for the function or property goes here/// </summary>

image

courtesy

  • Summary of the function parameter

    /// <param name="TestParameter">Summary description for the parameter goes here </param>

image

courtesy

Visual studio changes this section after change of the parameter name.

image

courtesy

  • Summary of the returning stuff

    ///<returns>Summary description for the function result goes here</returns>

A simple example:

/// <summary>/// Main class of the project/// </summary>class Program{        /// <summary>        /// Main entry point of the program        /// </summary>        /// <param name="args">Command line args</param>        static void Main(string[] args)        {            //Do stuff        }}

RELATED STORIES

L O A D I N G
. . . comments & more!
Hackernoon hq - po box 2206, edwards, colorado 81632, usa