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. Other Discussions
  3. The Weird and The Wonderful
  4. Let's REALLY make sure "4" isn't "5"

Let's REALLY make sure "4" isn't "5"

Scheduled Pinned Locked Moved The Weird and The Wonderful
pythoncomlearning
47 Posts 29 Posters 0 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.
  • M Marc Clifton

    switch (str)
    {
    case "4":
    if (str != "5") ...

    Ah, the joys of outsourcing with no code reviews.

    Latest Article - A Concise Overview of Threads Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

    M Offline
    M Offline
    MikeTheFid
    wrote on last edited by
    #18

    Marc Clifton wrote:

    Ah, the joys of outsourcing with no code reviews.

    Combined, perhaps, with last minute changes, or unthinking copy/cut and paste, failing to step-through debug or sheer incompetence, or all of the above. It is smdh funny, though.

    Cheers, Mike Fidler "I intend to live forever - so far, so good." Steven Wright "I almost had a psychic girlfriend but she left me before we met." Also Steven Wright "I'm addicted to placebos. I could quit, but it wouldn't matter." Steven Wright yet again.

    1 Reply Last reply
    0
    • B BillW33

      "You will save a lot of time only typing 2 or 3 letter variable names instead of those long names. Therefore you will be able to program faster if you keep your variable names short." At a previous job, that is what one of the senior programmers would teach to the new programmers and the boss (who was also a programmer) agreed with him. :wtf: X| There are reasons why I don't work there any longer. ;)

      Just because the code works, it doesn't mean that it is good code.

      F Offline
      F Offline
      F Margueirat
      wrote on last edited by
      #19

      Did the guy knew about IDEs with auto-complete? I understand the point that even if it takes a fraction of a second longer to type a variable name, it will save you several minutes/hours in the future when you or someone else has to maintain that code. But even that fraction of a second disappears with auto-complete.

      D B 2 Replies Last reply
      0
      • F F Margueirat

        Did the guy knew about IDEs with auto-complete? I understand the point that even if it takes a fraction of a second longer to type a variable name, it will save you several minutes/hours in the future when you or someone else has to maintain that code. But even that fraction of a second disappears with auto-complete.

        D Offline
        D Offline
        den2k88
        wrote on last edited by
        #20

        Most of these people think that "vim is better" than a proper IDE.

        GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++*      Weapons extension: ma- k++ F+2 X

        J 1 Reply Last reply
        0
        • B BillW33

          "You will save a lot of time only typing 2 or 3 letter variable names instead of those long names. Therefore you will be able to program faster if you keep your variable names short." At a previous job, that is what one of the senior programmers would teach to the new programmers and the boss (who was also a programmer) agreed with him. :wtf: X| There are reasons why I don't work there any longer. ;)

          Just because the code works, it doesn't mean that it is good code.

          A Offline
          A Offline
          Alister Morton
          wrote on last edited by
          #21

          I used to work with a guy who typed (mostly) with one finger - if he needed a capital letter he hit caps lock then the letter then caps lock ... This was pre-IDE with completion days. His variable and function names were really terse. When we noticed his coding style, the functions we implemented in our libraries started to "change" so cpos(...) became setVirtualCursorPosition(...) and fg(...) became setForegroundTextColour(...) and so on ;-)

          1 Reply Last reply
          0
          • D den2k88

            It's 3 weeks I am a consultant and I'm seeing sh*t like this way too often. And I am expected to produce the same, since I have to be productive with a 2 weeks training over a medium sized project with no documentation nor coding standard (functions that take 12 arguments named ct, ly, ex, ey, tx, fx and so on...).

            GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++*      Weapons extension: ma- k++ F+2 X

            T Offline
            T Offline
            TNCaver
            wrote on last edited by
            #22

            Thanks. I'm now having flashbacks to GW-BASIC.

            If you think 'goto' is evil, try writing an Assembly program without JMP.

            D J 2 Replies Last reply
            0
            • B BillW33

              "You will save a lot of time only typing 2 or 3 letter variable names instead of those long names. Therefore you will be able to program faster if you keep your variable names short." At a previous job, that is what one of the senior programmers would teach to the new programmers and the boss (who was also a programmer) agreed with him. :wtf: X| There are reasons why I don't work there any longer. ;)

              Just because the code works, it doesn't mean that it is good code.

              W Offline
              W Offline
              W Balboos GHB
              wrote on last edited by
              #23

              Not disagreeing with the idea that a symbol's name should tell you a bit about it (if possible), but I have worked with someone who who's symbol and function names were pretty near essays. It takes a bit of common sense - and making distinguishing them a non-painful eye exercise. Why not loop with i, j, etc., as counters? Why not use IPAddr instead of ipa (slurp!)? Always just common sense to make readable and to avoid mistakes. It shouldn't be hard.

              Ravings en masse^

              "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

              "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

              R 1 Reply Last reply
              0
              • M Marc Clifton

                switch (str)
                {
                case "4":
                if (str != "5") ...

                Ah, the joys of outsourcing with no code reviews.

                Latest Article - A Concise Overview of Threads Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

                W Offline
                W Offline
                W Balboos GHB
                wrote on last edited by
                #24

                Better said - better done[^]

                Ravings en masse^

                "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

                "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

                1 Reply Last reply
                0
                • T TNCaver

                  Thanks. I'm now having flashbacks to GW-BASIC.

                  If you think 'goto' is evil, try writing an Assembly program without JMP.

                  D Offline
                  D Offline
                  den2k88
                  wrote on last edited by
                  #25

                  You tell me... this code sucks so much I wrote several VB6 lines inside C++, not kidding!

                  GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++*      Weapons extension: ma- k++ F+2 X

                  1 Reply Last reply
                  0
                  • W W Balboos GHB

                    Not disagreeing with the idea that a symbol's name should tell you a bit about it (if possible), but I have worked with someone who who's symbol and function names were pretty near essays. It takes a bit of common sense - and making distinguishing them a non-painful eye exercise. Why not loop with i, j, etc., as counters? Why not use IPAddr instead of ipa (slurp!)? Always just common sense to make readable and to avoid mistakes. It shouldn't be hard.

                    Ravings en masse^

                    "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

                    "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

                    R Offline
                    R Offline
                    Rick York
                    wrote on last edited by
                    #26

                    There were people here who would call that variable ip. It drove me crazy until I eradicated all traces of that nonsense.

                    J 1 Reply Last reply
                    0
                    • G gardnerp

                      The naming of str bugs me just as much. Ok, I know it's a string. But what is it? Calling it something like invoiceTypeCode indicates it is a string and lets me know what I am looking at.

                      C Offline
                      C Offline
                      CHill60
                      wrote on last edited by
                      #27

                      I recently inherited a load of "code" (it's VBA so I don't want to it ideas above its station :laugh: ) ... during the "handover" (apparently that's what it was) the original "programmer" explained with great pride, that they didn't

                      Quote:

                      waste their time using long variable names...

                      Yep! Every single one of them was a single character. Every. Single. One. :mad: (Except where he copied code snippets off the internet)

                      Z 1 Reply Last reply
                      0
                      • M Marc Clifton

                        switch (str)
                        {
                        case "4":
                        if (str != "5") ...

                        Ah, the joys of outsourcing with no code reviews.

                        Latest Article - A Concise Overview of Threads Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

                        R Offline
                        R Offline
                        raddevus
                        wrote on last edited by
                        #28

                        That is one sick puppy. The person should be found, bound and brought out for public humiliation immediately. We had something like the following in legacy code:

                        for (x = 0; x <= 20;x++){
                        unknownVariable = x;
                        }
                        unknownVariable = 55;

                        X| That brings up so many questions. Was the dev trying to slow something down? What is unknownVariable? Why did dev set it to the specific value of 55? arghgghgghg!!!!

                        1 Reply Last reply
                        0
                        • D den2k88

                          It's 3 weeks I am a consultant and I'm seeing sh*t like this way too often. And I am expected to produce the same, since I have to be productive with a 2 weeks training over a medium sized project with no documentation nor coding standard (functions that take 12 arguments named ct, ly, ex, ey, tx, fx and so on...).

                          GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++*      Weapons extension: ma- k++ F+2 X

                          J Offline
                          J Offline
                          James Lonero
                          wrote on last edited by
                          #29

                          Sounds like a bunch of college students to me. They need refinement. But, you get what you pay for.

                          1 Reply Last reply
                          0
                          • D den2k88

                            Most of these people think that "vim is better" than a proper IDE.

                            GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++*      Weapons extension: ma- k++ F+2 X

                            J Offline
                            J Offline
                            James Lonero
                            wrote on last edited by
                            #30

                            For voice in mind?

                            1 Reply Last reply
                            0
                            • R Rick York

                              There were people here who would call that variable ip. It drove me crazy until I eradicated all traces of that nonsense.

                              J Offline
                              J Offline
                              James Lonero
                              wrote on last edited by
                              #31

                              You must be the boss.

                              1 Reply Last reply
                              0
                              • K kalberts

                                I think that if (itIsRainin == true) is just as bad.

                                J Offline
                                J Offline
                                James Lonero
                                wrote on last edited by
                                #32

                                Unless you're in California. WE WANT RAIN!

                                1 Reply Last reply
                                0
                                • T TNCaver

                                  Thanks. I'm now having flashbacks to GW-BASIC.

                                  If you think 'goto' is evil, try writing an Assembly program without JMP.

                                  J Offline
                                  J Offline
                                  James Lonero
                                  wrote on last edited by
                                  #33

                                  Reminds me of my first foray into Fortran IV. Then, we used computer cards. We were only allowed six characters for variable names. Then, it was all in CAPS.

                                  1 Reply Last reply
                                  0
                                  • B BillW33

                                    "You will save a lot of time only typing 2 or 3 letter variable names instead of those long names. Therefore you will be able to program faster if you keep your variable names short." At a previous job, that is what one of the senior programmers would teach to the new programmers and the boss (who was also a programmer) agreed with him. :wtf: X| There are reasons why I don't work there any longer. ;)

                                    Just because the code works, it doesn't mean that it is good code.

                                    M Offline
                                    M Offline
                                    Marc Clifton
                                    wrote on last edited by
                                    #34

                                    BillW33 wrote:

                                    You will save a lot of time only typing 2 or 3 letter variable names instead of those long names.

                                    And here I thought if you use shorter variable names, the program runs faster! :-D

                                    Latest Article - A Concise Overview of Threads Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

                                    1 Reply Last reply
                                    0
                                    • M MarkTJohnson

                                      Was it originally a set of nested if and they just missed that one?

                                      M Offline
                                      M Offline
                                      Marc Clifton
                                      wrote on last edited by
                                      #35

                                      MarkTJohnson wrote:

                                      Was it originally a set of nested if and they just missed that one?

                                      I have no idea, and I didn't want to look through the TFS change history to find out. :laugh:

                                      Latest Article - A Concise Overview of Threads Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

                                      1 Reply Last reply
                                      0
                                      • R Ron Anders

                                        Good grief. I keep telling my techie wife that soon you'll see critical systems failing left and right that used to work pretty well. Shoot, maybe that's why AI is all the rage today. Were scared of, let's just call em the up and comers.

                                        D Offline
                                        D Offline
                                        Dr Walt Fair PE
                                        wrote on last edited by
                                        #36

                                        Maybe they need to check that left!=right ?

                                        CQ de W5ALT

                                        Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

                                        1 Reply Last reply
                                        0
                                        • M Marc Clifton

                                          switch (str)
                                          {
                                          case "4":
                                          if (str != "5") ...

                                          Ah, the joys of outsourcing with no code reviews.

                                          Latest Article - A Concise Overview of Threads Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

                                          R Offline
                                          R Offline
                                          Ryan Peden
                                          wrote on last edited by
                                          #37

                                          Hey now, that could actually be a valid check! :laugh:

                                          public class Stringy
                                          {
                                          private string Value { get; set; }

                                          public Stringy(string value)
                                          {
                                              Value = value;
                                          }
                                          
                                          public static implicit operator string(Stringy s)
                                          {
                                              string value = s.Value;
                                          
                                              if (s.Value == "4") s.Value = "5";
                                          
                                              return value;
                                          }
                                          

                                          }

                                          Which lets you write code like this:

                                          var str = new Stringy("4");

                                          if (str == "4" && str == "5")
                                          Console.WriteLine("LOL");

                                          Which will, of course, print LOL to the console. Though I imagine you'd only do something like this if you really, really hate your co-workers.

                                          N 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