I recently read this long discussion on slashdot on commenting the code.There were people saying 'dont comment your code ,only then people willcome back and ask you and you become important'.
Shocking???Yes but there are a frustrated & insecure few who feel the same.But looking at the larger issue, I think everyone is for commenting.But the big questions are
1. How to comment(Format)
2. How much to comment.
The first point on the format to comment is pretty much standarised.It is either defined at the project level or the technology level.There are doc toolsand ide's that help in this.
The second question on how much to comments is the big complex one. Acode with excess comment by no means becomes a 'well commented code'. Toomany comments is annoying and distracts you from thinking. In large and long projects, the comments very often dont match what the code does. Yes this is true.Many times the code gets changed but not the comments.So what is the useof the comments??Ok ,the comments dont decide what the program does.It is the code that tells the truth.The comments just help you to get 'in flow'.Thats what my mentor used to tell me.'Remember,You Are Writing Code For People,NOT Computers.You write code that is self documented.'
Self Documented??? That is giving the variable and method proper names which by themselves describe what they are doing. Writing the code in the least complicated way.Hence think before you code. Its easier said than done.Very often you need to fix problems before a deadline and hence becomes very difficult to do all this.
One more thing I want to add is commenting small things. I mean in a thousandlines of code ,someone adds a line to check for null,and they comment it
// Checked for Null by Name(id) Date
if(loValue!=NULL) //Check if loValue is not Null Do something...
I mean if people start adding their names for all these triffle things the sizeof the file starts becoming ugly.I know its nice to have your name all around the code.But then there is a limit.Unless the code is getting changed in flow or it happens to be someone elses code,I think all minor changes can go without this.
But again the question as to what is major and minor is something to think about.Finally I think the code you write should be legible enough so that its easy to maintain.I think every coder takes pride in it.
Saturday, January 14, 2006
Monday, January 02, 2006
Happy New Year
Its New Year and time to reflect on the past year. This year started great, bcos I was learning the wonderful world of Java,EJB's and Patterns and what not.So learning wise I should say it started of great. But there was a part when I felt very bored and not so comfortable and did not enjoy anything. I dont know why, but that was for sometime.Cos in the middle I just started to feel lost in a big crowd.But the bestpart was the little angel, my neice.Everyday I came back home and I forgot office.She started to walk and talk this year.She was so naughty and she took all my time other than work. Another thing I did was startingto learn the flute. Its good. I havent learnt it well enough but I enjoy doing it and hopefully I ll continue it this year.Then I got my touch back in the middle of the year. I did a lot of new things at work. I got the freedom to try out my ideas.I also had nice friends. So all was fine.On the whole I thinkit was a ok-good year at work,and a great year wrt to my time at home.
This year is going to be a different one,the angel has gone to meet her daddy.So will be atleast 6 months more to see her,by which time she would have grown more.One thing that was missing this year is travel. I hope I do some of that this year.
So its a new year ....lets see.
This year is going to be a different one,the angel has gone to meet her daddy.So will be atleast 6 months more to see her,by which time she would have grown more.One thing that was missing this year is travel. I hope I do some of that this year.
So its a new year ....lets see.
Subscribe to:
Posts (Atom)