Regarding coding style

castironpi at gmail.com castironpi at gmail.com
Sat Mar 8 15:27:09 EST 2008


On Mar 8, 1:31 pm, Grant Edwards <gra... at visi.com> wrote:
> On 2008-03-08, castiro... at gmail.com <castiro... at gmail.com> wrote:
>
> > Does one side of this hold that there are no -good- comments?
>
> I wouldn't say there are _no_ good comments, but I would say
> that 90+% of the comments I've seen in my lifetime were bad.

Limit your comments, in other words.  <em>LIM-IT</em>.

> comment explaining a particularly opaque algorithm can be
> useful as well.

But can't the name do that?  <wink>

> at the beginnings of C/C++ functions that do things like tell
> you the name and return type of the function and list the names
> and types of the parameters. Gee, thanks.  I never could have
> figured that out from looking at the source code itself. IMO,

Sometimes void*s are guaranteed to be HTHREADs.

> I'm also a bit baffled by people who put a comment at the top
> of every file that tells you what the filename is.  I sometimes
> wonder how/where these files were created. All of the OSes I've
> ever used had a feature called a "filesystem" which kept track
> of info like the names of files.  It must be a bitch-and-a-half
> to work on an computer that doesn't keep track of filenames and
> makes the user do it.
>
> When was the last time you thought to yourself: "Gee, I wonder
> what's the the name of that file over there? I guess I'd better
> open the file and look at the comment at the top to see what
> the filename is?

What file did you open?

To Lie:

> Personally I preferred a code that has chosen good names but have
> little or no comments compared to codes that makes bad names and have

Personally I don't.  Show me a good one.  Until you do, it's not that
I won't like it, it's that I can't.  You know, in linguistics, there's
what's called 'code switching', which is switching between two
languages you know midstream.  People can understand 'hear' a language
but not speak it.  If you speak it, <leaves open>.  If comments aren't
the 'short version', then patience is the problem.  There's not one
word for lots and lots of things.  Examples on backorder.

Good comments are better than bad names.
Good names are better than bad comments.

And enter multi-word identifiers.  <wink>



More information about the Python-list mailing list