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.
  • L Lost User

    That's worth more points if it turns out that checkConnection actually does not check connection.

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

    It tries to open a connection; the catch block displays an err msg if it fails.

    I L 2 Replies Last reply
    0
    • B B Clay Shannon

      It tries to open a connection; the catch block displays an err msg if it fails.

      I Offline
      I Offline
      Ian Shlasko
      wrote on last edited by
      #9

      Well then it's named wrong... It should have been:

      // Check Connection
      tryToOpenConnectionAndDisplayAnErrorMessageIfItFailsThankYouAndGoodnight();

      Proud to have finally moved to the A-Ark. Which one are you in?
      Author of the Guardians Saga (Sci-Fi/Fantasy novels)

      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?

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

        // Check connection checkConnection(); // Cash connection checkConnection(); // Credit Card connection checkConnection(); // Debit Card connection checkConnection(); :-D

        Richard DeemingR 1 Reply Last reply
        0
        • B B Clay Shannon

          It tries to open a connection; the catch block displays an err msg if it fails.

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

          B. Clay Shannon wrote:

          It tries to open a connection

          That was my first hunch. :((

          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

          1 Reply Last reply
          0
          • P PIEBALDconsult

            // Check connection checkConnection(); // Cash connection checkConnection(); // Credit Card connection checkConnection(); // Debit Card connection checkConnection(); :-D

            Richard DeemingR Offline
            Richard DeemingR Offline
            Richard Deeming
            wrote on last edited by
            #12

            PIEBALDconsult wrote:

            // Cheque connection chequeConnection();

            FTFY. ;P


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

            P 1 Reply Last reply
            0
            • Richard DeemingR Richard Deeming

              PIEBALDconsult wrote:

              // Cheque connection chequeConnection();

              FTFY. ;P


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

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

              czechConnection frenchConnection

              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
                Jeremy Falcon
                wrote on last edited by
                #14

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

                ' assign 5 to x
                Let x = 5

                Jeremy Falcon

                L Sander RosselS 2 Replies 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?

                  N Offline
                  N Offline
                  Nemanja Trifunovic
                  wrote on last edited by
                  #15

                  Ughhh. It should really be: // Check connection check_connection();

                  utf8-cpp

                  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
                    #16

                    Just because he's a pro at naming a function doesn't mean the comment is bad.

                    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

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

                      Or:

                      // assign 0.1 to x
                      double x = 0.1;

                      Which is actually a lie.

                      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?

                        S Offline
                        S Offline
                        Slacker007
                        wrote on last edited by
                        #18

                        I don't always comment my code, but when I do... //TODO: insert comment here.

                        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?

                          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
                                          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