DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Actually, I don't hate comments ... I just don't read yours ;-)

  1. #1
    Heinz Kabutz Guest

    Actually, I don't hate comments ... I just don't read yours ;-)


    My message in my article (http://www.smotricz.com/kabutz/Issue039.html)
    was that if you are going to write a comment, I will only read it as a
    last resort. The first thing I will do is read through your code, since
    that should be clear enough to understand easily. If I cannot understand
    that, I will look at your unit tests (that hopefully exist!) Once all else
    fails, I will look at your comment to try and make sense of it. At this
    point in time, I usually am already wondering why your code was so complex
    that I had to do that, and I'm cursing you for trying to be too clever.

    Have a look at some of the comments in the JDK JavaDocs. How often do we
    really read them? I must say that I usually only use intellisense and
    code browsing when working with the JDK, and occasionally I will read the
    comments put there by developers who had to.

    The same thing applies with maintaining other people's code. When I code,
    I write such nasty unit tests, that if you change anything in my code that
    breaks one of my assumptions (which would be in a comment, btw), that the
    unit tests will fail. You as the maintenance programmer have landed in
    maintenance heaven. You can change my methods as you feel fit, and if that
    change breaks other code, the unit test will tell you at the next compile.
    (BTW, unit tests obviously get run at every build...)

    I also did not say that I don't write comments. I will always write a
    comment while I code something to make it easier for future users of my
    classes to maintain. The best way of course is to first write the comment,
    then the unit test, and lastly the method. In practice, I usually write
    a
    scant comment, the method and unit tests.

    I believe that good comments and good code and good unit tests is what
    makes coding worthwhile.

    Regards

    Heinz

  2. #2
    MarkN Guest

    Re: Actually, I don't hate comments ... I just don't read yours ;-)


    Heinz,
    I had re-read your article after reading some of the posts here and I really
    thought about how useful comments are to me. I was going to post something
    like this explaination (it is pretty much how I feel) because I feel most
    (if not all) have misread and misunderstood your article. Kind of proves
    your point about the usefullness of comments.


    Mark


  3. #3
    Anthony Gorli Guest

    Re: Actually, I don't hate comments ... I just don't read yours ;-)


    >When I code,
    >I write such nasty unit tests, that if you change anything in my code that
    >breaks one of my assumptions (which would be in a comment, btw), that the
    >unit tests will fail. You as the maintenance programmer have landed in
    >maintenance heaven. You can change my methods as you feel fit, and if that
    >change breaks other code, the unit test will tell you at the next compile.
    >(BTW, unit tests obviously get run at every build...)


    How do you do run your test units at every build? Do you use Jakarta's Cactus...or
    is there an intergrated feature in the JDK that allows you to do this?



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center