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. What are the worst programming habits?

What are the worst programming habits?

Scheduled Pinned Locked Moved The Lounge
helpquestion
152 Posts 69 Posters 7 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.
  • C Offline
    C Offline
    Chris Maunder
    wrote on last edited by
    #1

    I was thinking about the things that bug me and came up with a short list

    1. No comments. I know - let's have a religious war etc, but I find no comments dangerous.
    2. using o as a variable name. In fact using anything that's not sensible. ctx, dr_rfp_ptr, i2
    3. Bad formatting. It's like walking into a house and being unable to sit down because of empty pizza boxes on the couch
    4. Mystery side-effects in code.
    5. Magic numbers

    I'm guilty of 2 of these on occasion. What's your list?

    cheers Chris Maunder

    Richard Andrew x64R R N R F 51 Replies Last reply
    0
    • C Chris Maunder

      I was thinking about the things that bug me and came up with a short list

      1. No comments. I know - let's have a religious war etc, but I find no comments dangerous.
      2. using o as a variable name. In fact using anything that's not sensible. ctx, dr_rfp_ptr, i2
      3. Bad formatting. It's like walking into a house and being unable to sit down because of empty pizza boxes on the couch
      4. Mystery side-effects in code.
      5. Magic numbers

      I'm guilty of 2 of these on occasion. What's your list?

      cheers Chris Maunder

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      6. Leaving commented-out code hanging around too long I'm guilty of that one quite often.

      The difficult we do right away... ...the impossible takes slightly longer.

      N G L 3 Replies Last reply
      0
      • C Chris Maunder

        I was thinking about the things that bug me and came up with a short list

        1. No comments. I know - let's have a religious war etc, but I find no comments dangerous.
        2. using o as a variable name. In fact using anything that's not sensible. ctx, dr_rfp_ptr, i2
        3. Bad formatting. It's like walking into a house and being unable to sit down because of empty pizza boxes on the couch
        4. Mystery side-effects in code.
        5. Magic numbers

        I'm guilty of 2 of these on occasion. What's your list?

        cheers Chris Maunder

        R Offline
        R Offline
        R Giskard Reventlov
        wrote on last edited by
        #3

        My pet-peeves are all of those, especially comments where it is not immediately obvious what the intention of the code is. and 7: People that tell you their code is 'self-commenting'. :-(

        "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. Those who seek perfection will only find imperfection nils illegitimus carborundum me, me, me me, in pictures

        N 1 Reply Last reply
        0
        • C Chris Maunder

          I was thinking about the things that bug me and came up with a short list

          1. No comments. I know - let's have a religious war etc, but I find no comments dangerous.
          2. using o as a variable name. In fact using anything that's not sensible. ctx, dr_rfp_ptr, i2
          3. Bad formatting. It's like walking into a house and being unable to sit down because of empty pizza boxes on the couch
          4. Mystery side-effects in code.
          5. Magic numbers

          I'm guilty of 2 of these on occasion. What's your list?

          cheers Chris Maunder

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #4

          I'd add : 6) Leaving commented out code in source control.

          Regards, Nish


          Latest article: Using the Microsoft Azure Storage Client Library for C++ Blog: voidnish.wordpress.com

          1 Reply Last reply
          0
          • Richard Andrew x64R Richard Andrew x64

            6. Leaving commented-out code hanging around too long I'm guilty of that one quite often.

            The difficult we do right away... ...the impossible takes slightly longer.

            N Offline
            N Offline
            Nish Nishant
            wrote on last edited by
            #5

            Sonuffah!!! Beat me by 3 mins :-(

            Regards, Nish


            Latest article: Using the Microsoft Azure Storage Client Library for C++ Blog: voidnish.wordpress.com

            1 Reply Last reply
            0
            • C Chris Maunder

              I was thinking about the things that bug me and came up with a short list

              1. No comments. I know - let's have a religious war etc, but I find no comments dangerous.
              2. using o as a variable name. In fact using anything that's not sensible. ctx, dr_rfp_ptr, i2
              3. Bad formatting. It's like walking into a house and being unable to sit down because of empty pizza boxes on the couch
              4. Mystery side-effects in code.
              5. Magic numbers

              I'm guilty of 2 of these on occasion. What's your list?

              cheers Chris Maunder

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

              Since I don't do this for a living anymore, my opinion probably doesn't count for much. But back when I did do it, the cost of maintaining code far exceeded the cost of developing it, and I considered a lack of meaningful comments grounds for termination. I still do. Others in my list would include leaving commented-out code in production source, and embedding numeric constants in code for use in calculations. I don't know if that last one is common anymore, but it used to drive me nuts, and I found it in a lot of code.

              Will Rogers never met me.

              L J 2 Replies Last reply
              0
              • C Chris Maunder

                I was thinking about the things that bug me and came up with a short list

                1. No comments. I know - let's have a religious war etc, but I find no comments dangerous.
                2. using o as a variable name. In fact using anything that's not sensible. ctx, dr_rfp_ptr, i2
                3. Bad formatting. It's like walking into a house and being unable to sit down because of empty pizza boxes on the couch
                4. Mystery side-effects in code.
                5. Magic numbers

                I'm guilty of 2 of these on occasion. What's your list?

                cheers Chris Maunder

                F Offline
                F Offline
                Forogar
                wrote on last edited by
                #7

                7. Having two different methods that do exactly the same thing but with the arguments in a different order. I have come across this at at least three different places I have worked. Which one to delete when refactoring?

                - I would love to change the world, but they won’t give me the source code.

                S S 2 Replies Last reply
                0
                • R R Giskard Reventlov

                  My pet-peeves are all of those, especially comments where it is not immediately obvious what the intention of the code is. and 7: People that tell you their code is 'self-commenting'. :-(

                  "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. Those who seek perfection will only find imperfection nils illegitimus carborundum me, me, me me, in pictures

                  N Offline
                  N Offline
                  Nish Nishant
                  wrote on last edited by
                  #8

                  mark merrens wrote:

                  People that tell you their code is 'self-commenting'.

                  Sometimes, it is though.

                  // check if user is valid
                  if(IsUserValid(user))
                  {
                  // update the user
                  UpdateUser(user);
                  }
                  else
                  {
                  // show a messagebox with an error
                  MessageBox(error);
                  }

                  In that snippet, the comments are sorta annoying.

                  Regards, Nish


                  Latest article: Using the Microsoft Azure Storage Client Library for C++ Blog: voidnish.wordpress.com

                  R L S G J 5 Replies Last reply
                  0
                  • N Nish Nishant

                    mark merrens wrote:

                    People that tell you their code is 'self-commenting'.

                    Sometimes, it is though.

                    // check if user is valid
                    if(IsUserValid(user))
                    {
                    // update the user
                    UpdateUser(user);
                    }
                    else
                    {
                    // show a messagebox with an error
                    MessageBox(error);
                    }

                    In that snippet, the comments are sorta annoying.

                    Regards, Nish


                    Latest article: Using the Microsoft Azure Storage Client Library for C++ Blog: voidnish.wordpress.com

                    R Offline
                    R Offline
                    R Giskard Reventlov
                    wrote on last edited by
                    #9

                    But mostly, when they feel the need to tell you it is, it isn't.

                    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. Those who seek perfection will only find imperfection nils illegitimus carborundum me, me, me me, in pictures

                    1 Reply Last reply
                    0
                    • C Chris Maunder

                      I was thinking about the things that bug me and came up with a short list

                      1. No comments. I know - let's have a religious war etc, but I find no comments dangerous.
                      2. using o as a variable name. In fact using anything that's not sensible. ctx, dr_rfp_ptr, i2
                      3. Bad formatting. It's like walking into a house and being unable to sit down because of empty pizza boxes on the couch
                      4. Mystery side-effects in code.
                      5. Magic numbers

                      I'm guilty of 2 of these on occasion. What's your list?

                      cheers Chris Maunder

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

                      In order of how I have them listed below: 0) Use of VB. 1) Use of Convert and/or ToString rather than casting and/or Parsing. 2) Over-use of Reflection. Not caching and reusing information retrieved via Reflection. 3) Over-reliance on tools, especially third-party tools. 4) Monolithic classes, lack of modularity, non-single-responsibility. 5) Singletons. X| 6) Convoluted concatenation -- a String.Format will be clearer. 6.1) Concatenated SQL statements, when a parameterized statement is better on so many levels. 7) Not leveraging interfaces. 8) Not allowing polymorphism for no apparent reason. 9) Swallowing Exceptions. 10) Posting snippets of code that use uncommon, custon, or third-party classes and expecting everyone to know what they are.

                      You'll never get very far if all you do is follow instructions.

                      M L J M R 6 Replies Last reply
                      0
                      • C Chris Maunder

                        I was thinking about the things that bug me and came up with a short list

                        1. No comments. I know - let's have a religious war etc, but I find no comments dangerous.
                        2. using o as a variable name. In fact using anything that's not sensible. ctx, dr_rfp_ptr, i2
                        3. Bad formatting. It's like walking into a house and being unable to sit down because of empty pizza boxes on the couch
                        4. Mystery side-effects in code.
                        5. Magic numbers

                        I'm guilty of 2 of these on occasion. What's your list?

                        cheers Chris Maunder

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

                        If you need comments to explain what the code does, then the code is too complex. Formatting is a matter of taste, and there's a keyboard shortcut to automatically reformat in the VS-IDE. My worst programming habits;

                        1. Removing the access modifier "private" from code, as it is redundant. Not a bad habit in my book, but apparently in everyone else's.
                        2. Hitting F5 too regularly. Kills productivity if it takes 15 minutes to build.
                        3. Reading CodeProject while building a solution. I cannot stare at the build-screen, especially since it does not provide adequate feedback on what it is doing. If it appears to be waiting for a long time then chances are that it gets killed using the task-manager.
                        4. Coffee. With two suger, and two cups an hour, that adds to 32 lumps of suger.

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

                        P D C 3 Replies Last reply
                        0
                        • P PIEBALDconsult

                          In order of how I have them listed below: 0) Use of VB. 1) Use of Convert and/or ToString rather than casting and/or Parsing. 2) Over-use of Reflection. Not caching and reusing information retrieved via Reflection. 3) Over-reliance on tools, especially third-party tools. 4) Monolithic classes, lack of modularity, non-single-responsibility. 5) Singletons. X| 6) Convoluted concatenation -- a String.Format will be clearer. 6.1) Concatenated SQL statements, when a parameterized statement is better on so many levels. 7) Not leveraging interfaces. 8) Not allowing polymorphism for no apparent reason. 9) Swallowing Exceptions. 10) Posting snippets of code that use uncommon, custon, or third-party classes and expecting everyone to know what they are.

                          You'll never get very far if all you do is follow instructions.

                          M Offline
                          M Offline
                          Marco Bertschi
                          wrote on last edited by
                          #12

                          PIEBALDconsult wrote:

                          1. Singletons. X|

                          I reckon valid use cases for singletons. Facade patterns, for example, especially in C++ code.

                          PIEBALDconsult wrote:

                          1. Use of Convert and/or ToString rather than casting and/or Parsing.

                          I lost you there, can you please clarify?

                          The console is a black place

                          1 Reply Last reply
                          0
                          • C Chris Maunder

                            I was thinking about the things that bug me and came up with a short list

                            1. No comments. I know - let's have a religious war etc, but I find no comments dangerous.
                            2. using o as a variable name. In fact using anything that's not sensible. ctx, dr_rfp_ptr, i2
                            3. Bad formatting. It's like walking into a house and being unable to sit down because of empty pizza boxes on the couch
                            4. Mystery side-effects in code.
                            5. Magic numbers

                            I'm guilty of 2 of these on occasion. What's your list?

                            cheers Chris Maunder

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

                            - Wrong comments. Comments that pretend to explain the code, but the code and the explanation don't match. - Rambling comments. At least they're not wrong, but the useful part is hiding. - Unreachable code. Often mistaken for "defensive programming". Code that provably can't run is provably useless.

                            H S 2 Replies Last reply
                            0
                            • P PIEBALDconsult

                              In order of how I have them listed below: 0) Use of VB. 1) Use of Convert and/or ToString rather than casting and/or Parsing. 2) Over-use of Reflection. Not caching and reusing information retrieved via Reflection. 3) Over-reliance on tools, especially third-party tools. 4) Monolithic classes, lack of modularity, non-single-responsibility. 5) Singletons. X| 6) Convoluted concatenation -- a String.Format will be clearer. 6.1) Concatenated SQL statements, when a parameterized statement is better on so many levels. 7) Not leveraging interfaces. 8) Not allowing polymorphism for no apparent reason. 9) Swallowing Exceptions. 10) Posting snippets of code that use uncommon, custon, or third-party classes and expecting everyone to know what they are.

                              You'll never get very far if all you do is follow instructions.

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

                              PIEBALDconsult wrote:

                              6.1) Concatenated SQL statements

                              Revoke the programming license of anyone who does this.

                              P 1 Reply Last reply
                              0
                              • C Chris Maunder

                                I was thinking about the things that bug me and came up with a short list

                                1. No comments. I know - let's have a religious war etc, but I find no comments dangerous.
                                2. using o as a variable name. In fact using anything that's not sensible. ctx, dr_rfp_ptr, i2
                                3. Bad formatting. It's like walking into a house and being unable to sit down because of empty pizza boxes on the couch
                                4. Mystery side-effects in code.
                                5. Magic numbers

                                I'm guilty of 2 of these on occasion. What's your list?

                                cheers Chris Maunder

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

                                All that you listed, especially the magic numbers. I would add "Not checking return values", assuming things are going to work is a recipe for pain. OT:

                                Chris Maunder wrote:

                                site down

                                subconscious recollections of a nightmare? :)

                                "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
                                • C Chris Maunder

                                  I was thinking about the things that bug me and came up with a short list

                                  1. No comments. I know - let's have a religious war etc, but I find no comments dangerous.
                                  2. using o as a variable name. In fact using anything that's not sensible. ctx, dr_rfp_ptr, i2
                                  3. Bad formatting. It's like walking into a house and being unable to sit down because of empty pizza boxes on the couch
                                  4. Mystery side-effects in code.
                                  5. Magic numbers

                                  I'm guilty of 2 of these on occasion. What's your list?

                                  cheers Chris Maunder

                                  OriginalGriffO Offline
                                  OriginalGriffO Offline
                                  OriginalGriff
                                  wrote on last edited by
                                  #16

                                  I do #2, when I specifically have to work with an object Comments are my major bugbear: I enforce XML comments on all public methods (and add them to non-public ones) and have "warnings as errors" on, so I have to comment my methods as a bare minimum. The rest of the time, I reserve comments for where they are needed. 6) I hate comments that explain exactly what the code is telling you it is doing! I can read the code, dammit - I don't need you to put

                                  if (customer.IsAnIdiot)
                                  {
                                  // If the customer is an idiot then we need to handle it.

                                  1. Out of date comments. This gets my goat. Comments are there to help, when the code is complicated and more explanation is needed. So if you change the damn code, change the damn comments! Or you will hear the sound of a soft cough behind you, and it'll be me, with the ClueBat... 8) Variables names that don't reflect the use and / or purpose. Leaving control names at the VS default for example... ClueBat time!

                                  Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

                                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                  "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                  L B P 3 Replies Last reply
                                  0
                                  • C Chris Maunder

                                    I was thinking about the things that bug me and came up with a short list

                                    1. No comments. I know - let's have a religious war etc, but I find no comments dangerous.
                                    2. using o as a variable name. In fact using anything that's not sensible. ctx, dr_rfp_ptr, i2
                                    3. Bad formatting. It's like walking into a house and being unable to sit down because of empty pizza boxes on the couch
                                    4. Mystery side-effects in code.
                                    5. Magic numbers

                                    I'm guilty of 2 of these on occasion. What's your list?

                                    cheers Chris Maunder

                                    M Offline
                                    M Offline
                                    Maximilien
                                    wrote on last edited by
                                    #17

                                    ctrl-c/ctrl-v

                                    I'd rather be phishing!

                                    1 Reply Last reply
                                    0
                                    • P PIEBALDconsult

                                      In order of how I have them listed below: 0) Use of VB. 1) Use of Convert and/or ToString rather than casting and/or Parsing. 2) Over-use of Reflection. Not caching and reusing information retrieved via Reflection. 3) Over-reliance on tools, especially third-party tools. 4) Monolithic classes, lack of modularity, non-single-responsibility. 5) Singletons. X| 6) Convoluted concatenation -- a String.Format will be clearer. 6.1) Concatenated SQL statements, when a parameterized statement is better on so many levels. 7) Not leveraging interfaces. 8) Not allowing polymorphism for no apparent reason. 9) Swallowing Exceptions. 10) Posting snippets of code that use uncommon, custon, or third-party classes and expecting everyone to know what they are.

                                      You'll never get very far if all you do is follow instructions.

                                      J Offline
                                      J Offline
                                      Jacquers
                                      wrote on last edited by
                                      #18

                                      6.1 - I had to work on code today of a developer that left us last year. He used concatenated SQL statements... :| This is where something like Entity Framework comes in handy - let it handle your sql inserts / updates. There was also a whole lot of other bad coding habits. I blame the university where he studied though, seems like they didn't teach him good coding standards.

                                      S 1 Reply Last reply
                                      0
                                      • C Chris Maunder

                                        I was thinking about the things that bug me and came up with a short list

                                        1. No comments. I know - let's have a religious war etc, but I find no comments dangerous.
                                        2. using o as a variable name. In fact using anything that's not sensible. ctx, dr_rfp_ptr, i2
                                        3. Bad formatting. It's like walking into a house and being unable to sit down because of empty pizza boxes on the couch
                                        4. Mystery side-effects in code.
                                        5. Magic numbers

                                        I'm guilty of 2 of these on occasion. What's your list?

                                        cheers Chris Maunder

                                        D Offline
                                        D Offline
                                        dan sh
                                        wrote on last edited by
                                        #19

                                        I am currently working on something that has massive presence of #1, 2 and 4. Other than that I totally hate if someone mixes up naming conventions. I have my favorites but I am OK with any convention. Just stick to single bloody way. Other than that, for some reason, heavily parameterized methods and constructors to bother me. I also totally hate logic and calculations in constructors (unless that is really needed).

                                        My CP workspace: Incredibly trivial and probably useless code samples[^]

                                        1 Reply Last reply
                                        0
                                        • C Chris Maunder

                                          I was thinking about the things that bug me and came up with a short list

                                          1. No comments. I know - let's have a religious war etc, but I find no comments dangerous.
                                          2. using o as a variable name. In fact using anything that's not sensible. ctx, dr_rfp_ptr, i2
                                          3. Bad formatting. It's like walking into a house and being unable to sit down because of empty pizza boxes on the couch
                                          4. Mystery side-effects in code.
                                          5. Magic numbers

                                          I'm guilty of 2 of these on occasion. What's your list?

                                          cheers Chris Maunder

                                          J Offline
                                          J Offline
                                          JMK NI
                                          wrote on last edited by
                                          #20

                                          Not sealing classes by default/crazy overuse of inheritance Just because something needs something else doesn't mean it is a base class of that other thing, I think in a modern programming language you rarely actually need to use inheritance Also, Code that does nothing, but hasn't been taken out of the project, eugh I rarely comment my code unless I am doing something weird, I assume the next developer will be at least as smart as me, if not much much smarter (likely) I might use o as a variable name if I'm maybe inside a for loop inside another for loop (using i for the outer one), everybody should know what for(var i = 0; i < blah; i++) means, anything more descriptive is a waste of keystrokes Everything else I agree with

                                          D L 3 Replies 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