Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. code verbosity severely bugs my ADD and OCD
Forum Updated to NodeBB v4.3 + New Features

code verbosity severely bugs my ADD and OCD

Scheduled Pinned Locked Moved Unsolved C++ Gurus
33 Posts 10 Posters 4.5k Views 5 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.
  • Kent-DorfmanK Offline
    Kent-DorfmanK Offline
    Kent-Dorfman
    wrote on last edited by
    #1

    Why are modern coders, as a group, always so enamored with writing extremely verbose code?...I have an extremely short attention span...ie A.D.D...LOL
    Unfortunately that is a common "problem" with modern day coders, the impression that verbosity is somehow superior. Think Readers Digest condensed version, not full novel. Sometimes I really miss FORTRAN. LOL

    The argument against 20...30...40 character identifiers: USE SMALLER SCOPE!!! Nothing bugs my OCD more than seeing a 30+ character variable or type name listed over and over again...often with a single word in the middle of it transposed to something else.

    I wonder whether subconsciously coders feel that they are being graded on how verbose they can be...Hey guys...you get more kudos from me by writing the most elegant and concise code you can that doesn't introduce side-effects.

    If you want to be verbose then do it in comments, not code...code does NOT replace proper use of inline commenting.

    JonBJ J.HilkJ K 3 Replies Last reply
    0
    • Kent-DorfmanK Kent-Dorfman

      Why are modern coders, as a group, always so enamored with writing extremely verbose code?...I have an extremely short attention span...ie A.D.D...LOL
      Unfortunately that is a common "problem" with modern day coders, the impression that verbosity is somehow superior. Think Readers Digest condensed version, not full novel. Sometimes I really miss FORTRAN. LOL

      The argument against 20...30...40 character identifiers: USE SMALLER SCOPE!!! Nothing bugs my OCD more than seeing a 30+ character variable or type name listed over and over again...often with a single word in the middle of it transposed to something else.

      I wonder whether subconsciously coders feel that they are being graded on how verbose they can be...Hey guys...you get more kudos from me by writing the most elegant and concise code you can that doesn't introduce side-effects.

      If you want to be verbose then do it in comments, not code...code does NOT replace proper use of inline commenting.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Kent-Dorfman
      Things have gone downhill since small computers had more than a few K of memory for programs to fit into, and you could afford to have long variable names, and comments.

      1 Reply Last reply
      0
      • Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by
        #3

        I don't understand. In the BASIC interpretter world your comments ended up in RAM, but in modern well-endowed machines it all compiles to the same machine code...My point of contention is that modern devs seem to favor ridiuclously verbose machine instructions, over good solid internal commenting of code.

        At a previous job it wasn't uncommon to see 200+ lines of long winded deeply nested shared memory structure names, and verbose field names, where often a single word in the middle of the struct name may be changed...I got yelled at because I refactored one such section of code to use shorthand pointers to the records so I only had to worry about the field names.

        ie

        ApActiveAvionicsDisplayPower->CurrentLoadAmps
        

        became

        auto ptr=ApActiveAvionicsDisplayPower;
        ptr->PreviousLoadAmps = ptr->CurrentLoadAmps;
        ptr->CurrentLoadAmps = 0.0;
        

        and the like

        JonBJ 1 Reply Last reply
        0
        • Kent-DorfmanK Kent-Dorfman

          I don't understand. In the BASIC interpretter world your comments ended up in RAM, but in modern well-endowed machines it all compiles to the same machine code...My point of contention is that modern devs seem to favor ridiuclously verbose machine instructions, over good solid internal commenting of code.

          At a previous job it wasn't uncommon to see 200+ lines of long winded deeply nested shared memory structure names, and verbose field names, where often a single word in the middle of the struct name may be changed...I got yelled at because I refactored one such section of code to use shorthand pointers to the records so I only had to worry about the field names.

          ie

          ApActiveAvionicsDisplayPower->CurrentLoadAmps
          

          became

          auto ptr=ApActiveAvionicsDisplayPower;
          ptr->PreviousLoadAmps = ptr->CurrentLoadAmps;
          ptr->CurrentLoadAmps = 0.0;
          

          and the like

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Kent-Dorfman said in code verbosity severely bugs my ADD and OCD:

          I don't understand

          It was only meant humorously :)

          1 Reply Last reply
          1
          • Kent-DorfmanK Kent-Dorfman

            Why are modern coders, as a group, always so enamored with writing extremely verbose code?...I have an extremely short attention span...ie A.D.D...LOL
            Unfortunately that is a common "problem" with modern day coders, the impression that verbosity is somehow superior. Think Readers Digest condensed version, not full novel. Sometimes I really miss FORTRAN. LOL

            The argument against 20...30...40 character identifiers: USE SMALLER SCOPE!!! Nothing bugs my OCD more than seeing a 30+ character variable or type name listed over and over again...often with a single word in the middle of it transposed to something else.

            I wonder whether subconsciously coders feel that they are being graded on how verbose they can be...Hey guys...you get more kudos from me by writing the most elegant and concise code you can that doesn't introduce side-effects.

            If you want to be verbose then do it in comments, not code...code does NOT replace proper use of inline commenting.

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @Kent-Dorfman

            to be honest, I like to read my code as a text/novel from left to right, so you understand exactly what is happening while reading it

            take this function for example

            void resendPendingDatagram()
            {
                if(retryCount() < maxNumberOfRetries()){
                        setRetryCount(retryCount() +1);
                
                        m_pendingDatagram.clearResponseBuffer();
                        sendDatagram(m_pendingDatagram);
                    } else {
                        stopTimeouts();
                
                        setError(tr("All retries exhausted"), MceDiscardedDatagram);
                    }
            }
            

            obviously very verbose naming of members and functions. but just from reading left to right top to bottom spelling symbols out, you get a comprehensive description of what is happening.

            If the retry count is less then the max number of retries*, then* increase the retry count by one, clear the response buffer and resend the pending datagram
            else (if not) stop the timeouts and set an error

            Obviously its not perfect, but I try :D

            And in my opinion, much clearer than auto ptr, int count, i, m_data etc

            obviously I agree, that ApActiveAvionicsDisplayPower and similar is not that helpful as a name


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            jsulmJ 1 Reply Last reply
            4
            • J.HilkJ J.Hilk

              @Kent-Dorfman

              to be honest, I like to read my code as a text/novel from left to right, so you understand exactly what is happening while reading it

              take this function for example

              void resendPendingDatagram()
              {
                  if(retryCount() < maxNumberOfRetries()){
                          setRetryCount(retryCount() +1);
                  
                          m_pendingDatagram.clearResponseBuffer();
                          sendDatagram(m_pendingDatagram);
                      } else {
                          stopTimeouts();
                  
                          setError(tr("All retries exhausted"), MceDiscardedDatagram);
                      }
              }
              

              obviously very verbose naming of members and functions. but just from reading left to right top to bottom spelling symbols out, you get a comprehensive description of what is happening.

              If the retry count is less then the max number of retries*, then* increase the retry count by one, clear the response buffer and resend the pending datagram
              else (if not) stop the timeouts and set an error

              Obviously its not perfect, but I try :D

              And in my opinion, much clearer than auto ptr, int count, i, m_data etc

              obviously I agree, that ApActiveAvionicsDisplayPower and similar is not that helpful as a name

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @J-Hilk Yes, I also like names for variables, methods and classes which tell you what it is about. There is no problem to use short names in some cases (like "i" in a for loop), but else it is better to write easy to understand code. Code is read more often than written, so it is more important to write understandable code than having short names.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              JKSHJ 1 Reply Last reply
              3
              • jsulmJ jsulm

                @J-Hilk Yes, I also like names for variables, methods and classes which tell you what it is about. There is no problem to use short names in some cases (like "i" in a for loop), but else it is better to write easy to understand code. Code is read more often than written, so it is more important to write understandable code than having short names.

                JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on last edited by JKSH
                #7

                @jsulm said in code verbosity severely bugs my ADD and OCD:

                it is more important to write understandable code than having short names.

                +1

                The ideal is to be "easy to read" and "easy to understand", not to be "verbose".

                • Too short => Difficult to read
                • Too long => Difficult to read
                • Just right => Easy to read

                @Kent-Dorfman said in code verbosity severely bugs my ADD and OCD:

                a 30+ character variable or type name listed over and over again...often with a single word in the middle of it transposed to something else.

                This sounds horribly difficult to read. I wouldn't want to work on such a code base

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                JonBJ 1 Reply Last reply
                4
                • JKSHJ JKSH

                  @jsulm said in code verbosity severely bugs my ADD and OCD:

                  it is more important to write understandable code than having short names.

                  +1

                  The ideal is to be "easy to read" and "easy to understand", not to be "verbose".

                  • Too short => Difficult to read
                  • Too long => Difficult to read
                  • Just right => Easy to read

                  @Kent-Dorfman said in code verbosity severely bugs my ADD and OCD:

                  a 30+ character variable or type name listed over and over again...often with a single word in the middle of it transposed to something else.

                  This sounds horribly difficult to read. I wouldn't want to work on such a code base

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #8

                  @JKSH said in code verbosity severely bugs my ADD and OCD:

                  Too short => Difficult to read
                  Too long => Difficult to read
                  Just right => Easy to read

                  Reminds me of "Goldilocks", "The Three Bears" and "porridge" :) Do you have this tale in Europe?

                  J.HilkJ KroMignonK 2 Replies Last reply
                  1
                  • JonBJ JonB

                    @JKSH said in code verbosity severely bugs my ADD and OCD:

                    Too short => Difficult to read
                    Too long => Difficult to read
                    Just right => Easy to read

                    Reminds me of "Goldilocks", "The Three Bears" and "porridge" :) Do you have this tale in Europe?

                    J.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on last edited by
                    #9

                    @JonB sure, Goldlöckchen und die drei Bären here in Germany, but we don't have the same phrase for a goldilocks zone resulting from the tale :D


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    1 Reply Last reply
                    2
                    • JonBJ JonB

                      @JKSH said in code verbosity severely bugs my ADD and OCD:

                      Too short => Difficult to read
                      Too long => Difficult to read
                      Just right => Easy to read

                      Reminds me of "Goldilocks", "The Three Bears" and "porridge" :) Do you have this tale in Europe?

                      KroMignonK Offline
                      KroMignonK Offline
                      KroMignon
                      wrote on last edited by
                      #10

                      @JonB said in code verbosity severely bugs my ADD and OCD:

                      Do you have this tale in Europe?

                      It France it is called "Boucle d'Or et les trois oursons" ;)
                      AFAIK, it is a britisch/scottish fairy tale.

                      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                      JonBJ 1 Reply Last reply
                      0
                      • KroMignonK KroMignon

                        @JonB said in code verbosity severely bugs my ADD and OCD:

                        Do you have this tale in Europe?

                        It France it is called "Boucle d'Or et les trois oursons" ;)
                        AFAIK, it is a britisch/scottish fairy tale.

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by JonB
                        #11

                        @KroMignon said in code verbosity severely bugs my ADD and OCD:

                        AFAIK, it is a britisch/scottish fairy tale.

                        Well that might explain "porridge", I don't know whether you really eat that stuff in Germany/France but one certainly does in Scotland!

                        Having said that, I was under the impression that basically all fairy tales came from Europe (Germany/Eastern), I didn't think we really invented any here... :) (And I think it has been a long time since we have had any bears in the British Isles!)

                        jsulmJ 1 Reply Last reply
                        0
                        • JonBJ JonB

                          @KroMignon said in code verbosity severely bugs my ADD and OCD:

                          AFAIK, it is a britisch/scottish fairy tale.

                          Well that might explain "porridge", I don't know whether you really eat that stuff in Germany/France but one certainly does in Scotland!

                          Having said that, I was under the impression that basically all fairy tales came from Europe (Germany/Eastern), I didn't think we really invented any here... :) (And I think it has been a long time since we have had any bears in the British Isles!)

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @JonB said in code verbosity severely bugs my ADD and OCD:

                          it has been a long time since we have had any bears in the British Isles

                          Just wanted to ask that :-)

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          JonBJ 1 Reply Last reply
                          0
                          • jsulmJ jsulm

                            @JonB said in code verbosity severely bugs my ADD and OCD:

                            it has been a long time since we have had any bears in the British Isles

                            Just wanted to ask that :-)

                            JonBJ Offline
                            JonBJ Offline
                            JonB
                            wrote on last edited by
                            #13

                            @jsulm
                            Our largest non-herbivore is basically the fox! :)

                            KroMignonK 1 Reply Last reply
                            0
                            • JonBJ JonB

                              @jsulm
                              Our largest non-herbivore is basically the fox! :)

                              KroMignonK Offline
                              KroMignonK Offline
                              KroMignon
                              wrote on last edited by
                              #14

                              @JonB said in code verbosity severely bugs my ADD and OCD:

                              Our largest non-herbivore is basically the fox! :)

                              Aha, this made me remember this: "The quick brown fox jumps over the lazy dog"

                              Often used to check communication protocols and/or display :D

                              It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                              JonBJ 1 Reply Last reply
                              0
                              • KroMignonK KroMignon

                                @JonB said in code verbosity severely bugs my ADD and OCD:

                                Our largest non-herbivore is basically the fox! :)

                                Aha, this made me remember this: "The quick brown fox jumps over the lazy dog"

                                Often used to check communication protocols and/or display :D

                                JonBJ Offline
                                JonBJ Offline
                                JonB
                                wrote on last edited by
                                #15

                                @KroMignon
                                You do/Do you realise this phrase was chosen (I believe in typewriter days) as (just about the shortest, meaningful) sentence holding all 26 letters of the alphabet?

                                KroMignonK 1 Reply Last reply
                                1
                                • JonBJ JonB

                                  @KroMignon
                                  You do/Do you realise this phrase was chosen (I believe in typewriter days) as (just about the shortest, meaningful) sentence holding all 26 letters of the alphabet?

                                  KroMignonK Offline
                                  KroMignonK Offline
                                  KroMignon
                                  wrote on last edited by
                                  #16

                                  @JonB said in code verbosity severely bugs my ADD and OCD:

                                  You do/Do you realise this phrase was chosen (I believe in typewriter days) as (just about the shortest, meaningful) sentence holding all 26 letters of the alphabet?

                                  Yes of course, this is why I used to check if all is working well ;)
                                  But I must admit, this phrase was suggested by a British co-worker. It found it funny, so I used it often :)

                                  It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                                  1 Reply Last reply
                                  3
                                  • JonBJ Offline
                                    JonBJ Offline
                                    JonB
                                    wrote on last edited by
                                    #17

                                    @Kent-Dorfman
                                    I am sorry, it is probably I who have hijacked your thread! Hope you don't mind.

                                    Getting back to your original comment about the length of variable/symbol names. You might (or might not) be interested that when I started out in Unix System V.0 coding many years ago, at least external linker symbols (e.g. publicly visible global function names) were limited to 7 character significance! You could name a global function/variable with more characters if you wished, but they would be "chopped off" at the seventh character (actually to allow a maximum of 8 characters, because they would have an underscore character added at the beginning), and had to be distinct from any other global symbol within the first 7 characters, else clash error).

                                    This led to severe required "abbreviation" of one's chosen function names! If you have ever wondered why C library functions had names like strncpy and not longer, this is the reason :)

                                    Just as a separate by-the-by, filenames (per directory) were limited to 14 characters, so that with an additional 2 bytes/16 bits of file attributes/permissions (like drwxrwxrwx) every file name fitted into a convenient 16 bytes in the file system... :)

                                    1 Reply Last reply
                                    0
                                    • J.HilkJ Offline
                                      J.HilkJ Offline
                                      J.Hilk
                                      Moderators
                                      wrote on last edited by
                                      #18

                                      If the company I currently worked for, would actually enforce the coding guidelines, I would be forced to name stuff like:
                                      uint16_t u16_input_status = 0

                                      I think I suddenly would find myself doing much more functional programming.


                                      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                                      Q: What's that?
                                      A: It's blue light.
                                      Q: What does it do?
                                      A: It turns blue.

                                      1 Reply Last reply
                                      0
                                      • JoeCFDJ Offline
                                        JoeCFDJ Offline
                                        JoeCFD
                                        wrote on last edited by JoeCFD
                                        #19

                                        You missed FORTRAN? It is so hard to maintain it. Actually, I hated it because of a lot of short names. Often it is painful to read someone else's code. And it introduced even class and this may kill itself. I am glad I switched to C++.

                                        It is better to write code like a book. More readable, better to maintain it. I later realized that I should always think I am writing code for someone else, but for myself.

                                        Who is writting a code alone nowadays?

                                        .

                                        1 Reply Last reply
                                        0
                                        • Kent-DorfmanK Offline
                                          Kent-DorfmanK Offline
                                          Kent-Dorfman
                                          wrote on last edited by
                                          #20

                                          I would then argue that the minions of mediocity have done well in convincing people to to think as marketers/writers intead of as engineers/mathematicians/scientists. Most of this same "identifers must be meaningful" drivvel is linked to code that severely lacks in internal inline documentation...as if somehow being wordy negates any responsibility to comment on what you're trying to accomplish...and as I stated before, pointy haired boss will be much more impressed with expressing a code idea in 1000 lines instead of 100. LOL

                                          I mean why write this:

                                          if (condition) {
                                             DoSomething();
                                          } else {
                                             SomethingElse();
                                          }
                                          

                                          when you can make the reader scroll pages by doing:

                                          if (condition) 
                                          {
                                             DoSomething();
                                          } 
                                          else 
                                          {
                                             SomethingElse();
                                          }
                                          
                                          JoeCFDJ 1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved