| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
On 8/29/03 9:21 PM, Camillo Lugaresi didst favor us with:
> The pitfalls of excessive self-documentation are the same as those of
excessive commenting. The only difference is that your text will be
mostly blue instead of mostly red (or whatever color). :)
I wouldn't use something like that myself unless I had a pretty good reason
to, but I wouldn't rule out the possibility.
>
> I think your earlier attempt was a better example of practical
self-documenting code:
At 15:57 -0400 27-08-2003, Laurence Harris wrote:const SInt16 windowWidth = intRight - intLeft,
windowHeight = intBottom - intTop,
kScrollbarWidth = 15;
SizeControl( control, windowWidth, windowHeight - kScrollbarWidth );
Sure, but this is a tiny amount of code. If it were larger and/or there were
some tedious detail I don't need to read through to get an overall picture
of the function containing this code were doing, I might put it in a
function.
One of the reasons to factor stuff out into smaller, more narrowly
focused functions is so you don't get bogged down in details when trying to
read the function that calls those helper functions.
> Of course it's not perfect, but if someone gets puzzled becauseyou're using a couple of local variables, it's his job that should be
changed, not your code. ;)
Well, that's my perspective. Like I said, the few comments I write are not
intended to be lessons in how to write Mac software. ;-)
>> SizeControlToFillWindowLeavingSpaceForHorizScrollbar( widgetControl,
In fact, if you use enough of these kinds of functions the logic of your
code can become extremely easy to follow just from reading a sequence of
well-named functions:
CreateWidgetWindow( &widgetWindow );
CreateWidgetControlToDisplayContent( widgetWindow , &widgetControl );
>>widgetWindow );CreateHorizontolScrollbarAtBottomOfWindow( widgetWindow, &scrollbar );
get(&clue); /* just use a NIB ;) */
get(&clue); // This was just an example
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.