Re: Comments

From: Graham Stratford (gstratford_at_das.ca)
Date: 06/24/04


Date: Thu, 24 Jun 2004 09:46:29 -0400

I have a couple of rules that I follow:

Comments should not show "what" a section of code is doing (unless it is
rather complex), but "why" it is doing so. Of course, there is always a
place for comments at the head of units, functions, etc.

Also, every time I put in a comment, I try to think whether the code
wouldn't be better served with a function/procedure that accomplishes
the same goal. For example:

// Check to see if the user has permission
... my code here ...

might be easier to understand and maintain if it were put into a
function called

function TMyObject.CheckUserPermission();

Graham

In article <40d955fd$1@newsgroups.borland.com>, ya.ierfgnf@thnxf.x
says...
> Scout wrote:
> >
> > What rules do you use in deciding what (and what not) to comment?

> Myself I tend to comment rather more than less, when in doubt. I have too
> many times noticed that "simple, obvious" things (to me) are far from
> obvious to a colleague who has to jump in and fix something in my code.
> Of course I don't mean stupid things like "inc(i); // increase i by one"
> type comments; but rather the goings-on at application levels higher than
> that - there's plenty of medium-to-high-level stuff that warrants an
> explanation.



Relevant Pages

  • Re: Comments
    ... "Kristofer Skaug" wrote in ... > are far from obvious to a colleague who has to jump in and fix ...
    (borland.public.delphi.non-technical)
  • Re: Brains Reward Mechanism For Learning
    ... Neuroscientists have proposed a simple explanation for the pleasure ... The brain is getting its fix. ... The brain's craving for a fix motivates humans to maximize the rate ...
    (sci.anthropology.paleo)
  • Brains Reward Mechanism For Learning
    ... Neuroscientists have proposed a simple explanation for the pleasure ... The brain is getting its fix. ... The brain's craving for a fix motivates humans to maximize the rate ...
    (sci.anthropology.paleo)
  • Re: [PATCH 5/7] ftrace, PPC64: handle module trampolines for dyn ftrace
    ... I'm positive I made that fix already. ... I'm making sure that I will actually jump to the correct spot before ... And then the jump is to r11. ...
    (Linux-Kernel)
  • Re: Where is TApplication located?
    ... >> I'm trying to correct some buggy mouse wheel behavior in the DBGrid... ... >> A colleague told me how to fix it and sent me this URL... ...
    (comp.lang.pascal.delphi.misc)