Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Code comments - how old is your code?

Code comments - how old is your code?

Scheduled Pinned Locked Moved The Lounge
question
45 Posts 32 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Sander RosselS Sander Rossel

    I never write comments. As it happens, I just hired a junior and he loves comments. He writes all sorts of useless comments like // set the variable. I told him not to do that because we can read code. Point is, he doesn't read code that well yet and the comments help him see what happens. He also writes comments like // why does this work? So he'll be reminded to ask me. One time we rearranged some code and all of his comments had to moved and/or changed as well. People sometimes forget that comments are just like code, they're hard to write well and they need maintainance just like code. Comment maintainance is rare and so most of the time comments are just as unclear as the code, outdated or even plain wrong. I rarely trust a comment and when I see them I'll try to change the code so they won't be necessary anymore. That's not to say I never write them. I once worked with a library (Crystal Reports, 'nuff said) where setting one property would set another one to null. So the order in which I set specific properties had to be very specific too. Needless to say I wrote a comment saying // do not switch these lines around, the person who wrote this library was drunk and drugged and the order somehow matters.

    Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #33

    His commenting may be providing him with "thinking space" ... the same way some people doodle. I expect he'll outgrow it.

    "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

    1 Reply Last reply
    0
    • _ _WinBase_

      one of my products is 23 years old now since i launched it (started writing it in the late 90's), written in vb6. I sold over 1000 copies back in the day (and even sold a new one a year ago). I still have quite a few users who pay support (and a few who don't) and dont see the need to change or upgrade to my newer version coz it does everything they want and they are comfortable with it. my newer version was launched 2010 and is a net framework product, so i suppose 13yo for that is getting quite aged these days, but again i have loads of customers on it. I am a compulsive 'commenter' (always have been) since the 70's, even though the code is never likely to be seen by anyone else, and now i'm in my 60's (and still coding), the grey matter aint as sharp as it once was there's a definate advantage when i need to make mods, and imho code that aint documented aint complete. GL

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #34

      Yes ... commenting can be seen as an investment in terms of when it comes time to "sell the company". One man's noise is another man's salvation.

      "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

      1 Reply Last reply
      0
      • C charlieg

        Just hit an interesting thought and would like veterans' perspective. I support a product that has over 20+ years of accumulated history. As I was writing some comments to explain why or what some code was doing, I've found that the #1 person who read my comments was me. Do comments even matter any more, or am I flattering myself? Filed under hmmmm

        Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

        M Offline
        M Offline
        Marc Clifton
        wrote on last edited by
        #35

        Definitely for myself, though most of the comments nowadays seem to be // TODO: fix this bug :laugh:

        Latest Articles:
        A Lightweight Thread Safe In-Memory Keyed Generic Cache Collection Service A Dynamic Where Implementation for Entity Framework

        1 Reply Last reply
        0
        • C charlieg

          Just hit an interesting thought and would like veterans' perspective. I support a product that has over 20+ years of accumulated history. As I was writing some comments to explain why or what some code was doing, I've found that the #1 person who read my comments was me. Do comments even matter any more, or am I flattering myself? Filed under hmmmm

          Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

          S Offline
          S Offline
          sasadler
          wrote on last edited by
          #36

          I started programming in the late 70's so the only real option was assembly code for the devices I was programming for. It pretty much cemented the idea that I should be commenting my code. It's a practice that I kept throughout my career. Commenting was for my own benefit and for anyone who might be modifying my code. I always made the assumption that the person inheriting one of my projects wouldn't necessarily be a very knowledgeable programmer so good commenting was needed.

          1 Reply Last reply
          0
          • C charlieg

            Just hit an interesting thought and would like veterans' perspective. I support a product that has over 20+ years of accumulated history. As I was writing some comments to explain why or what some code was doing, I've found that the #1 person who read my comments was me. Do comments even matter any more, or am I flattering myself? Filed under hmmmm

            Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

            J Offline
            J Offline
            jochance
            wrote on last edited by
            #37

            There has been a fairly recent crusade against comments. Some claim code should be self-documenting and that comments are somehow evil. You know what's documenting? Documentation... like comments. Self-documenting? WTF? There's nearly zero code ever written that explains WHY it does what it does or WHY it was changed to do otherwise. I guess you can enforce tying commits to cards and chase down the commit that changed the code and then the card that brought that commit. Alternatively, maybe a comment isn't such a bad thing. Has nobody written a VS plugin to just turn all comments on/off? Is it really just that developers hate documentation so much they'd rather claim their code does all the documentation for them? Because that's just how great their code is? Do people not use XML comments so people get intellisense on what they are calling? Do they think making that block descriptive is some massive chore?

            T B 2 Replies Last reply
            0
            • Sander RosselS Sander Rossel

              Never say never :laugh: I write them like once every few years whenever I find some weird ass third party component I really can't ditch :)

              Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

              T Offline
              T Offline
              trønderen
              wrote on last edited by
              #38

              ... say ... ?

              1 Reply Last reply
              0
              • W WPerkins

                Absolutely do matter, anyone tells you otherwise does not have 40 years experience. The concept of "self-documenting" code is nice, sometimes do-able. But the time it takes to write a comment (or a few comments) for code that is non-trivial is saved many times over as that code is revisited in coming *decades* (think the build up to Y2K when we needed to figure out code written between 1965 and 1990). Not commenting is short-sighted and, I think, selfish and arrogant of the developer who assumes: 1) later developers are as good as he thinks he is 2) his time is too valuable to be wasted doing non-coding tasks. Sorry, personal pet peeve of mine picking up process control C code written in the mid-1990s with zero comments that does not work.

                T Offline
                T Offline
                trønderen
                wrote on last edited by
                #39

                WPerkins wrote:

                The concept of "self-documenting" code is nice, sometimes do-able.

                "Self-documenting APL code", is than an oxymoron or not?

                1 Reply Last reply
                0
                • C charlieg

                  Just hit an interesting thought and would like veterans' perspective. I support a product that has over 20+ years of accumulated history. As I was writing some comments to explain why or what some code was doing, I've found that the #1 person who read my comments was me. Do comments even matter any more, or am I flattering myself? Filed under hmmmm

                  Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                  J Offline
                  J Offline
                  Jeremy Falcon
                  wrote on last edited by
                  #40

                  Comment for yourself. Some devs will read them... some... if they are coherent and make sense to a different person. And then some devs refuse to take any initiative... so good luck with that.

                  Jeremy Falcon

                  1 Reply Last reply
                  0
                  • J jochance

                    There has been a fairly recent crusade against comments. Some claim code should be self-documenting and that comments are somehow evil. You know what's documenting? Documentation... like comments. Self-documenting? WTF? There's nearly zero code ever written that explains WHY it does what it does or WHY it was changed to do otherwise. I guess you can enforce tying commits to cards and chase down the commit that changed the code and then the card that brought that commit. Alternatively, maybe a comment isn't such a bad thing. Has nobody written a VS plugin to just turn all comments on/off? Is it really just that developers hate documentation so much they'd rather claim their code does all the documentation for them? Because that's just how great their code is? Do people not use XML comments so people get intellisense on what they are calling? Do they think making that block descriptive is some massive chore?

                    T Offline
                    T Offline
                    trønderen
                    wrote on last edited by
                    #41

                    That crusade against comments has been going on for many years, where I have been. The major exception is huge copyright/left comment blocks topping every source file and extensive comment blocks heading every function, repeating the function name, the the types and names of all parameters of the function declaration, only doing it in 10-20 lines instead of one, cluttered with typographic markup. I have been heavily criticized for my habit of adding a lot of explanatory ("why") end-of-line comments - end-of-line because I like to see the entire function/method in a single screenful rather than three. I also have a habit of aligning the comments from col 80, so that they do not visually disturb the code itself - you look at the comments (only) if you wonder "why". A number of my critics also love to open three source file windows side by side, so narrow that they usually won't see my comments, which are outside of their windows :-)

                    1 Reply Last reply
                    0
                    • J jochance

                      There has been a fairly recent crusade against comments. Some claim code should be self-documenting and that comments are somehow evil. You know what's documenting? Documentation... like comments. Self-documenting? WTF? There's nearly zero code ever written that explains WHY it does what it does or WHY it was changed to do otherwise. I guess you can enforce tying commits to cards and chase down the commit that changed the code and then the card that brought that commit. Alternatively, maybe a comment isn't such a bad thing. Has nobody written a VS plugin to just turn all comments on/off? Is it really just that developers hate documentation so much they'd rather claim their code does all the documentation for them? Because that's just how great their code is? Do people not use XML comments so people get intellisense on what they are calling? Do they think making that block descriptive is some massive chore?

                      B Offline
                      B Offline
                      Br Bill
                      wrote on last edited by
                      #42

                      This. 100% this.

                      1 Reply Last reply
                      0
                      • C charlieg

                        Just hit an interesting thought and would like veterans' perspective. I support a product that has over 20+ years of accumulated history. As I was writing some comments to explain why or what some code was doing, I've found that the #1 person who read my comments was me. Do comments even matter any more, or am I flattering myself? Filed under hmmmm

                        Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                        C Offline
                        C Offline
                        charlieg
                        wrote on last edited by
                        #43

                        I guess I should have provided context on what I mean as a comment. For as long as I've been writing code, I outgrew quickly code comments that say "increment the pointer" and other trivial stuff. I also like *limited* Hungarian notation: certain prefixes that over time just help me scan the code. Years ago, I picked up the habit that every pointer begins with a lower case p. Key was readability. As for oxygen and other tools like that, they sometimes help understand the overall system (especially call trees) but development tools have made such advancements that most of the doc has been replaced by tool features (hovering over a variable for example). The best tool I've ever used is Understand from SciTools. Unfortunately, they moved from a perm. license model to monthly fees, pricing it out of my market. Rather than what, I try to explain why the code does what it does. Example of the table of data - that's what and you can infer why. In my case, I have a piece of common code that runs on 4 different platforms. Thelatest platform has some issues to be worked around, and I found myself trying to explain why. It then occurred to me that I knew the product was reaching end of life, no one will likely read this, just comment in the SVN commit. After reading all of the replies to my question, it might be wordier, but breaking up the code into 4 different methods (each supporting a specific device) is probably the cleaner approach. Thanks for the insights.

                        Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                        1 Reply Last reply
                        0
                        • C charlieg

                          Just hit an interesting thought and would like veterans' perspective. I support a product that has over 20+ years of accumulated history. As I was writing some comments to explain why or what some code was doing, I've found that the #1 person who read my comments was me. Do comments even matter any more, or am I flattering myself? Filed under hmmmm

                          Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                          O Offline
                          O Offline
                          OldDBA
                          wrote on last edited by
                          #44

                          Sometime in the 1970s one of our users reported a problem entering a date for a future event. The code was not written by us, but we had the source, so I pulled up the code to see how it worked. I found this comment (PDP-10 assembler) "Thirty days hath September, all the rest I can't remember, except February which never works anyway" There was no code to handle leap year! At least the comment helped us know we were in the right place. That isn't the worst comment I found in code from that source, but the worst would violate nsfw rules.

                          C 1 Reply Last reply
                          0
                          • O OldDBA

                            Sometime in the 1970s one of our users reported a problem entering a date for a future event. The code was not written by us, but we had the source, so I pulled up the code to see how it worked. I found this comment (PDP-10 assembler) "Thirty days hath September, all the rest I can't remember, except February which never works anyway" There was no code to handle leap year! At least the comment helped us know we were in the right place. That isn't the worst comment I found in code from that source, but the worst would violate nsfw rules.

                            C Offline
                            C Offline
                            charlieg
                            wrote on last edited by
                            #45

                            I like it!

                            Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups