<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Enigma</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Enigma"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Enigma"/>
	<updated>2026-06-10T04:04:18Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=29006</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=29006"/>
		<updated>2009-11-19T00:36:49Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Conclusion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readability of the code an issue. Thus the definition of a good code involves a good self documenting structure and involves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derived form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call involves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Similar to the principles for naming methods, name your variables explicitly as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping structures . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggests that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and parameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
*Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
*Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
* Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
* Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
* Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
* Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
* Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
* Align comments in consecutive lines:&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
* Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
* Be polite:&lt;br /&gt;
Always stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
* Use a consistent style:&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
* Do commenting as you code:&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
* Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
* Always update the comment when the code is updated:&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
* The golden rule of comments: readable code:&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
* Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
Readability is one of the most important characteristics of good code. The use code with good self documentation and comments goes a long way in improving the readability of code.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;br /&gt;
&lt;br /&gt;
[http://devjargon.com/developement/the-art-of-commenting-code/ The Art of Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips for Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://particletree.com/features/successful-strategies-for-commenting-code/ Types of Comments]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=29001</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=29001"/>
		<updated>2009-11-19T00:35:30Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Tips for commenting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readability of the code an issue. Thus the definition of a good code involves a good self documenting structure and involves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derived form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call involves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Similar to the principles for naming methods, name your variables explicitly as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping structures . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggests that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and parameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
*Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
*Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
* Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
* Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
* Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
* Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
* Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
* Align comments in consecutive lines:&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
* Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
* Be polite:&lt;br /&gt;
Always stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
* Use a consistent style:&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
* Do commenting as you code:&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
* Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
* Always update the comment when the code is updated:&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
* The golden rule of comments: readable code:&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
* Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
Readability is one of the most important characteristics of good code. The use of self documenting code and comments, goes a long way in improving the readability of code.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;br /&gt;
&lt;br /&gt;
[http://devjargon.com/developement/the-art-of-commenting-code/ The Art of Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips for Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://particletree.com/features/successful-strategies-for-commenting-code/ Types of Comments]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28984</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28984"/>
		<updated>2009-11-19T00:28:20Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Commenting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readability of the code an issue. Thus the definition of a good code involves a good self documenting structure and involves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derived form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call involves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Similar to the principles for naming methods, name your variables explicitly as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping structures . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggests that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and parameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
*Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
*Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
* Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
* Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
* Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
* Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
* Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
* Align comments in consecutive lines:&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
* Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
* Be polite:&lt;br /&gt;
Always stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
* Use a consistent style:&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
* Do commenting as you code:&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
* Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
* Always update the comment when the code is updated:&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
* The golden rule of comments: readable code:&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
* Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;br /&gt;
&lt;br /&gt;
[http://devjargon.com/developement/the-art-of-commenting-code/ The Art of Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips for Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://particletree.com/features/successful-strategies-for-commenting-code/ Types of Comments]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28983</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28983"/>
		<updated>2009-11-19T00:28:09Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readability of the code an issue. Thus the definition of a good code involves a good self documenting structure and involves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derived form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call involves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Similar to the principles for naming methods, name your variables explicitly as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping structures . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggests that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and parameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
*Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
*Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
* Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
* Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
* Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
* Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
* Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
* Align comments in consecutive lines:&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
* Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
* Be polite:&lt;br /&gt;
Always stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
* Use a consistent style:&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
* Do commenting as you code:&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
* Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
* Always update the comment when the code is updated:&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
* The golden rule of comments: readable code:&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
* Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;br /&gt;
&lt;br /&gt;
[http://devjargon.com/developement/the-art-of-commenting-code/ The Art of Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips for Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://particletree.com/features/successful-strategies-for-commenting-code/ Types of Comments]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28981</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28981"/>
		<updated>2009-11-19T00:27:36Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readability of the code an issue. Thus the definition of a good code involves a good self documenting structure and involves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derived form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call involves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggests that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
*Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
*Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
* Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
* Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
* Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
* Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
* Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
* Align comments in consecutive lines:&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
* Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
* Be polite:&lt;br /&gt;
Always stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
* Use a consistent style:&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
* Do commenting as you code:&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
* Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
* Always update the comment when the code is updated:&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
* The golden rule of comments: readable code:&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
* Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;br /&gt;
&lt;br /&gt;
[http://devjargon.com/developement/the-art-of-commenting-code/ The Art of Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips for Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://particletree.com/features/successful-strategies-for-commenting-code/ Types of Comments]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28979</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28979"/>
		<updated>2009-11-19T00:27:21Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Coding Styles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readability of the code an issue. Thus the definition of a good code involves a good self documenting structure and involves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derived form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggests that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
*Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
*Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
* Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
* Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
* Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
* Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
* Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
* Align comments in consecutive lines:&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
* Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
* Be polite:&lt;br /&gt;
Always stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
* Use a consistent style:&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
* Do commenting as you code:&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
* Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
* Always update the comment when the code is updated:&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
* The golden rule of comments: readable code:&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
* Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;br /&gt;
&lt;br /&gt;
[http://devjargon.com/developement/the-art-of-commenting-code/ The Art of Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips for Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://particletree.com/features/successful-strategies-for-commenting-code/ Types of Comments]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28978</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28978"/>
		<updated>2009-11-19T00:27:06Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Self-Documentation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readability of the code an issue. Thus the definition of a good code involves a good self documenting structure and involves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derived form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
*Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
*Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
* Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
* Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
* Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
* Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
* Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
* Align comments in consecutive lines:&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
* Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
* Be polite:&lt;br /&gt;
Always stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
* Use a consistent style:&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
* Do commenting as you code:&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
* Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
* Always update the comment when the code is updated:&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
* The golden rule of comments: readable code:&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
* Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;br /&gt;
&lt;br /&gt;
[http://devjargon.com/developement/the-art-of-commenting-code/ The Art of Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips for Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://particletree.com/features/successful-strategies-for-commenting-code/ Types of Comments]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28972</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28972"/>
		<updated>2009-11-19T00:26:54Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readability of the code an issue. Thus the definition of a good code involves a good self documenting structure and involves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
*Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
*Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
* Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
* Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
* Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
* Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
* Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
* Align comments in consecutive lines:&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
* Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
* Be polite:&lt;br /&gt;
Always stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
* Use a consistent style:&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
* Do commenting as you code:&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
* Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
* Always update the comment when the code is updated:&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
* The golden rule of comments: readable code:&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
* Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;br /&gt;
&lt;br /&gt;
[http://devjargon.com/developement/the-art-of-commenting-code/ The Art of Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips for Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://particletree.com/features/successful-strategies-for-commenting-code/ Types of Comments]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28532</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28532"/>
		<updated>2009-11-18T19:50:17Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
* Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
* Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
* Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
* Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
* Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
* Align comments in consecutive lines:&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
* Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
* Be polite:&lt;br /&gt;
Always stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
* Use a consistent style:&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
* Do commenting as you code:&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
* Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
* Always update the comment when the code is updated:&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
* The golden rule of comments: readable code:&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
* Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;br /&gt;
&lt;br /&gt;
[http://devjargon.com/developement/the-art-of-commenting-code/ The Art of Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips for Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://particletree.com/features/successful-strategies-for-commenting-code/ Types of Comments]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28531</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28531"/>
		<updated>2009-11-18T19:49:47Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
* Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
* Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
* Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
* Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
* Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
* Align comments in consecutive lines:&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
* Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
* Be polite:&lt;br /&gt;
Always stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
* Use a consistent style:&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
* Do commenting as you code:&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
* Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
* Always update the comment when the code is updated:&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
* The golden rule of comments: readable code:&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
* Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;br /&gt;
&lt;br /&gt;
[http://devjargon.com/developement/the-art-of-commenting-code/ The Art of Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips for Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://particletree.com/features/successful-strategies-for-commenting-code/ Types of code commenting]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28530</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28530"/>
		<updated>2009-11-18T19:48:41Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Four major types of comments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
* Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
* Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
* Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
* Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
* Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
* Align comments in consecutive lines:&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
* Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
* Be polite:&lt;br /&gt;
Always stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
* Use a consistent style:&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
* Do commenting as you code:&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
* Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
* Always update the comment when the code is updated:&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
* The golden rule of comments: readable code:&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
* Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;br /&gt;
&lt;br /&gt;
[http://devjargon.com/developement/the-art-of-commenting-code/ The Art of Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips for Commenting]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28529</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28529"/>
		<updated>2009-11-18T19:47:50Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Tips for commenting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
1. Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
2. Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
3. Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
4. Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
* Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
* Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
* Align comments in consecutive lines:&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
* Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
* Be polite:&lt;br /&gt;
Always stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
* Use a consistent style:&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
* Do commenting as you code:&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
* Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
* Always update the comment when the code is updated:&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
* The golden rule of comments: readable code:&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
* Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;br /&gt;
&lt;br /&gt;
[http://devjargon.com/developement/the-art-of-commenting-code/ The Art of Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips for Commenting]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28528</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28528"/>
		<updated>2009-11-18T19:47:12Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Tips for commenting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
1. Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
2. Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
3. Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
4. Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
** Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
* Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
3. Align comments in consecutive lines:&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
4. Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
5. Be polite:&lt;br /&gt;
Always stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
6. Use a consistent style:&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
7.Do commenting as you code:&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
8. Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
9. Always update the comment when the code is updated:&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
10. The golden rule of comments: readable code:&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
11.Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;br /&gt;
&lt;br /&gt;
[http://devjargon.com/developement/the-art-of-commenting-code/ The Art of Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips for Commenting]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28527</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28527"/>
		<updated>2009-11-18T19:47:00Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Tips for commenting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
1. Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
2. Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
3. Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
4. Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
-&amp;gt; Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
* Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
3. Align comments in consecutive lines:&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
4. Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
5. Be polite:&lt;br /&gt;
Always stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
6. Use a consistent style:&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
7.Do commenting as you code:&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
8. Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
9. Always update the comment when the code is updated:&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
10. The golden rule of comments: readable code:&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
11.Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;br /&gt;
&lt;br /&gt;
[http://devjargon.com/developement/the-art-of-commenting-code/ The Art of Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips for Commenting]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28526</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28526"/>
		<updated>2009-11-18T19:46:37Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Tips for commenting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
1. Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
2. Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
3. Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
4. Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
* Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
* Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
3. Align comments in consecutive lines:&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
4. Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
5. Be polite:&lt;br /&gt;
Always stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
6. Use a consistent style:&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
7.Do commenting as you code:&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
8. Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
9. Always update the comment when the code is updated:&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
10. The golden rule of comments: readable code:&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
11.Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;br /&gt;
&lt;br /&gt;
[http://devjargon.com/developement/the-art-of-commenting-code/ The Art of Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips for Commenting]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28524</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28524"/>
		<updated>2009-11-18T19:46:15Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
1. Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
2. Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
3. Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
4. Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
1. Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
2. Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
3. Align comments in consecutive lines:&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
4. Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
5. Be polite:&lt;br /&gt;
Always stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
6. Use a consistent style:&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
7.Do commenting as you code:&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
8. Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
9. Always update the comment when the code is updated:&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
10. The golden rule of comments: readable code:&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
11.Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;br /&gt;
&lt;br /&gt;
[http://devjargon.com/developement/the-art-of-commenting-code/ The Art of Commenting]&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips for Commenting]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28523</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28523"/>
		<updated>2009-11-18T19:45:34Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
1. Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
2. Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
3. Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
4. Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
1. Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
2. Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
3. Align comments in consecutive lines:&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
4. Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
5. Be polite:&lt;br /&gt;
Always stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
6. Use a consistent style:&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
7.Do commenting as you code:&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
8. Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
9. Always update the comment when the code is updated:&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
10. The golden rule of comments: readable code:&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
11.Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;br /&gt;
&lt;br /&gt;
[http://devjargon.com/developement/the-art-of-commenting-code/]&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28522</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28522"/>
		<updated>2009-11-18T19:44:13Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Tips for commenting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
1. Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
2. Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
3. Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
4. Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
1. Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
2. Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
3. Align comments in consecutive lines:&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
4. Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
5. Be polite:&lt;br /&gt;
Always stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
6. Use a consistent style:&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
7.Do commenting as you code:&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
8. Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
9. Always update the comment when the code is updated:&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
10. The golden rule of comments: readable code:&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
11.Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28521</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28521"/>
		<updated>2009-11-18T19:43:13Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Tips for commenting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
1. Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
2. Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
3. Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
4. Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
1. Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
2. Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
 Context ctx = new ApplicationContext(); &lt;br /&gt;
 ctx.BeginTransaction();&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
3. Align comments in consecutive lines&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
4. Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
5. Be polite&lt;br /&gt;
All stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
6. Use a consistent style&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
7.Do commenting as you code&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
8. Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
9. Always update the comment when the code is updated.&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
10. The golden rule of comments: readable code&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
11.Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28520</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28520"/>
		<updated>2009-11-18T19:42:51Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Tips for commenting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
1. Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
2. Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
3. Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
4. Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
1. Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
 •	For each class, include a brief description, author and date of last modification &lt;br /&gt;
 •	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
2. Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
Context ctx = new ApplicationContext(); &lt;br /&gt;
ctx.BeginTransaction();&lt;br /&gt;
. . .&lt;br /&gt;
&lt;br /&gt;
3. Align comments in consecutive lines&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
4. Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
5. Be polite&lt;br /&gt;
All stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
6. Use a consistent style&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
7.Do commenting as you code&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
8. Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
9. Always update the comment when the code is updated.&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
10. The golden rule of comments: readable code&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
11.Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28518</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28518"/>
		<updated>2009-11-18T19:42:29Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Tips for commenting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
1. Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
2. Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
3. Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
4. Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
1. Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
•	For each class, include a brief description, author and date of last modification &lt;br /&gt;
•	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
&lt;br /&gt;
2. Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
Context ctx = new ApplicationContext(); &lt;br /&gt;
ctx.BeginTransaction();&lt;br /&gt;
. . .&lt;br /&gt;
&lt;br /&gt;
3. Align comments in consecutive lines&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
 const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
 const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
&lt;br /&gt;
4. Avoid obvious comments:&lt;br /&gt;
Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
 if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
5. Be polite&lt;br /&gt;
All stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
6. Use a consistent style&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
&lt;br /&gt;
7.Do commenting as you code&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
8. Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
&lt;br /&gt;
9. Always update the comment when the code is updated.&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
&lt;br /&gt;
10. The golden rule of comments: readable code&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
 Calculator calc = new Calculator();&lt;br /&gt;
 calc.Set(0);&lt;br /&gt;
 calc.Add(10);&lt;br /&gt;
 calc.Multiply(2);&lt;br /&gt;
 calc.Subtract(4);&lt;br /&gt;
 Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
&lt;br /&gt;
11.Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28516</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28516"/>
		<updated>2009-11-18T19:41:07Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Tips for commenting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
1. Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
2. Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
3. Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
4. Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
1. Comment each level:&lt;br /&gt;
This is the first important rule that you need to remember. Comment each code block, using a uniform approach for each level.  For example: &lt;br /&gt;
•	For each class, include a brief description, author and date of last modification &lt;br /&gt;
•	For each method, include a description of its purpose, functions, parameters and results&lt;br /&gt;
Adopting comment standards is important when working with a team.  Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task.&lt;br /&gt;
2. Paragraph Comments:&lt;br /&gt;
On top of each block of code that is there in the program, add a comment explaining what exactly the following block of code will do.&lt;br /&gt;
 // Check that all data records&lt;br /&gt;
 // are correct &lt;br /&gt;
 foreach (Record record in records) &lt;br /&gt;
 {&lt;br /&gt;
     if (rec.checkStatus()==Status.OK)&lt;br /&gt;
     { &lt;br /&gt;
        . . . &lt;br /&gt;
     } &lt;br /&gt;
 } &lt;br /&gt;
 // Now we begin to perform &lt;br /&gt;
 // transactions &lt;br /&gt;
Context ctx = new ApplicationContext(); &lt;br /&gt;
ctx.BeginTransaction();&lt;br /&gt;
. . .&lt;br /&gt;
3. Align comments in consecutive lines&lt;br /&gt;
If there are codes in consecutive lines of the program, align them such that they start at the same point. This makes the program more readable.&lt;br /&gt;
const MAX_ITEMS = 10; // maximum number of packets &lt;br /&gt;
const MASK = 0x1F;    // mask bit TCP &lt;br /&gt;
You can use tabs to align them together. Also make sure you leave a small gap between where the code ends and the commenting begins.&lt;br /&gt;
4. Avoid obvious comments:&lt;br /&gt;
&lt;br /&gt;
 Avoid obvious comments in the code. This will only clutter up the code and distracts the reader with details that can be easily deduced from the code.&lt;br /&gt;
&lt;br /&gt;
if (a == 5)      // if a equals 5 &lt;br /&gt;
    counter = 0; // set the counter to zero&lt;br /&gt;
&lt;br /&gt;
5. Be polite&lt;br /&gt;
&lt;br /&gt;
All stay away from making any rude comments to the reader like,  “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.”  Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted.&lt;br /&gt;
&lt;br /&gt;
6. Use a consistent style&lt;br /&gt;
Always use a consistent style of coding. Its always easier for reader to understand the code and documentation if the comments are in consistent style throughout the code.&lt;br /&gt;
7.Do commenting as you code&lt;br /&gt;
Its always good to make it a habit to comment the code as you write it. Its much easier to do the commenting it when the code is still fresh in your memory.&lt;br /&gt;
public void ProcessOrder() &lt;br /&gt;
{&lt;br /&gt;
    // Make sure the products are available&lt;br /&gt;
    // Check that the customer is valid &lt;br /&gt;
    // Send the order to the store &lt;br /&gt;
    // Generate bill &lt;br /&gt;
}&lt;br /&gt;
8. Comments should always be written as if they for you as much as it is for others:&lt;br /&gt;
When it comes to commenting code, think not only about the developers who will maintain your code in the future or reuse it later, but also think about yourself.  In the words of the great Phil Haack:&lt;br /&gt;
“As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.”&lt;br /&gt;
9. Always update the comment when the code is updated.&lt;br /&gt;
The comment needs to be updated whenever the code is updated. If this is not followed, the comments might end up confusing them and prove to be a curse to the developers rather than helping them. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant.&lt;br /&gt;
10. The golden rule of comments: readable code&lt;br /&gt;
Your code should speak for itself. Self explanatory code will make the life of the future reader of your code a lot easier.&lt;br /&gt;
Calculator calc = new Calculator();&lt;br /&gt;
calc.Set(0);&lt;br /&gt;
calc.Add(10);&lt;br /&gt;
calc.Multiply(2);&lt;br /&gt;
calc.Subtract(4);&lt;br /&gt;
Console.WriteLine( &amp;quot;Result: {0}&amp;quot;, calc.Get() ); &lt;br /&gt;
11.Get a friend to look it over:&lt;br /&gt;
Finally have someone else who has never seen the code go over it. The point of this is if they have any questions about any parts of your code you should comment that part better.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28515</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28515"/>
		<updated>2009-11-18T19:40:17Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Four major types of comments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
&lt;br /&gt;
1. Code Commenting - This refers to writing descriptive variable names that are self explanatory.&lt;br /&gt;
&lt;br /&gt;
 function addUserToDatabase(userName, userAge)&lt;br /&gt;
&lt;br /&gt;
2. Inline Commenting - Specifically, these types of comments come at the end of a line of code, but we can also use this term to refer to comments inside of a function as well.&lt;br /&gt;
&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     var nStrength = document.getElementById(&amp;quot;enemyStrength&amp;quot;).value; // grab current enemy strength&lt;br /&gt;
 &lt;br /&gt;
     // subtract user size : small = 1, medium = 2, large = 3&lt;br /&gt;
     var nDamage = (nStrength * 3) ï¿½ cUser.nSize;&lt;br /&gt;
     return cUser.nCurrentHitPoints ï¿½ nDamage;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
3. Function Commenting - This type of commenting is found on the lines above a function, and reveals all of the necessary details about that function.&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  * Summary:      Calculate hitpoints after attack using formula&lt;br /&gt;
  *               new = current ï¿½ ((enemyStrength*3) ï¿½ size)&lt;br /&gt;
  * Parameters:   cUser ï¿½ object containing hero's stats&lt;br /&gt;
  * Return:       Boolean indicating life or death&lt;br /&gt;
  */&lt;br /&gt;
 function calculateHitPoints(cUser) {&lt;br /&gt;
     ï¿½&lt;br /&gt;
 } // end calculateHitPoints&lt;br /&gt;
&lt;br /&gt;
4. Class / Page Commenting - Comments that refer to an entire page or top level object fall into this category. Usually these comments include a broad overview, last edit date, associated files, author, and contact information.&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 Title : &lt;br /&gt;
 Author : &lt;br /&gt;
 URL : &lt;br /&gt;
 Description : &lt;br /&gt;
 Created : &lt;br /&gt;
 Modified : &lt;br /&gt;
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28514</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28514"/>
		<updated>2009-11-18T19:39:17Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Commenting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
 /*These are two pre-defined header files that&lt;br /&gt;
 I've included I'm going to be using printf()&lt;br /&gt;
 from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
 from stdlib.h*/&lt;br /&gt;
 #include &lt;br /&gt;
 #incude &lt;br /&gt;
 &lt;br /&gt;
 /*This function takes in the two variables&lt;br /&gt;
 (x and y) and calculates the Distance&lt;br /&gt;
 between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
 checks in the code but then decided&lt;br /&gt;
 against it. They'll be added in version 1.1 */&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 //The function where the program starts.&lt;br /&gt;
 int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28513</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28513"/>
		<updated>2009-11-18T19:38:40Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Commenting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
&lt;br /&gt;
Too Little&lt;br /&gt;
&lt;br /&gt;
 #include &lt;br /&gt;
 #include  &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
/*These are two pre-defined header files that&lt;br /&gt;
I've included I'm going to be using printf()&lt;br /&gt;
from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
from stdlib.h*/&lt;br /&gt;
#include &lt;br /&gt;
#incude &lt;br /&gt;
 &lt;br /&gt;
/*This function takes in the two variables&lt;br /&gt;
(x and y) and calculates the Distance&lt;br /&gt;
between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
checks in the code but then decided&lt;br /&gt;
against it. They'll be added in version 1.1 */&lt;br /&gt;
int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//The function where the program starts.&lt;br /&gt;
int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28511</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28511"/>
		<updated>2009-11-18T19:38:11Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Commenting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
Too Little&lt;br /&gt;
#include &lt;br /&gt;
#include &lt;br /&gt;
 &lt;br /&gt;
 //This is a function&lt;br /&gt;
 int calculateDistance(int x, int y){&lt;br /&gt;
      . . . .} &lt;br /&gt;
 //Main function&lt;br /&gt;
 int main(){&lt;br /&gt;
      int x=0;&lt;br /&gt;
      int y=2;&lt;br /&gt;
      calculateDistance(x, y);&lt;br /&gt;
      printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
      return EXIT_SUCCESS;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
/*These are two pre-defined header files that&lt;br /&gt;
I've included I'm going to be using printf()&lt;br /&gt;
from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
from stdlib.h*/&lt;br /&gt;
#include &lt;br /&gt;
#incude &lt;br /&gt;
 &lt;br /&gt;
/*This function takes in the two variables&lt;br /&gt;
(x and y) and calculates the Distance&lt;br /&gt;
between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
checks in the code but then decided&lt;br /&gt;
against it. They'll be added in version 1.1 */&lt;br /&gt;
int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//The function where the program starts.&lt;br /&gt;
int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28510</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28510"/>
		<updated>2009-11-18T19:37:12Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Commenting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
Even while documenting a code we need to take care that we neither comment the code way too much nor should be too less that its meaningless to the reader. Lets first take a look take a look at the different approaches to commenting; too much and too little:&lt;br /&gt;
Too Little&lt;br /&gt;
#include &lt;br /&gt;
#include &lt;br /&gt;
 &lt;br /&gt;
//This is a function&lt;br /&gt;
int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//Main function&lt;br /&gt;
int main(){&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The above comment has way too little information for the reader to make any meaning out of it.&lt;br /&gt;
&lt;br /&gt;
Too Much&lt;br /&gt;
&lt;br /&gt;
/*These are two pre-defined header files that&lt;br /&gt;
I've included I'm going to be using printf()&lt;br /&gt;
from stdio.h and then I'll be usingEXIT_SUCCESS&lt;br /&gt;
from stdlib.h*/&lt;br /&gt;
#include &lt;br /&gt;
#incude &lt;br /&gt;
 &lt;br /&gt;
/*This function takes in the two variables&lt;br /&gt;
(x and y) and calculates the Distance&lt;br /&gt;
between the two. In the end it will return an&lt;br /&gt;
 integer.  I thought I'd include a few error&lt;br /&gt;
checks in the code but then decided&lt;br /&gt;
against it. They'll be added in version 1.1 */&lt;br /&gt;
int calculateDistance(int x, int y){&lt;br /&gt;
     . . . .&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
//The function where the program starts.&lt;br /&gt;
int main(){&lt;br /&gt;
     //These are the two variables use.&lt;br /&gt;
     int x=0;&lt;br /&gt;
     int y=2;&lt;br /&gt;
 &lt;br /&gt;
     //Call the the calculateDistance function&lt;br /&gt;
     calculateDistance(x, y);&lt;br /&gt;
     //Prints that the function was a success&lt;br /&gt;
     printf(&amp;quot;SUCCESS&amp;quot;);&lt;br /&gt;
     //Exits the program&lt;br /&gt;
     return EXIT_SUCCESS;&lt;br /&gt;
     //End of the main function&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
And this code has way too much information. This is unnecessary and makes the program look huge and cluttered up. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28507</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28507"/>
		<updated>2009-11-18T19:35:15Z</updated>

		<summary type="html">&lt;p&gt;Enigma: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
===Four major types of comments===&lt;br /&gt;
===Tips for commenting===&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28506</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28506"/>
		<updated>2009-11-18T19:33:50Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Commenting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28505</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 14 rd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_14_rd&amp;diff=28505"/>
		<updated>2009-11-18T19:33:30Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Commenting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Principle of Self-Documentation=&lt;br /&gt;
=Introduction=&lt;br /&gt;
A good code can be defined as a code that has a good structure and design, correct algorithm used and a good flow to the program. Good code is not replete with question mark colon operators and pointer arithmetic, or at least not when the code doesn't need to be optimized to save a few seconds every few months of operation. The algorithm may be too complex and function names may be esoteric . This makes readablility of the code an issue. Thus the defenition of a good code involves a good self documenting sturcture and invloves many comments to aid the user or developer in understanding the code .&lt;br /&gt;
&lt;br /&gt;
=Self-Documentation=&lt;br /&gt;
Self documentation of the code invloves using two methods &lt;br /&gt;
*1. '''Coding style'''&lt;br /&gt;
One of the major goals when embarking on a development project is to structure the application such that the code documents itself.   &lt;br /&gt;
Thus if all the comments disappeared , the code should still be understandable to the developer&lt;br /&gt;
&lt;br /&gt;
*2. '''Commenting'''&lt;br /&gt;
To make the code completely understandable the use of good code documentation is not enough . There is the need to give explanation of the working and the flow which may not be easily derieved form the code itself .Explanation of an algorithm can only be done with the use of comments. &lt;br /&gt;
&lt;br /&gt;
==Coding Styles==&lt;br /&gt;
The biggest concept of self documentation is the naming itself .The is basically two rules for that one has to follow in order to ensure that the code is self documenting .&lt;br /&gt;
&lt;br /&gt;
*If it looks like a cow and acts like a cow, call it a cow. &lt;br /&gt;
*Once you call it a cow, make sure you always call it a cow.&lt;br /&gt;
&lt;br /&gt;
In other words , the naming should be as meaningful as possible and the developer should stick to it trying not to step out of convention. The abbreviations used in the code should also be those that are commonly accepted . &lt;br /&gt;
&lt;br /&gt;
 naming message as msg and sticking to it is a good coding style&lt;br /&gt;
&lt;br /&gt;
 naming message as mesg,msg,mess,msge throughout the code will make understanding of the code difficult&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
When trying to name a method , try to describe the intent in the name itslef . This enables the developer to understand the code and the use of the function call in the program. &lt;br /&gt;
&lt;br /&gt;
 user.GetID();&lt;br /&gt;
 user.Get();&lt;br /&gt;
 product.GetAvg();&lt;br /&gt;
&lt;br /&gt;
Understanding the method calls by just looking at the code is difficult .The reader to actually drill into the logic to determine what the method actually does.&lt;br /&gt;
&lt;br /&gt;
 user.getcustomerID();&lt;br /&gt;
 user.Getnextcustomer();&lt;br /&gt;
 product.GetAveragePrice();&lt;br /&gt;
&lt;br /&gt;
The method calls makes for explanation of the logic more clear . The function names explain themself what the call invloves.&lt;br /&gt;
&lt;br /&gt;
Another advantage to implementing this type of specific naming in your code is that it can give you an excellent heads up when a method is trying to do too much.When you are attempting to name a method and you find it difficult because of the scope of the method you should definitely examine it and see if you can break it up into smaller more specific pieces.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
&lt;br /&gt;
Simliar to the principles for naming methods, name your variables explicitely as to what they accomplish.  The worst case scenario of this would be using a variable &amp;quot;d&amp;quot; which tells me absolutely nothing.  Slightly less harsh would be using &amp;quot;dt, dte, or date&amp;quot;.  What is most beneficial to the reader is using a name like &amp;quot;CurrentDate&amp;quot; or &amp;quot;MeetingDate&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another example is the use of i,j in looping sturctres . &lt;br /&gt;
&lt;br /&gt;
 for i = 1 to 7&lt;br /&gt;
&lt;br /&gt;
The code suggestst that there is looping structure here ,but nothing more&lt;br /&gt;
&lt;br /&gt;
 for dayInWeek = 1 to NUM_DAYS_IN_WEEK&lt;br /&gt;
&lt;br /&gt;
Thus by the use of specific variables and prameters the loop structure is now clear in terms of its use in the code.Although the coding style becomes more verbose , it will aid in better understanding of the code even for the developer when he returns to add or extend  the code .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Commenting==&lt;br /&gt;
In a software development, in-code documentation is a very important aspect of the code. Program comments within and between modules and procedures usually convey information about the program, such as the functionality, design decisions, assumptions, declarations, algorithms, nature of input and output data, and reminder notes. Almost all the source code will need to be referred back in back in the future or it might also need to be reused. In any case the document that is provided is like a specification or a literal form of the code for any reader using it in the future. Without a good documentation, the reader will end up wasting a lot of time understanding the code or make dangerous assumption and misinterpret the code.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://www.devtopics.com/13-tips-to-comment-your-code/ Tips to commenting your code]&lt;br /&gt;
&lt;br /&gt;
[http://www.cprogramming.com/tutorial/comments.html Commenting styles]&lt;br /&gt;
&lt;br /&gt;
[http://codebetter.com/blogs/eric.wise/archive/2005/12/06/135418.aspx Code Self Documentation]&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_3_bd&amp;diff=25606</id>
		<title>CSC/ECE 517 Fall 2009/wiki2 3 bd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_3_bd&amp;diff=25606"/>
		<updated>2009-10-11T00:03:20Z</updated>

		<summary type="html">&lt;p&gt;Enigma: /* Conclusion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Synchronizer token pattern== &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Web application developers and designers face the problem with maintaining normal flow of control when multiple form submissions are made in a website .&lt;br /&gt;
This situation typically occurs when a user clicks more than once on a submit button before the response is sent back or when a client accesses a view by returning to a previously bookmarked page. Control flow sequence is particularly important to preserve when form submission involves transaction processing on the server. There are many solutions to the situation ,some websites just warn the user not to submit twice once a submission is made and to wait for the response .In other cases we have client side and server side solutions to the problem .Server side solution being more reliable than client side .In the client side model the button is disabled based on a flag which is set  once first submission is performed .Below we discuss some the ways this is handled in different in&lt;br /&gt;
different languages -&lt;br /&gt;
&lt;br /&gt;
==Java==&lt;br /&gt;
&lt;br /&gt;
Java uses the server side solution to solve this problem .The basic idea is to set a token in a session variable before returning a transactional page to the client. This page carries the token inside a hidden field. Upon submission, request processing first tests for the presence of a valid token in the request parameter by comparing it with the one registered in the session. If the token is valid, processing can continue normally, otherwise an alternate course of action is taken. After testing, the token resets to null to prevent subsequent submissions until a new token is saved in the session, which must be done at the appropriate time based on the desired application flow of control. In other words, the one-time privilege to submit data is given to one specific instance of a view.&lt;br /&gt;
&amp;lt;p&amp;gt; Based on the above, the solution appears complete. But an element is missing: how do we specify/implement the alternate course of action when an invalid token is detected. In fact, given the case where the submit button is reclicked, the second request will cause the loss of the first response containing the expected result. The thread that executes the first request still runs, but has no means of providing its response to the browser. Hence, the user may be left with the impression that the transaction did not complete, while in reality, it may have successfully completed.This tip's proposed strategy builds on the Struts framework to provide a complete solution that prevents duplicate submission and still ensures the display of a response that represents the original request's outcome. The proposed implementation involves the abstract class SynchroAction, which actions can extend to behave in the specified synchronized manner. This class overrides the Action.perform() method and provides an abstract performSynchro() method with the same arguments. Below is the example implementation in Java using struts &amp;lt;/p&amp;gt;&lt;br /&gt;
Eg Code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public final ActionForward perform(ActionMapping mapping,&lt;br /&gt;
ActionForm form,&lt;br /&gt;
HttpServletRequest request,&lt;br /&gt;
HttpServletResponse response) throws IOException, ServletException &lt;br /&gt;
{ HttpSession session = request.getSession();&lt;br /&gt;
 ActionForward forward = null;&lt;br /&gt;
 if (isTokenValid(request)) &lt;br /&gt;
{ &lt;br /&gt;
 try { &lt;br /&gt;
session.setAttribute(FORM_KEY, form);&lt;br /&gt;
 session.setAttribute(FORWARD_KEY, forward);&lt;br /&gt;
 ActionErrors errors = (ActionErrors) request.getAttribute(Action.ERROR_KEY);&lt;br /&gt;
 if (errors != null &amp;amp;&amp;amp; !errors.empty()) &lt;br /&gt;
{ &lt;br /&gt;
 saveToken(request); &lt;br /&gt;
 } &lt;br /&gt;
 session.setAttribute(ERRORS_KEY, errors); &lt;br /&gt;
 session.setAttribute(COMPLETE_KEY, &amp;quot;true&amp;quot;); } &lt;br /&gt;
catch (IOException e)&lt;br /&gt;
 { &lt;br /&gt;
 throw e; &lt;br /&gt;
 } &lt;br /&gt;
catch (ServletException e) &lt;br /&gt;
{ &lt;br /&gt;
 session.setAttribute(COMPLETE_KEY, &amp;quot;true&amp;quot;); &lt;br /&gt;
 throw e; } } &lt;br /&gt;
&lt;br /&gt;
else { &lt;br /&gt;
 { &lt;br /&gt;
throw it if (e != null) { if (e instanceof IOException) { throw (IOException) e; } &lt;br /&gt;
else if (e instanceof ServletException) &lt;br /&gt;
{ throw (ServletException) e; &lt;br /&gt;
} } context if (&amp;quot;request&amp;quot;.equals(mapping.getScope())) &lt;br /&gt;
{ request.setAttribute(mapping.getAttribute(), f); } &lt;br /&gt;
&lt;br /&gt;
else { session.setAttribute(mapping.getAttribute(), f); } &lt;br /&gt;
(ActionErrors) session.getAttribute(ERRORS_KEY)); &lt;br /&gt;
session.getAttribute(FORWARD_KEY); } &lt;br /&gt;
else { &lt;br /&gt;
 return forward; }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As we can see from the above code that for a valid token the protected action is performed only once ,while the action is being performed any other requests are received then &lt;br /&gt;
they are directed to performInvalidToken() method until the action is completed ,this method simply returns an ActionForward named &amp;quot;synchroerror&amp;quot; ,this should lead to a form with a button for continue , this just resubmits without any parameters and nothing happens until action of first form submission  is completed .When the action completes, it stores its forward, form, exception, and errors, if any, in the session, and it sets a flag to indicate it has completed. The first request coming after the action completion will get the forward, form, exception, and errors from the session and continue as if it was the first request itself.&lt;br /&gt;
&lt;br /&gt;
==PHP==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following method is one of the ways of creating a Synchronous token pattern&lt;br /&gt;
&lt;br /&gt;
The below given code needs to be added to ur code&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
session_start();&lt;br /&gt;
$secret=md5(uniqueid(rand(), true));&lt;br /&gt;
$_SESSION['FORM_SECRET']=$secret;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here uniqueid() is used to create Unique ID. Then md5() is used to create 32 character hash of this Unique ID. This unique id is stored in the session for later use. We also need to use a different session variable for each form.&lt;br /&gt;
&lt;br /&gt;
Then we add a hidden field anywhere in the form using the below given code.&lt;br /&gt;
&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;form_secret&amp;quot; id=&amp;quot;form_secret&amp;quot; &lt;br /&gt;
value=&amp;quot;&amp;lt;?php echo $_SESSION['FORM_SECRET'];?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
we need to compare the value of the hidden field with the value stored in the session. If the value is the same, that means its the first time. Hence process the form data. Now unset the values stored in this session. now when the user refreshes the page, the code for processing form will be skipped. It can be done as given below&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
session_start();&lt;br /&gt;
//get the hidden value&lt;br /&gt;
$form_secret=$_POST['form_secret'];&lt;br /&gt;
if(isset($_SESSION['FORM_SECRET'])) {&lt;br /&gt;
if(strcasecmp($form_secret,$_SESSION['FORM_SECRET'])===0) {&lt;br /&gt;
/*We need to have the form submission code here&lt;br /&gt;
*/&lt;br /&gt;
unset($_SESSION['FORM_SECRET']);&lt;br /&gt;
}else {&lt;br /&gt;
//this is the condition of key which is invalid&lt;br /&gt;
}&lt;br /&gt;
}else {&lt;br /&gt;
//this is the case where is secret key is no there&lt;br /&gt;
echo 'Form data has been processed once!';&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==JavaScript== &lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;   Java Script uses two methods to prevent Duplicate form submissions .The first method disables the button and the second method uses cookies to prevent multiple submissions.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Eg:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
a.&lt;br /&gt;
&amp;lt;SCRIPT LANGUAGE=&amp;quot;JavaScript&amp;quot; TYPE=&amp;quot;text/JavaScript&amp;quot;&amp;gt; &lt;br /&gt;
 function formControl(submitted)&lt;br /&gt;
 { if(submitted==&amp;quot;1&amp;quot;) &lt;br /&gt;
 { commentForm.Submit.disabled=true alert&lt;br /&gt;
(&amp;quot;Thanks for your comments!&amp;quot;) } } &amp;lt;/SCRIPT&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
The JavaScript event that fires this script is the onClick event. You're telling it to disable the SUBMIT button after the button is clicked. At that point, the button value equals &amp;quot;1.&amp;quot;&lt;br /&gt;
We included a JavaScript ALERT box in this example so that you'll know the form is working. &lt;br /&gt;
To tie this JavaScript to our form, we change the form's SUBMIT button to call the JavaScript function. This is done by adding an onClick event to the appropriate INPUT tag, as shown below.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;FORM action=&amp;quot;&amp;quot; method=&amp;quot;post&amp;quot; enctype=&amp;quot;text/plain&amp;quot; name=&amp;quot;commentForm&amp;quot;&amp;gt; &lt;br /&gt;
 How did you find our site? &amp;lt;input type=&amp;quot;text&amp;quot; maxlength=&amp;quot;30&amp;quot; size=&amp;quot;20&amp;quot;&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt; &lt;br /&gt;
 &amp;lt;input type=&amp;quot;submit&amp;quot; name=&amp;quot;Submit&amp;quot; value=&amp;quot;Send Comments and Get a Cookie&amp;quot; onClick=&amp;quot;formControl(1)&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;/FORM&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The problem with this approach is only Internet explorer supports the disable option ,so it is browser dependent.&amp;lt;/p&amp;gt;&lt;br /&gt;
 &amp;lt;p&amp;gt; Below is another approach in java script using cookies in browser&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
b.&lt;br /&gt;
&lt;br /&gt;
The Below code has to be inserted into head section of our code &lt;br /&gt;
&lt;br /&gt;
&amp;lt;script&amp;gt; &amp;lt;!-- // give feedback to the respondent about the state of their submission function AllowNoDups() &lt;br /&gt;
{ var cookie_ls = document.cookie; &lt;br /&gt;
 if (cookie_ls.indexOf(document.location) &amp;gt; -1) &lt;br /&gt;
 { alert(&amp;quot;You've already submitted your answers. Thank you for your interest! &amp;quot;);&lt;br /&gt;
 return false; } &lt;br /&gt;
 else { document.cookie = window.location.href + &amp;quot; from &amp;quot; + document.referrer + &amp;quot;; &lt;br /&gt;
path=/; &lt;br /&gt;
expires=Thu, 23-Aug-2012 00:00:01 GMT;&amp;quot;; return true; }; }; //--&amp;gt; &amp;lt;/script&amp;gt;   &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
When a user submits the form, the function sets an identifying cookie. Before the form processes, the function checks to see if there is already a cookie set.  If not, the form handles the submission as normal. If there is a cookie, the user gets an alert box that says &amp;quot;You've already submitted your answers&amp;quot; and the form submission is blocked.&lt;br /&gt;
This is a good, cross-browser way to avoid duplicate submissions, but we have to be careful that user's browser must accept cookies and have JavaScript turned on for this method to work.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==ASP.NET==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Here is an implementation in ASP that prevents duplicate form submission. In this implementation, we consider two ways of avoiding this problem. One is the Unsafe button method, where the button does not vanish after the user clicks the button. But at the same time does not consider two or more consecutive clicks, if done within a specified period of time, as a different request from the orginal one. The other method is the safe button method where the button vanishes after the button is clicked once and returns only after the request has been completed or timed out.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%@ Page Language=&amp;quot;VB&amp;quot; %&amp;gt;&lt;br /&gt;
&amp;lt;script runat=&amp;quot;server&amp;quot;&amp;gt;&lt;br /&gt;
Dim counter As Integer&lt;br /&gt;
Sub Page_Load()&lt;br /&gt;
If Session(&amp;quot;counter&amp;quot;) Is Nothing Then&lt;br /&gt;
counter = 0&lt;br /&gt;
Else&lt;br /&gt;
counter = CInt( Session(&amp;quot;counter&amp;quot;) )&lt;br /&gt;
End If&lt;br /&gt;
If IsPostBack Then&lt;br /&gt;
counter += 1&lt;br /&gt;
Session(&amp;quot;counter&amp;quot;) = counter&lt;br /&gt;
End If&lt;br /&gt;
Label1.Text = &amp;quot;Counter = &amp;quot; &amp;amp; counter.ToString()&lt;br /&gt;
SafeButton.Attributes.Add(&amp;quot;onclick&amp;quot;, &amp;quot;disableButton();return true&amp;quot;)&lt;br /&gt;
End Sub&lt;br /&gt;
&lt;br /&gt;
Sub Process_Click(sender As Object, e As EventArgs)&lt;br /&gt;
Dim i As Long&lt;br /&gt;
' 2-second delay&lt;br /&gt;
Dim endTime As DateTime = DateTime.Now.AddSeconds(2)&lt;br /&gt;
While DateTime.Now &amp;lt; endTime&lt;br /&gt;
End While&lt;br /&gt;
Label2.Text = &amp;quot;Finished @ &amp;quot; &amp;amp; DateTime.Now.ToString()&lt;br /&gt;
End Sub&lt;br /&gt;
&lt;br /&gt;
Sub Button2_Click(sender As Object, e As EventArgs)&lt;br /&gt;
Session(&amp;quot;counter&amp;quot;) = 0&lt;br /&gt;
Label1.Text = &amp;quot;Counter = &amp;quot; &amp;amp; Session(&amp;quot;counter&amp;quot;).ToString()&lt;br /&gt;
End Sub&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;script language=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
function disableButton()&lt;br /&gt;
{&lt;br /&gt;
document.form1.SafeButton.style.visibility = &amp;quot;hidden&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;form runat=&amp;quot;server&amp;quot; id=&amp;quot;form1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&amp;lt;asp:Label id=&amp;quot;Label1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;Label&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&amp;lt;asp:Label id=&amp;quot;Label2&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;Label&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&amp;lt;asp:Button id=&amp;quot;UnsafeButton&amp;quot; onclick=&amp;quot;Process_Click&amp;quot; runat=&amp;quot;server&amp;quot; Text=&amp;quot;Unsafe Button&amp;quot;&amp;gt;&amp;lt;/asp:Button&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&amp;lt;asp:Button id=&amp;quot;SafeButton&amp;quot; onclick=&amp;quot;Process_Click&amp;quot; runat=&amp;quot;server&amp;quot; Text=&amp;quot;Safe Button&amp;quot;&amp;gt;&amp;lt;/asp:Button&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&amp;lt;asp:Button id=&amp;quot;Button2&amp;quot; onclick=&amp;quot;Button2_Click&amp;quot; runat=&amp;quot;server&amp;quot; Text=&amp;quot;Clear Counter&amp;quot;&amp;gt;&amp;lt;/asp:Button&amp;gt;&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;span1&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
As explained earlier, the Unsafe button allows users to click on submit multiple times. But clicking on the button again doesnt do anything, a two-second delay has been put into the button handler to emulate the time that a back-end process might take. So unless that time is up it doesnt effective count as a click.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
Even for the Safe button the same process runs. But in this case as soon as the button is clicked, it disappears, preventing you from being able to click it again until the processing (postback) is complete.  This ensures that multiple form request is not sent by completely taking out the submit button. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Ruby On Rails==&lt;br /&gt;
&lt;br /&gt;
Ruby on Rails uses the Submit button disabling method to prevent Multiple form submissions .It uses the submit_tag option .Below is the code that demonstrate this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
submit_tag &amp;quot;Submit&amp;quot;, :disable_with =&amp;gt; &amp;quot;Saving...&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This adds behavior to the submit button to disable it once clicked, and to display &amp;quot;Saving...&amp;quot; instead of &amp;quot;Submit&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&amp;lt;p&amp;gt;&lt;br /&gt;
As illustrated in the above wiki, various languages handle the problem of multiple form submission either by client side or server &lt;br /&gt;
side methods. Server side handling is more reliable as some web browsers do not support the disabling of button feature. Synchronizer token pattern is best solution as illustrated in Java .In most languages, for server side handling, a token is set once on submission and compared again on resubmission to check for duplicates ,this prevents the data from being inserted again into the database. Some websites just pop message to user to wait until action is completed. Overall Java script is best way to handle duplicate form submission &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt; Below are some of the references for further reading &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;http://www.javaworld.com/javaworld/javatips/jw-javatip136.html?page=1&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;http://forums.asp.net/t/447620.aspx?PageIndex=1&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;http://drupal.org/node/69048&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;http://phpsense.com/php/prevent-duplicate-form-submission.html&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;http://forums.techarena.in/software-development/1149257.htm&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;http://www.stackoverflow.com&amp;lt;/p&amp;gt;&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
</feed>