Re: "Tricks" of the "Trade"
Re: "Tricks" of the "Trade"
- Subject: Re: "Tricks" of the "Trade"
- From: Erik Thorteran <email@hidden>
- Date: Thu, 7 Jun 2001 00:33:27 -0700
Hmmm. Here is a quote from Martin Fowler's Refactoring book:
"The reason we mention comments here is that comments often are used as
a deodorant [for smelly code - gt]. It's surprising how often you look
at trickly commented code and notice that the comments are there
because the code is bad"
My advise: do not use comments, but use proper method and variable
names. One of the beauties of ObjectiveC is that (similar to Smalltalk)
it is a self commenting language (if used properly). My colleagues and
I use comments in three situations:
1. To document public API (in the header file)
2. For mathematical expressions (a formula is more compact and readable
then several lines of code)
3. To mark some source fragment to be changed or enhanced in the
future. I start such comments with "$$$" so that I can search for this
pattern in the entire project. Some folks are also using the #warning
pragma, but this should not be misused.
I disagree that commenting is a "deoderant" for smelly code. I use it
always, as it is not compiled. i do it just to make sure that I
understand what I was thinking an ungodly hour like now. However I do
agree with your places where you do put comments. i figure, commenting
ain't so hard, might be useful, and takes no performance toll, so what
the hell?
Erik