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

        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 Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #21

        Eddy Vluggen wrote:

        Removing the access modifier "private" from code

        There should be no default access modifiers; the developer's intent should be clearly specified. I don't want to have to guess, and you don't want me to keep asking you. Specify it, and decrease the hit to your own productivity caused by your juniors.

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

        L 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

          G Offline
          G Offline
          Gary Wheeler
          wrote on last edited by
          #22

          Misspelled identifiers. Inconsistent naming for related items. C++ header files that group things by their access method (public:, protected:, private:) rather than putting related items together. Hungarian notation should die in a fire.

          Software Zen: delete this;

          P 1 Reply Last reply
          0
          • J JMK NI

            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 Offline
            D Offline
            dan sh
            wrote on last edited by
            #23

            Use of var is justifiable? In my useless opinion, var is useless in .Net framework World.

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

            J OriginalGriffO 2 Replies Last reply
            0
            • L Lost User

              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[^]

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #24

              I gotta call foul on removing the private access specifier. In C# the default is private while in VB it's Public. I absolutely hate that and really dont want to have to remember what the defaults ars supposed to be when scanning over code for problems.

              A guide to posting questions on CodeProject

              How to debug small programs
              Dave Kreskowiak

              L 1 Reply Last reply
              0
              • J JMK NI

                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

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

                That var is obviously an int, and you didn't even save any characters there..

                J 1 Reply Last reply
                0
                • G Gary Wheeler

                  Misspelled identifiers. Inconsistent naming for related items. C++ header files that group things by their access method (public:, protected:, private:) rather than putting related items together. Hungarian notation should die in a fire.

                  Software Zen: delete this;

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

                  Gary Wheeler wrote:

                  Hungarian notation should die in a fire

                  That's too good for it. However, have you read this: Making Wrong Code Look Wrong by Joel Spolsky[^]

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

                  G S 2 Replies Last reply
                  0
                  • D dan sh

                    Use of var is justifiable? In my useless opinion, var is useless in .Net framework World.

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

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

                    I disagree, in a situation like:

                    CryptographicUnexpectedOperationException exception = new CryptographicUnexpectedOperationException();

                    I find this more readable:

                    var exception = new CryptographicUnexpectedOperationException();

                    Typing CryptographicUnexpectedOperationException twice in such a short space I think is a bit redundant

                    D F 2 Replies Last reply
                    0
                    • L Lost User

                      That var is obviously an int, and you didn't even save any characters there..

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

                      I didn't waste any characters either :^)

                      L 1 Reply Last reply
                      0
                      • P PIEBALDconsult

                        Eddy Vluggen wrote:

                        Removing the access modifier "private" from code

                        There should be no default access modifiers; the developer's intent should be clearly specified. I don't want to have to guess, and you don't want me to keep asking you. Specify it, and decrease the hit to your own productivity caused by your juniors.

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

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

                        PIEBALDconsult wrote:

                        the developer's intent should be clearly specified.

                        It IS clearly specified if it is omitted. It is not some arcane trick, it is not something that causes side-effects, and it improves readability. It is as usefull as typing "begin" and "end" instead of the default scope-blocks. It might take some getting used to, but it conveys the same amount of information using less symbols. That's kinda essential, and the reason why we are not programming in COBOL.

                        PIEBALDconsult wrote:

                        I don't want to have to guess

                        If you have to guess at the default access modifier in C#, you should not be writing in C#.

                        PIEBALDconsult wrote:

                        and decrease the hit to your own productivity caused by your juniors.

                        Should I prefix each class with a complete namespace? Otherwise they'd be guessing at which class it will take :D You explain a junior ONCE that everything that does not have a modifier is private. If they come asking, even once, then make them prefix everything. Using "this" and "that", using namespaces, using "global::". Throw in some hungarian systems, so they won't have to guess the type :suss:

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

                        L P pkfoxP S N 5 Replies Last reply
                        0
                        • J JMK NI

                          I didn't waste any characters either :^)

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

                          Hmm.. OK fine, I'll accept that excuse. This time.

                          1 Reply Last reply
                          0
                          • J JMK NI

                            I disagree, in a situation like:

                            CryptographicUnexpectedOperationException exception = new CryptographicUnexpectedOperationException();

                            I find this more readable:

                            var exception = new CryptographicUnexpectedOperationException();

                            Typing CryptographicUnexpectedOperationException twice in such a short space I think is a bit redundant

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

                            Intellisense does help. For reading, indentation is something I would prefer. It is opinion. I think MS wants to divide and rule. When did Britishers took over MS? *Last 2 sentences are supposed to be humor.

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

                            OriginalGriffO 1 Reply Last reply
                            0
                            • L Lost User

                              PIEBALDconsult wrote:

                              the developer's intent should be clearly specified.

                              It IS clearly specified if it is omitted. It is not some arcane trick, it is not something that causes side-effects, and it improves readability. It is as usefull as typing "begin" and "end" instead of the default scope-blocks. It might take some getting used to, but it conveys the same amount of information using less symbols. That's kinda essential, and the reason why we are not programming in COBOL.

                              PIEBALDconsult wrote:

                              I don't want to have to guess

                              If you have to guess at the default access modifier in C#, you should not be writing in C#.

                              PIEBALDconsult wrote:

                              and decrease the hit to your own productivity caused by your juniors.

                              Should I prefix each class with a complete namespace? Otherwise they'd be guessing at which class it will take :D You explain a junior ONCE that everything that does not have a modifier is private. If they come asking, even once, then make them prefix everything. Using "this" and "that", using namespaces, using "global::". Throw in some hungarian systems, so they won't have to guess the type :suss:

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

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

                              Eddy Vluggen wrote:

                              Should I prefix each class with a complete namespace? Otherwise they'd be guessing at which class it will take

                              You've done it now :-D

                              L 1 Reply Last reply
                              0
                              • D dan sh

                                Use of var is justifiable? In my useless opinion, var is useless in .Net framework World.

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

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

                                var is handy in two places: 1) When using Linq and returning "An IEnumerable of something, gawddammit, but I have no idea what the compiler is going to call it" 2) To identify people whose code you can't trust because they have no idea or no interest in what type a variable should be. It may save five keystrokes to use var instead of IEnumerable<Customer> but it doesn't help understanding when you have to read the code later.

                                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

                                D F 2 Replies Last reply
                                0
                                • D dan sh

                                  Intellisense does help. For reading, indentation is something I would prefer. It is opinion. I think MS wants to divide and rule. When did Britishers took over MS? *Last 2 sentences are supposed to be humor.

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

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

                                  d@nish wrote:

                                  When did Britishers took over MS?

                                  We didn't. If we had, the Color class would be spelled properly!

                                  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

                                  D 1 Reply Last reply
                                  0
                                  • OriginalGriffO OriginalGriff

                                    var is handy in two places: 1) When using Linq and returning "An IEnumerable of something, gawddammit, but I have no idea what the compiler is going to call it" 2) To identify people whose code you can't trust because they have no idea or no interest in what type a variable should be. It may save five keystrokes to use var instead of IEnumerable<Customer> but it doesn't help understanding when you have to read the code later.

                                    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 – ∞)

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

                                    OriginalGriff wrote:

                                    To identify people whose code you can't trust

                                    :thumbsup:

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

                                    1 Reply Last reply
                                    0
                                    • OriginalGriffO OriginalGriff

                                      d@nish wrote:

                                      When did Britishers took over MS?

                                      We didn't. If we had, the Color class would be spelled properly!

                                      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 – ∞)

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

                                      Wait, that explains it. Those who have trouble typing a "u", can not type IEnumerable< Whatever the hell it is >. I now know the whole purpose of var. Enlightened.

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

                                      1 Reply Last reply
                                      0
                                      • L Lost User

                                        PIEBALDconsult wrote:

                                        the developer's intent should be clearly specified.

                                        It IS clearly specified if it is omitted. It is not some arcane trick, it is not something that causes side-effects, and it improves readability. It is as usefull as typing "begin" and "end" instead of the default scope-blocks. It might take some getting used to, but it conveys the same amount of information using less symbols. That's kinda essential, and the reason why we are not programming in COBOL.

                                        PIEBALDconsult wrote:

                                        I don't want to have to guess

                                        If you have to guess at the default access modifier in C#, you should not be writing in C#.

                                        PIEBALDconsult wrote:

                                        and decrease the hit to your own productivity caused by your juniors.

                                        Should I prefix each class with a complete namespace? Otherwise they'd be guessing at which class it will take :D You explain a junior ONCE that everything that does not have a modifier is private. If they come asking, even once, then make them prefix everything. Using "this" and "that", using namespaces, using "global::". Throw in some hungarian systems, so they won't have to guess the type :suss:

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

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

                                        Eddy Vluggen wrote:

                                        explain a junior ONCE

                                        That's once too many.

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

                                        1 Reply Last reply
                                        0
                                        • L Lost User

                                          Eddy Vluggen wrote:

                                          Should I prefix each class with a complete namespace? Otherwise they'd be guessing at which class it will take

                                          You've done it now :-D

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

                                          Adding oil to the fire, a practical example;

                                          using System;
                                          using System.Threading;
                                          using System.Windows.Forms;
                                          using System.Timers;

                                          namespace ConsoleApplication5
                                          {
                                          class Program
                                          {
                                          Timer t = new System.Threading.Timer(null); // will not compile, as it is unclear which Timer
                                          Timer t2 = new System.Windows.Forms.Timer(); // is declared (as opposed to the type instantiated)
                                          Timer pfld_SysTimrTimrt3 = new System.Timers.Timer(); // using hungarian systems with namespace prefix

                                              static void Main(global::System.String\[\]\[\] strSrgs)
                                              {
                                                  global::System.Console.ReadLine();
                                              }
                                          }
                                          

                                          }

                                          And yes, the "console application template" has an entry point which is implicitly private.

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

                                          P L 2 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