Thursday, 24 May 2012

Code and Comments What is important

Being a programmer doesn’t make you great if you can write a long long lines of code. Its your baby you’ve got to put some thing in it so that other can understand it as clearly by looking at it. Nobody have time to debug the code every time as it takes time to setup the environment and debug your code. It would still remain a puzzle why you’re doing crazy things in it.
Do you remember when you install a new hardware and you don’t get a help manual in there you feel cheated. The same way other developer feels when he/she looks at your code later. You might have written the rocket science in there but that code is for computer not for human. so do take care of putting some information like a Pseudo or something that can hint guest to understand the flow.
Thinks about it if you’re running on highway with no sign boards what will you get? A way full of surprises you don’t know what’s gonna come in your way.
What kinda comments you can put in to save and help others in time -
Type of comments -
Inline comments – putting a single line for the statement. Most programming language supports '//’ so putting a single line would create some respect for you.
// begin: Variation Three.
// -------------------------
// This is the comment body.
// -------------------------

Block comments – When you gonna do some stuff with bunch of line of code do put a block comment what’s happening in there.
/* 
     This is the comment body.
     Variation One.
*/

XML comments – if you’re a DotNet developer then every function, class and property have support to put comments on the header of the definition. you can use it to describe what your function will do exactly.
/// <summary>
///
/// </summary>
/// <param name="strFilePath"></param>

put brief of your logic in comments like mentioning the algorithm. Detail the use of every parameter and return type. This would help you itself when you come back after a long time to you own home.

Do write code but do mention what you wrote.

Comments are as important as your code. Keep it in mind while you develop. Think like the person who’s gonna review your code is near by neighborhood and he’s got a weapon to kill you right away.

No comments:

Post a Comment