Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
About method comments
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 77 - Expand all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Esteban A. Maringolo  
View profile  
 More options Feb 28 2006, 11:10 am
Newsgroups: comp.lang.smalltalk
From: "Esteban A. Maringolo" <eMaring...@small-REMOVETHIS-talking.net>
Date: Tue, 28 Feb 2006 13:10:06 -0300
Local: Tues, Feb 28 2006 11:10 am
Subject: About method comments
Hi all:

On thing that disturbs me everytime I see a presentation/screencast
or download some goodie, is the total lack of method/class comments.

Particulary on third party classes, but I find it also on many base
classes of some smalltalk distributions.

The only smalltalk which I can tell it has comments for almost all
the methods and classes is Dolphin. But this isn't true for many
goodies around.

Am I the only who worries about this, or also concerns somebody else?

For those who don't comment, why? :-)

Regards,

--
Esteban


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Uppal  
View profile  
 More options Feb 28 2006, 11:25 am
Newsgroups: comp.lang.smalltalk
From: "Chris Uppal" <chris.up...@metagnostic.REMOVE-THIS.org>
Date: Tue, 28 Feb 2006 16:25:20 -0000
Local: Tues, Feb 28 2006 11:25 am
Subject: Re: About method comments

Esteban A. Maringolo wrote:
> On thing that disturbs me everytime I see a presentation/screencast
> or download some goodie, is the total lack of method/class comments.

> Particulary on third party classes, but I find it also on many base
> classes of some smalltalk distributions.
[...]
> Am I the only who worries about this, or also concerns somebody else?

You are not alone.

    -- chris


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Gagne  
View profile  
 More options Feb 28 2006, 2:53 pm
Newsgroups: comp.lang.smalltalk
From: Thomas Gagne <tga...@wide-open-west.com>
Date: Tue, 28 Feb 2006 14:53:21 -0500
Local: Tues, Feb 28 2006 2:53 pm
Subject: Re: About method comments
I like the way stx does it's comments.  Comments on a class are added to
  method inside "comment" method categories.  While working on a class
you're always reminded you haven't commented it if the method category
is empty.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Buck  
View profile  
 More options Feb 28 2006, 8:45 pm
Newsgroups: comp.lang.smalltalk
From: David Buck <da...@simberon.com>
Date: Tue, 28 Feb 2006 20:45:37 -0500
Local: Tues, Feb 28 2006 8:45 pm
Subject: Re: About method comments

You should definitely have method comments if the method comment helps
you understand what the method does.  I don't like seeing this:

phoneNumber
    "return the phone number instance variable"
    ^phoneNumber

In this case, I can read the code faster than the comment and I'm
guaranteed that the code is accurate.

Having added a method comment, you should ask yourself why the method
needs a comment to make it understandable.  You can then simplify,
shorten, and clarify the method until it is so clear that it no longer
needs a comment.

Method comments can be a code smell.  They indicate that the code itself
isn't clear enough.  Once it is clear enough, you can remove the comment
because it's superfluous.

David Buck
Simberon Inc.
www.simberon.com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Upright  
View profile  
 More options Mar 1 2006, 1:48 am
Newsgroups: comp.lang.smalltalk
From: Ian Upright <ian-n...@upright.net>
Date: Wed, 01 Mar 2006 06:48:29 GMT
Local: Wed, Mar 1 2006 1:48 am
Subject: Re: About method comments
"Esteban A. Maringolo" <eMaring...@small-REMOVETHIS-talking.net> wrote:

>Hi all:

>On thing that disturbs me everytime I see a presentation/screencast
>or download some goodie, is the total lack of method/class comments.

>Particulary on third party classes, but I find it also on many base
>classes of some smalltalk distributions.

>The only smalltalk which I can tell it has comments for almost all
>the methods and classes is Dolphin. But this isn't true for many
>goodies around.

>Am I the only who worries about this, or also concerns somebody else?

>For those who don't comment, why? :-)

I'll reserve my judgement and not comment on this.  :-)

Ian

>Regards,

---
http://www.upright.net/ian/

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Geoff  
View profile  
 More options Mar 1 2006, 2:45 am
Newsgroups: comp.lang.smalltalk
From: "Geoff" <nos...@nospam.com>
Date: Wed, 01 Mar 2006 07:45:35 GMT
Local: Wed, Mar 1 2006 2:45 am
Subject: Re: About method comments
IMHO, one should use method comments.  However, I have been in situations
when the boss, also an st'r, integrated the stuff I wrote or took it over,
he removed all the method comments.

