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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. The Lounge
  3. With comments like this, no wonder commenting gets a bad reputation

With comments like this, no wonder commenting gets a bad reputation

Scheduled Pinned Locked Moved The Lounge
question
30 Posts 16 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.
  • B B Clay Shannon

    I ran across this in some legacy code, and I hereby submit it to "the most redundant/superfluous code comment contest": // Check connection checkConnection(); Why do I hear, in my mind's ear, Jim Nabors as Gomer Pyle drawling "Surprise, surprise!" when I see this comment?

    P Offline
    P Offline
    PIEBALDconsult
    wrote on last edited by
    #19

    // Whereas we wish for this application to interact with a database // and whereas such interaction will require a connection to the server and instance of said database // and whereas a connection of this type relies on many fluctuating unknowns within the server and network infrastructure // and further, given the business-critical nature of this application and its associated interaction with the database // it has therefore been determined that checking whether or not such a connection can be successfully negotiated as early as possible // in the event that such a connection cannot be negotiated, then remediatory actions may be activated in a more timely manner than otherwise feasible checkConnection();

    1 Reply Last reply
    0
    • B B Clay Shannon

      I ran across this in some legacy code, and I hereby submit it to "the most redundant/superfluous code comment contest": // Check connection checkConnection(); Why do I hear, in my mind's ear, Jim Nabors as Gomer Pyle drawling "Surprise, surprise!" when I see this comment?

      Sander RosselS Offline
      Sander RosselS Offline
      Sander Rossel
      wrote on last edited by
      #20

      Found stuff like that too.

      ' Save the customer.
      SaveCustomer()

      Even worse:

      ' Save the customer.
      SaveProduct()

      The code was copy/pasted and then changed, but of course the comments were overlooked. But that's not all:

      ' A helper variable
      Dim helper As String
      helper = "Something"
      ' Lots of code here...
      If someCondition Then
      MessageBox.Show(helper)
      End If

      Yes, in that last part the 'helper variable' is actually a constant string that may or may not be used further in the function... Good thing it was commented :doh: And you wonder why VB has a bad name? This has nothing to do with VB, but with coders that can't code...

      It's an OO world.

      public class SanderRossel : Lazy<Person>
      {
      public void DoWork()
      {
      throw new NotSupportedException();
      }
      }

      P 1 Reply Last reply
      0
      • J Jeremy Falcon

        It gets even better. I've even seen something akin to this in Basic...

        ' assign 5 to x
        Let x = 5

        Jeremy Falcon

        Sander RosselS Offline
        Sander RosselS Offline
        Sander Rossel
        wrote on last edited by
        #21

        I've seen something like that, except the writer of the comment started about memory and how it works internally... Except the comment clearly showed the writer had no clue what actually happened :laugh: Can't remember where I've seen it or what the comment said though :doh:

        It's an OO world.

        public class SanderRossel : Lazy<Person>
        {
        public void DoWork()
        {
        throw new NotSupportedException();
        }
        }

        1 Reply Last reply
        0
        • Sander RosselS Sander Rossel

          Found stuff like that too.

          ' Save the customer.
          SaveCustomer()

          Even worse:

          ' Save the customer.
          SaveProduct()

          The code was copy/pasted and then changed, but of course the comments were overlooked. But that's not all:

          ' A helper variable
          Dim helper As String
          helper = "Something"
          ' Lots of code here...
          If someCondition Then
          MessageBox.Show(helper)
          End If

          Yes, in that last part the 'helper variable' is actually a constant string that may or may not be used further in the function... Good thing it was commented :doh: And you wonder why VB has a bad name? This has nothing to do with VB, but with coders that can't code...

          It's an OO world.

          public class SanderRossel : Lazy<Person>
          {
          public void DoWork()
          {
          throw new NotSupportedException();
          }
          }

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #22

          Sander Rossel wrote:

          coders that can't code...

          I disagree... the whole purpose of code is to not be readable. :-D

          1 Reply Last reply
          0
          • B B Clay Shannon

            I ran across this in some legacy code, and I hereby submit it to "the most redundant/superfluous code comment contest": // Check connection checkConnection(); Why do I hear, in my mind's ear, Jim Nabors as Gomer Pyle drawling "Surprise, surprise!" when I see this comment?

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

            Most comments (or error messages) are written by the same master of the obvious.

            The language is JavaScript. that of Mordor, which I will not utter here
            I hold an A-7 computer expert classification, Commodore. I'm well acquainted with Dr. Daystrom's theories and discoveries. The basic design of all our ship's computers are JavaScript.

            1 Reply Last reply
            0
            • B B Clay Shannon

              I ran across this in some legacy code, and I hereby submit it to "the most redundant/superfluous code comment contest": // Check connection checkConnection(); Why do I hear, in my mind's ear, Jim Nabors as Gomer Pyle drawling "Surprise, surprise!" when I see this comment?

              J Offline
              J Offline
              Joe Woodbury
              wrote on last edited by
              #24

              My favorite was akin to this: // Actually means hasn't been modified except in the function in file xxx.c bool isModified = false; The comment was actually accurate and isModified really did switch meaning multiple times throughout the code.

              1 Reply Last reply
              0
              • B B Clay Shannon

                I ran across this in some legacy code, and I hereby submit it to "the most redundant/superfluous code comment contest": // Check connection checkConnection(); Why do I hear, in my mind's ear, Jim Nabors as Gomer Pyle drawling "Surprise, surprise!" when I see this comment?

                T Offline
                T Offline
                thrakazog
                wrote on last edited by
                #25

                I prefer the obvious to comments that are lies. Given time and a few updates, most of them head that way. //NEVER DO X. Code evolves to do X when the following condition are true.... Comment never updated.

                Play my game Gravity: Android[^], Windows Phone 7[^]

                J 1 Reply Last reply
                0
                • T thrakazog

                  I prefer the obvious to comments that are lies. Given time and a few updates, most of them head that way. //NEVER DO X. Code evolves to do X when the following condition are true.... Comment never updated.

                  Play my game Gravity: Android[^], Windows Phone 7[^]

                  J Offline
                  J Offline
                  jeron1
                  wrote on last edited by
                  #26

                  Amen brother! I recently had the extreme headache pleasure of looking at assembler code that had commenting issues. Nothing like taking a 5 minute task and making it a half day project. :mad:

                  "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst

                  1 Reply Last reply
                  0
                  • B B Clay Shannon

                    I ran across this in some legacy code, and I hereby submit it to "the most redundant/superfluous code comment contest": // Check connection checkConnection(); Why do I hear, in my mind's ear, Jim Nabors as Gomer Pyle drawling "Surprise, surprise!" when I see this comment?

                    R Offline
                    R Offline
                    Rage
                    wrote on last edited by
                    #27

                    This code was sponsored by the Ministry of Obvious and Redundancy and Redundancy.

                    ~RaGE();

                    I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus Entropy isn't what it used to.

                    B 1 Reply Last reply
                    0
                    • R Rage

                      This code was sponsored by the Ministry of Obvious and Redundancy and Redundancy.

                      ~RaGE();

                      I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus Entropy isn't what it used to.

                      B Offline
                      B Offline
                      B Clay Shannon
                      wrote on last edited by
                      #28

                      I've changed the name of the method from checkConnection() to openConnectionIfPossibleAndNecessary() because that is what it really does (checks for not null not already open, and then provisionally (no pun intended) creates a new connection).

                      1 Reply Last reply
                      0
                      • Mike HankeyM Mike Hankey

                        Does seem excessively redundant! :) I think even Gomer would know not to do this.

                        Have you ever just looked at someone and knew the wheel was turning but the hamster was dead? Trying to understand the behavior of some people is like trying to smell the color 9.

                        R Offline
                        R Offline
                        Roger Wright
                        wrote on last edited by
                        #29

                        Maybe, but I'll bet if you looked closely at the implementation code, it might draw a check box onscreen next to the word 'Connection" and place a checkmark into it. Encapsulation can do that! ;P

                        Will Rogers never met me.

                        1 Reply Last reply
                        0
                        • B B Clay Shannon

                          I ran across this in some legacy code, and I hereby submit it to "the most redundant/superfluous code comment contest": // Check connection checkConnection(); Why do I hear, in my mind's ear, Jim Nabors as Gomer Pyle drawling "Surprise, surprise!" when I see this comment?

                          M Offline
                          M Offline
                          Mark_Wallace
                          wrote on last edited by
                          #30

                          The thing is: If you use something like JavaDoc or DoxyGen, comments like that can actually be useful.

                          I wanna be a eunuchs developer! Pass me a bread knife!

                          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