-g


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
macta  
View profile  
(1 user)  More options Mar 1 2006, 3:33 am
Newsgroups: comp.lang.smalltalk
From: macta <365n...@gmail.com>
Date: Wed, 1 Mar 2006 08:33:56 +0000 (UTC)
Local: Wed, Mar 1 2006 3:33 am
Subject: Re: About method comments
Hi Esteban,

> Hi all:

> On thing that disturbs me everytime I see a presentation/screencast or
> download some goodie, is the total lack of method/class comments.

That said there are way too many bogus comments around (if you ever read
Sun JDK java doc you will know what I mean).

I did a quick spot check of Dolphin class comments - and I would agree that
they add some benefit.

On the method side however, comments are more often than not a crutch to
not renaming things. For example here's a random method I plucked out of
DBAbstractRow in dolphin:

isDeletedRow
        "Answer whether the receiver represents a row in a result set which has
been
        deleted in the time since the result set was originally queried."

        ^self status = SQL_ROW_DELETED

So the deleted aspect is covered by the name, the interesting bit is the
"since the result set was orginally queeried" - which kind of makes me think
that the real smell is the name - maybe #isDeletedSinceQueried would be better?
And this is the problem with comments, rather than doing the right thing,
people often just add a comment.

I did an experiement a few years ago - a colleague and I wrote comments for
a week, while we refactored code and built up a system. At the end of the
week, most of the comments we checked were either wrong, or misleading -
the problem is that the overhead of keeping them upto date is quite high
- especially if you constantly simplify and refactor/rename. The refactoring
tools will happily rename references for you - but comments aren't references
(so if you are commenting - keep that in mind, and maybe keep comments as
small as possible).

The other aspect - at least for me, is that the tests are often much better
comments than the comments. However in Smalltalk, because things are so natural
to just "do it" there doesn't seem to be lots of examples of well tested
(read descriptive) libraries. I was pleasantly suprised to find some in Swazoo
- and the tests did actually help me figure out how to get things running.
However in this case, a high level overview of how to do it right was missing
(in fact I think you sent me a few things to show swazoo in action) - so
maybe a good overview is more helpful than itty bitty comments.

Good point overall though - I will look at my latest library and see if there
are any things I could helpfully do to make sure its understandable.

Tim


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steven Kelly  
View profile  
 More options Mar 1 2006, 6:37 am
Newsgroups: comp.lang.smalltalk
From: "Steven Kelly" <ste...@metacase.com>
Date: Wed, 01 Mar 2006 11:37:52 GMT
Local: Wed, Mar 1 2006 6:37 am
Subject: Re: About method comments
"Esteban A. Maringolo" <eMaring...@small-REMOVETHIS-talking.net> wrote
in message news:D6Cdna08bJqA65nZnZ2dnUVZ_tOdnZ2d@totallyobjects.com...

> On thing that disturbs me everytime I see a presentation/screencast
> or download some goodie, is the total lack of method/class comments.

What irks me most is when there is no package/parcel comment. Second
worst is when there is no version comment on parcels. If these are
goodies, and are being maintained, it makes it many times easier to
use if there's at least some information on how to get started, and
what has changed since the last version.

Even if the code really is well-written enough that it is its own
documentation, we still need some pointer as to which classes to look
at first.

Those are my comments as a user of goodies. As a provider, I know I
fail my own tests sometimes :-(.

Steve


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steven Kelly  
View profile  
 More options Mar 1 2006, 6:40 am
Newsgroups: comp.lang.smalltalk
From: "Steven Kelly" <ste...@metacase.com>
Date: Wed, 01 Mar 2006 11:40:58 GMT
Local: Wed, Mar 1 2006 6:40 am
Subject: Re: About method comments
Oops, meant to say "second worst is when there is no version comment
on PACKAGES" - parcels rarely even have a strict version number. Mind
you, we were one of several people caught out when the SmaCC package
in the public store had a newer version number than the parcel in
/goodies/*, but was actually an older version...
S.

"Steven Kelly" <ste...@metacase.com> wrote in message

news:kIfNf.144$hR2.135@read3.inet.fi...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bob Nemec  
View profile  
 More options Mar 1 2006, 7:37 am
Newsgroups: comp.lang.smalltalk
From: "Bob Nemec" <b...@rogers.com>
Date: Wed, 1 Mar 2006 07:37:26 -0500
Local: Wed, Mar 1 2006 7:37 am
Subject: Re: About method comments

> On thing that disturbs me everytime I see a presentation/screencast or
> download some goodie, is the total lack of method/class comments.

The rule that I follow is to comment intent, not action (the 'why', not the
'how').

Most Smalltalk methods can be understood by reading the code, but in a
complex app, where the method fits into the bigger picture is not always
easy it understand.  And a comment about the intent of a method is less
likely to become outdated.  Even if code is refactored, the reason it was
added in the first place is probably still valid.

Bob Nemec
Northwater Objects


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Esteban A. Maringolo  
View profile  
 More options Mar 1 2006, 7:46 am
Newsgroups: comp.lang.smalltalk
From: "Esteban A. Maringolo" <eMaring...@small-REMOVETHIS-talking.net>
Date: Wed, 01 Mar 2006 09:46:57 -0300
Local: Wed, Mar 1 2006 7:46 am
Subject: Re: About method comments
Hi macta,

macta escribió:

> Hi Esteban,
>> Hi all:
>> On thing that disturbs me everytime I see a presentation/screencast or
>> download some goodie, is the total lack of method/class comments.
> That said there are way too many bogus comments around (if you ever read
> I did a quick spot check of Dolphin class comments - and I would agree
> that they add some benefit.

[SNIP]

> which kind of makes me
> think that the real smell is the name - maybe #isDeletedSinceQueried
> would be better? And this is the problem with comments, rather than
> doing the right thing, people often just add a comment.

Yes, the method could had a more intention revealing selector. But
even in that case the comment should not be ommited.

> I did an experiement a few years ago - a colleague and I wrote comments
> for a week, while we refactored code and built up a system. At the end
> of the week, most of the comments we checked were either wrong, or
> misleading - the problem is that the overhead of keeping them upto date
> is quite high - especially if you constantly simplify and
> refactor/rename. The refactoring tools will happily rename references
> for you - but comments aren't references (so if you are commenting -
> keep that in mind, and maybe keep comments as small as possible).

Well... many times if you refactor some method and need to modify
the comment may indicate that is was bad commented. The only problem
I see in the refactoring is when one changes the name of one or more
arguments, and those names are in the comment, but that is local to
the method and easily modifiable.

Doing TDD one first sends a message with the selector expected, but
once a MNU exception is thrown and one chooses to implement the
method, the first to write is the comment, not its implementation, IMHO.

> The other aspect - at least for me, is that the tests are often much
> better comments than the comments.

This proven to be true for documentation or usage purpose, and is so
because tests have gained momentum again during the last 2-3 years.

But it doesn't apply for exploratory or self learning usage, which
is the way most smalltalkers uses an Smalltalk (or at least used to do).

> However in Smalltalk, because things
> are so natural to just "do it" there doesn't seem to be lots of examples
> of well tested (read descriptive) libraries.

 > I was pleasantly suprised

> to find some in Swazoo - and the tests did actually help me figure out
> how to get things running. However in this case, a high level overview
> of how to do it right was missing (in fact I think you sent me a few
> things to show swazoo in action) - so maybe a good overview is more
> helpful than itty bitty comments.

But here we are talking of another issue which is documentation of a
class, and more particulary of a set of classes and how to use them.
I agree with you that test cases are very instructive in how to get
started using something.

> Good point overall though - I will look at my latest library and see if
> there are any things I could helpfully do to make sure its understandable.

:-)

Regards,

--
Esteban.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Esteban A. Maringolo  
View profile  
 More options Mar 1 2006, 8:06 am
Newsgroups: comp.lang.smalltalk
From: "Esteban A. Maringolo" <eMaring...@small-REMOVETHIS-talking.net>
Date: Wed, 01 Mar 2006 10:06:16 -0300
Local: Wed, Mar 1 2006 8:06 am
Subject: Re: About method comments
Hello David,

David Buck escribió:

> Esteban A. Maringolo wrote:
>> On thing that disturbs me everytime I see a presentation/screencast or
>> download some goodie, is the total lack of method/class comments.
> You should definitely have method comments if the method comment helps
> you understand what the method does.  I don't like seeing this:
> phoneNumber
>    "return the phone number instance variable"
>    ^phoneNumber

> In this case, I can read the code faster than the comment and I'm
> guaranteed that the code is accurate.

Agree, but that method is bad commented, because it never should
talk about its implementation. It should be something like "Answers
the phone number of receiver.", then if you refactor it to be
obtained from any other place than a i.v., the comment will keep
having meaning.

> Having added a method comment, you should ask yourself why the method
> needs a comment to make it understandable.  You can then simplify,
> shorten, and clarify the method until it is so clear that it no longer
> needs a comment.

I like the quote:
"Programs must be written for people to read,
and only incidentally for machines to execute."

The comment should say anything about the implementation, I must be
able to program "trusting" in the comment (as I trust in the type),
if I read that #rounded answers me the receiver rounded, I don't
care how is it implemented. In many cases the selector is intention
revealing enoguh (as in my example).

> Method comments can be a code smell.  They indicate that the code itself
> isn't clear enough.  Once it is clear enough, you can remove the comment
> because it's superfluous.

Method comment _is not_ code comments, if the method talks about its
implementation, something smells. Method comment must complement or
expand the selector name itself, ignoring what the implementation is.

About getters and setters, it's true that are the most obvious case,
  but for the sake of homogeneity they should be there, after all
they're simple to write, and most Smalltalks (at least Dolphin
does), allows you to create the accessors for the i.v. automatically.

Object>>name
        "Answers the name of receiver."

Fast coding isn't related to better coding, IMHO.

Regards,

--
Esteban.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mdr  
View profile  
 More options Mar 1 2006, 9:15 am
Newsgroups: comp.lang.smalltalk
From: "mdr" <mrobe...@cincom.com>
Date: 1 Mar 2006 06:15:09 -0800
Local: Wed, Mar 1 2006 9:15 am
Subject: Re: About method comments
The lack of method/class comments is a recognized problem. However,
comments missing from an application may be less serious than comments
missing from the class library in the base image.

Method comments are often the only guide to an API in a class. When
they are lacking, the developer may be forced to spend more time trying
to figure out the API itself. The Smalltalk language provides no fixed
convention to distinguish public from private methods, and it doesn't
have the notion of an interface.

Without a clearly-expressed API, an application programmer is soon
combing through all the protocols, looking for suitable-sounding
selectors. Without adequate method comments, she must reverse-engineer
methods inside the library. Reading method after method to figure out
all the conditions under which they return true/false/nil/whatever can
be a big waste of time.

There's a lot of talk about how XP can be used to eliminate the need
for comments, but I personally don't find these claims terribly
persuasive.

First, having tried to work with code that was developed this way, it
strikes me (and I am not alone) that no matter what the XP theory says,
the reality is that all bets are off when the next developer who looks
at your code isn't pair programming with you. Passing on undocumented
code may be passing on the work of actually making it clear, and it
presupposes that the next person who didn't develop the code is going
to readily grasp its design by reading code.

Yet, just because developer A thinks the intention behind a class is
obvious is clearly no guarantee that developers B, C, and D will feel
the same way. Similarly, there is no guarantee that the next developer
looking at the code will have the same level of expertise. We easily
say "read the code" when in practice this often means
reverse-engineering it.

For example, let's say you want to build a CodeTool in the Refactoring
Browser that needs to read the current state of the RB navigator. Is
there a clear API for this? No. The RB was developed XP-style, and the
idea seems to be that it's not necessary to present an API through
comments. "But it's simple, just go read the code." Right? Err, not
quite. At first, it seems straightforward, but there are inner
mechanisms which are undocumented and non-obvious. In fact, a seasoned
Smalltalk developer working for Cincom spent 75 hours
reverse-engineering that one particular interface. If it took 75 hours
to figure out how to get the current browser selection, it's not
"simple". Also, that was time spent just to figure out how to use the
RB code, not to write the missing documentation. So, another developer
can go through the same hassle again next time.

In my experience, a developer who didn't write the code in the first
place will be quite reluctant to write documentation for it. You know
the feeling: "do I *really* understand what's going on here? Do I
understand it well enough to document it?" Thus, once it leaves the
hands of the original authors, it becomes much harder to add lacking
documentation later.

Another claim is that comments "should be unnecessary" and that methods
should be re-factored until they are simple enough not to need
comments. If we accept this, then can we apply this practice to all the
existing classes in the base library that "need" comments? And what of
all the opaque code that doesn't even have comments in the first place?

Well, how many man-years of work are we talking about here? How many
classes are in the base image? How many of them don't even have enough
comments to aid in simplifying the code in the first place? Do any of
the Smalltalk vendors have the resources to go through their base
libraries, simplify, shorten, re-write and clarify all of the code
until it doesn't "need" comments? The answer is pretty obviously "no".

As for the question about why developers don't comment, I can only
hazard a few ideas. Often, the design of the code changes several times
during development, and it's a nuisance to keep updating the comments
to track these changes. The idea is that when the code is "finished"
then the documentation will be written, but often that last step is
never taken. Documentation/comments are not seen as "deliverables". Or
else comments are unpleasant to write, they don't provide the same
enjoyment that coding does, so developers invent rationalizations to
convince themselves that comments are unnecessary. Another problem is
that a developer may look at a piece of code, find that the existing
comment is outdated or inadequate, and after a while conclude that the
comments aren't very useful -- a vicious cycle.

Overall, as long as writing documentation/comments is not viewed as an
essential part of the code development process, they'll likely be
forgotten or otherwise rationalized away.

Some will argue with these points, citing the usual counterexamples of
code that is overly encumbered with comments, etc. Certainly, that is a
problem, and setting the standard too high means too much work to
maintain the "excess" documentation. I won't argue with that.

Rather, my concern is closer to Mr. Maringolo's, i.e., not with code
that has "too much" commentary, but with code that has too little.
I.e., code that lacks clear APIs, or the basics like package and class
comments for the main components or public classes of an
application/subsystem. This is the case where the application developer
is forced to reverse-engineer code.

Clearly, developers are leery of the cost of spending a lot of time
writing and maintaining comments under "verbose" methodologies, but
what about the deferred costs of producing incomprehensible code, code
that demands a prohibitive time investment to use?

A balance must be struck between too much and too little.

At Cincom, we decided to address these issues with an internal policy
that all new code going into the product should be adequately
commented, and we launched an initiative called SmalltalkDoc that aims
to provide better API documentation for the base library.

Some have argued that the Smalltalk vendors should try to formalize the
notion of an interface, perhaps along the lines of SmallInterfaces. My
own preference has been to do this through an integrated documentation
approach like SmalltalkDoc, which doesn't burden the developer as much.
The general idea is to provide a framework, some automation and better
tools, all with the aim to make it easier to write and maintain
high-quality comments and API documentation.

For the curious, more information on SmalltalkDoc is available here:

http://www.cincomsmalltalk.com/CincomSmalltalkWiki/SmalltalkDoc

Regards,

M. Roberts
Cincom Systems, Inc.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Uppal  
View profile  
 More options Mar 1 2006, 10:41 am
Newsgroups: comp.lang.smalltalk
From: "Chris Uppal" <chris.up...@metagnostic.REMOVE-THIS.org>
Date: Wed, 1 Mar 2006 15:41:39 -0000
Local: Wed, Mar 1 2006 10:41 am
Subject: Re: About method comments

mdr wrote:
> [...lots of sensible stuff snipped...]

I'm just picking up on one or two points.

> First, having tried to work with code that was developed this way, it
> strikes me (and I am not alone) that no matter what the XP theory says,
> the reality is that all bets are off when the next developer who looks
> at your code isn't pair programming with you. Passing on undocumented
> code may be passing on the work of actually making it clear, and it
> presupposes that the next person who didn't develop the code is going
> to readily grasp its design by reading code.

It seems to me that the pair-programming practise is intensely wasteful. No, I
don't mean the hypothetical halving of productivity.  But every time the pair
communicate,  "why do it like that?",  "wouldn't X be better ?",  "looks a bit
iffy to me", there's a good chance that that communication (or the answer)
should be in the code as a comment.  Yet the information is passed to only one
other person...

> As for the question about why developers don't comment, I can only
> hazard a few ideas. Often, the design of the code changes several times
> during development, and it's a nuisance to keep updating the comments
> to track these changes.

I don't see why anyone who is using commenting /properly/ -- i.e. as an
exercise in communication (with him/her self, with the next programmer, with
posterity) -- should have any difficulty with updating comments.  If the code
is different, then clearly we'll have different things to say about it -- type
'em in !

Personally, I have never encountered (in real life) a programmer who wanted to
avoid comments (for any of the "reasons" you mentioned), who didn't have an
over-inflated idea of the quality of his own code.

    -- chris


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Uppal  
View profile  
 More options Mar 1 2006, 3:15 pm
Newsgroups: comp.lang.smalltalk
From: "Chris Uppal" <chris.up...@metagnostic.REMOVE-THIS.org>
Date: Wed, 1 Mar 2006 20:15:02 -0000
Local: Wed, Mar 1 2006 3:15 pm
Subject: Re: About method comments

David Buck wrote:
>  I don't like seeing this:

> phoneNumber
>     "return the phone number instance variable"
>     ^phoneNumber

Neither do I, but for different reasons.

A) Who /cares/ whether the number is stored in an instvar ?

B) It's a good deal less obvious than it looks -- or at least it might be.
Consider this:

    phoneNumber
        "answer the phone number as a String of digits.
        Note that non-digit characters may be included either as
        separators, or in order to indicate hybrid local/international
        numbers.
        For instance:
             +44 (0) 1628 589262
        "
        ^ phoneNumber.

> Method comments can be a code smell.  They indicate that the code itself
> isn't clear enough.  Once it is clear enough, you can remove the comment
> because it's superfluous.

Funny that, I see /lack/ of comments as a code smell.  It hints to me that the
programmer is not thinking about the code, or is only thinking about it from a
single direction.  There are many indicators that a programmer is not fully on
the ball (sloppy layout for instance), one of the strongest is that they are
not seeing the code as it will appear to the working system (and the working
programmer coming after), but only as it happened to appear to them at the
instant they wrote it.  Tunnel vision can conceal an awful lot of ambiguity.

    -- chris


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andre Schnoor  
View profile  
 More options Mar 1 2006, 4:01 pm
Newsgroups: comp.lang.smalltalk
From: Andre Schnoor <nospam_so...@yahoo.com>
Date: Wed, 01 Mar 2006 22:01:02 +0100
Local: Wed, Mar 1 2006 4:01 pm
Subject: Re: About method comments
I really can't imagine to not comment code at all. I absolutely need to
comment my code in order to understand it *myself* after a while. I more
than once encountered the situation that, when browsing through
classes/subsystems I wrote years ago, I found myself reverse engineering
my own stuff.

I often write the comment prior to the code, being a part of the
structuring and modelling excercise.

As James Robertson pointed out, a communication problem specific to
Smalltalk is, that even straight forward code tends to spread its
functionality across several classes, which is not necessarily unveiling
the original intention of "the algorithm" behind it at a glance. This
finer granularity makes Smalltalk maintainable and extensible on the one
hand, but harder to read on the other hand.

I'd like to see clearly visible levels of method "privacy":

1 "private": used only by the instance or class itself
2 "intimate": used among closely related classes
3 "public": API available to everyone, likely to survive future releases
4 "entry": API for suggested top-level entry points, e.g. start or
shutdown a server, open a window, run an example, etc.

I have no idea how to indicate these levels in the IDE (colors?
filters?), but IMHO browsing a package with a "show only entry methods"
option would dramatically speed up the task of exploring other people's
code.

Andre


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mdr  
View profile  
 More options Mar 1 2006, 7:25 pm
Newsgroups: comp.lang.smalltalk
From: "mdr" <mrobe...@cincom.com>
Date: 1 Mar 2006 16:25:38 -0800
Local: Wed, Mar 1 2006 7:25 pm
Subject: Re: About method comments

>> The other aspect - at least for me, is that the tests are often much
>> better comments than the comments.
>This proven to be true for documentation or usage purpose, and is so
>because tests have gained momentum again during the last 2-3 years.
>But it doesn't apply for exploratory or self learning usage, which
>is the way most smalltalkers uses an Smalltalk (or at least used to do).

While tests can be helpful for understanding code, I don't think they
are really an adequate substitute for a good comment on a public
method. Reading a test is still reading code.

If I'm writing an application, I can work much more effectively if the
code I want to use has good class comments, a clearly-expressed API,
and method comments that explain the function of the method, what it
returns, any exceptional conditions that might arise, etc.

If the code in question lacks all of this and I'm expected to read the
tests, it's still a nuisance. In order to use the code, I must go off
and find the tests, load them, try and figure out which classes test
the methods in question. Basically, I'm clicking on "senders" over and
over, then reading a bunch of test methods, usually skipping all of the
initialization junk in the beginning of the test method, etc. I'm still
reading code to try and reconstruct the API definition of the class.

While I think TDD is a great idea, reading over a bunch of tests is
much less efficient than having well-written API documentation.

For those interested, I wrote a proposal several years back that
explores these issues in a bit more detail:

http://www.cincomsmalltalk.com/CincomSmalltalkWiki/Documentation+Stan...

Regards,

M. Roberts
Cincom Systems, Inc.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Reinout Heeck  
View profile  
 More options Mar 2 2006, 4:54 am
Newsgroups: comp.lang.smalltalk
From: Reinout Heeck <re...@desk.org>
Date: Thu, 02 Mar 2006 10:54:24 +0100
Local: Thurs, Mar 2 2006 4:54 am
Subject: Re: About method comments

My experience is that method comments are "invisible".

When intensively working to solve a problem our programmers only see the
code, they literally don't see the method comments.
As a consequence our image is littered with method comments like "Dummy
method template.  This was installed by the debugger define method
command.",  the programmers really don't see them, only when I point it out
does it enter their consciousness.

Apparently at the development stage method comments don't add value,
programmers block them out. Architecture is communicated differently,
mostly by pairing in our shop.

R
-


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Uppal  
View profile  
 More options Mar 2 2006, 5:23 am
Newsgroups: comp.lang.smalltalk
From: "Chris Uppal" <chris.up...@metagnostic.REMOVE-THIS.org>
Date: Thu, 2 Mar 2006 10:23:22 -0000
Local: Thurs, Mar 2 2006 5:23 am
Subject: Re: About method comments

Andre Schnoor wrote:
> I really can't imagine to not comment code at all. I absolutely need to
> comment my code in order to understand it *myself* after a while.

For me the need starts /as/ I write the code.  The comments are, amongst other
things, my ongoing design notes.

> I often write the comment prior to the code, being a part of the
> structuring and modelling exercise.

Yup.  That's the way it works.  Otherwise commenting is a chore rather than an
ongoing conversation with the reader.

> I'd like to see clearly visible levels of method "privacy":

> 1 "private": used only by the instance or class itself
> 2 "intimate": used among closely related classes
> 3 "public": API available to everyone, likely to survive future releases
> 4 "entry": API for suggested top-level entry points, e.g. start or
> shutdown a server, open a window, run an example, etc.

That's an interesting idea.  I think the principle distinction is between
"published" and "non-published", only the former implies any kind of contract
with the client code, or any constraint on future changes.  I.e. not about who
is "allowed" to use methods, but about what guarantees are provided (and to
whom).   But I like the idea of distinguishing the parts of the published API
that are central to using and understanding the module.

> I have no idea how to indicate these levels in the IDE (colors?
> filters?), but IMHO browsing a package with a "show only entry methods"
> option would dramatically speed up the task of exploring other people's
> code.

In Dolphin that could be done quite naturally with method categories (since
Dolphin doesn't have the absurd restriction that a method can be in only one
category), which should be simple enough.  Hmmm....

    -- chris


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yanni Chiu  
View profile  
 More options Mar 2 2006, 11:23 am
Newsgroups: comp.lang.smalltalk
From: Yanni Chiu <yanni-REMOVET...@rogers.com>
Date: Thu, 02 Mar 2006 11:23:26 -0500
Local: Thurs, Mar 2 2006 11:23 am
Subject: Re: About method comments

Reinout Heeck wrote:
> My experience is that method comments are "invisible".

That is my experience as well - whatever the programming language.
However, if I print out the code (which sometimes happens in other
languages), then I might read the comments. But reading the comments
is the last thing I do to figure out how code works.

Chris Uppal wrote:

 > For me the need starts /as/ I write the code.  The comments are, amongst other
 > things, my ongoing design notes.

That's really what they are: design notes. Maybe they belong with
the code, maybe they don't. If the code is not immediately clear,
but is well written, then you need to refer to design notes. It may
be convenient to have them right there, as code comments, but I don't
see a definitive argument that all code must have code comments.

Just my two cents.

--
Yanni Chiu


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bruce Badger  
View profile  
 More options Mar 2 2006, 5:00 pm
Newsgroups: comp.lang.smalltalk
From: Bruce Badger <bbad...@no.spam.openskills.com>
Date: Fri, 03 Mar 2006 09:00:20 +1100
Local: Thurs, Mar 2 2006 5:00 pm
Subject: Re: About method comments

On Wed, 01 Mar 2006 07:37:26 -0500, Bob Nemec wrote:
>> On thing that disturbs me everytime I see a presentation/screencast or
>> download some goodie, is the total lack of method/class comments.

> The rule that I follow is to comment intent, not action (the 'why', not the
> 'how').

Spot on, than man.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mdr  
View profile  
 More options Mar 2 2006, 7:35 pm
Newsgroups: comp.lang.smalltalk
From: "mdr" <mrobe...@cincom.com>
Date: 2 Mar 2006 16:35:11 -0800
Local: Thurs, Mar 2 2006 7:35 pm
Subject: Re: About method comments

> That's really what they are: design notes. Maybe they belong with
> the code, maybe they don't. If the code is not immediately clear,
> but is well written, then you need to refer to design notes. It may
> be convenient to have them right there, as code comments, but I don't
> see a definitive argument that all code must have code comments.

None of these claims are persuasive and here's why not.

First, remember that Smalltalk has no concept of an interface and makes
no distinction between public and private methods. The Smalltalk
language has no built-in support for expressing an API, and even the
conventions for naming protocols are *not* consistent across the
system. Method comments are sometimes the *only* information that
really distinguishes the public from private in a class. They are not
just design notes. They serve a role in defining the public interface
to the class.

You can, of course, choose not to follow these conventions, you don't
have to include method comments. However, this is deferring a cost.
Each developer who uses the class Z must now read over all of the code
to mentally reconstruct the API, and thus the time and effort required
to use Z go way up.

Remember also that the writers who produce documentation use method
comments to produce API or subsystem documentation. They need to know
what's public and what's not. If you don't include those comments, then
in practice the work flow breaks down. Writers do not always have the
time or training to reverse-engineer undocumented code. Often, the
documentation can't get written until the original developer can be
consulted to "explain" the class. This means sending e-mail messages
and opening job tickets just to get some basic information. If the
original developer left the company, the writers demote the priority of
that project because it takes too much time. No comments = work doesn't
get done. I can tell you from personal experience that all of this is a
*huge* waste of time.

Second, if comments are not "with the code", then it is more work (more
clicks, more hunting, typing, etc) to keep them maintained, more work
to use them later, more chance that the "notes" get lost or out of sync
with the code. Separating them also means it takes more attention to
focus on both comments and code at once. More attention means more
effort. Attention/focus are fundamental issues in the organization of a
system and the design of its tools.

In the VisualWorks browser, for example, we have always had a separate
code pane to show class comments. After many years of working with this
design, we are now dissatisfied with it. Why? It separates comments
from code. It is the seasoned opinion of our tools designer that we
need a better solution that doesn't force a separation between the two.

Next, "if the code is not immediately clear" - for who? The
implementor or the developers who want to use the code? These are often
not the same person and they often have totally different levels of
expertise. What is "clear" to one is often not at all clear to the
other, and the implementor is often a poor judge of what is clear for
others. This is part of the reason that there are "code reviews" that
involve several different people.

Finally, I would say that the argument is not that *all* code must have
comments, but that the code becomes more usable when comments are used
judiciously in public methods, and the cost of using the code goes
down. In private methods, comments can be used to capture the intention
of the design (as Bob Nemec put it in another part of this discussion,
they should express "the 'why', not the 'how'"), and this helps to make
it more maintainable in the future.

M. Roberts
Cincom Systems, Inc.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mdr  
View profile  
 More options Mar 2 2006, 7:39 pm
Newsgroups: comp.lang.smalltalk
From: "mdr" <mrobe...@cincom.com>
Date: 2 Mar 2006 16:39:56 -0800
Local: Thurs, Mar 2 2006 7:39 pm
Subject: Re: About method comments

> Architecture is communicated differently, mostly by pairing in our shop.

And that communication breaks down for the first developer who isn't
pairing with the guys who wrote the code.

If you're running a small, closed shop, then maybe this doesn't matter.
But if the code is to be used by somebody in another group, outside
your shop, then it could be a problem.

M


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yanni Chiu  
View profile  
 More options Mar 2 2006, 8:08 pm
Newsgroups: comp.lang.smalltalk
From: Yanni Chiu <yanni-REMOVET...@rogers.com>
Date: Thu, 02 Mar 2006 20:08:25 -0500
Local: Thurs, Mar 2 2006 8:08 pm
Subject: Re: About method comments

mdr wrote:
>>Architecture is communicated differently, mostly by pairing in our shop.

> And that communication breaks down for the first developer who isn't
> pairing with the guys who wrote the code.

> If you're running a small, closed shop, then maybe this doesn't matter.
> But if the code is to be used by somebody in another group, outside
> your shop, then it could be a problem.

This is starting to sound like big-shop vs. small-shop
(i.e. big team, lots of teams, heavy weight process vs.
an agile shop).

Can we say that "code comments are required" is really
a local development process decision, not a universal
axiom of good coding.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yanni Chiu  
View profile  
 More options Mar 2 2006, 8:58 pm
Newsgroups: comp.lang.smalltalk
From: Yanni Chiu <yanni-REMOVET...@rogers.com>
Date: Thu, 02 Mar 2006 20:58:09 -0500
Local: Thurs, Mar 2 2006 8:58 pm
Subject: Re: About method comments
So much to "comment" on. I'll just make a few.

mdr wrote:
> First, remember that Smalltalk has no concept of an interface and makes
> no distinction between public and private methods.

Aren't method categories sufficient. You would rather have
a method comment with "public" or "private", that you have
to select the method to see.

> Attention/focus are fundamental issues in the organization of a
> system and the design of its tools.

Right. And IMHO comments often just get in the way of reading the code.
When you look at a webpage, do you *see* the advertisements. I almost
never notice them; instead, the content (if any) is what I immediately
focus on. Wouldn't you rather see the webpage without the advertisements?

> Next, "if the code is not immediately clear" - for who? The
> implementor or the developers who want to use the code?

An implicit assumption seems to be that the code is being
delivered to developers in far away lands. For a Smalltalk
vendor, that might be true, and the cost of well documented
code needs to be factored in. For other cases, the cost of writing
and maintaining code comments needs to be weighed against the
potential benefits. Also needing consideraton are alternative
ways (and maybe more effective ways), other than code comments,
to transfer the knowledge.

> This is part of the reason that there are "code reviews" that
> involve several different people.

In the one case that I encountered a formal code review process that
involved several people, the overall project was a disaster.

> Finally, I would say that the argument is not that *all* code must have
> comments, but that the code becomes more usable when comments are used
> judiciously in public methods, and the cost of using the code goes
> down.

This statement I agree with, to some degree. But I thought someone
was advocating that simple accessor methods should be commented.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 77   Newer >
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google