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
    megaadam
    wrote on last edited by
    #3

    You should have a mutex to make sure str does not change at that moment! ;P

    "If we don't change direction, we'll end up where we're going"

    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
      Ron Anders
      wrote on last edited by
      #4

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

        N Offline
        N Offline
        Nathan Minier
        wrote on last edited by
        #5

        It could be a Trekkie trying to be cute. "There are four lights!" "Are you sure?"

        "Never attribute to malice that which can be explained by stupidity." - Hanlon's Razor

        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

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

          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

          M B T J D 5 Replies 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.

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

            gardnerp wrote:

            The naming of str bugs me just as much.

            It had a real name. I sanitized it.

            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

            K 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

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

              den2k88 wrote:

              since I have to be productive with a 2 weeks training over a medium sized project with no documentation nor coding standard

              Ouch! I feel your pain!

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

                B Offline
                B Offline
                BillW33
                wrote on last edited by
                #9

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

                J M F A W 6 Replies 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

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

                  Well, seeing that you do not like switch statements to begin with, they have already failed, throwing the 4 and 5 in is just overkill. :-D BTW, I love how they are checking str if it is not 5 in a case statement where str = 4. Of course it is not 5. :laugh: :laugh: :laugh: :laugh: :laugh: :laugh: :laugh: :laugh: :laugh: Edit: I just realized your title is saying what I just said. :doh: I really need to take a nap. :cool:

                  D 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

                    M Offline
                    M Offline
                    MarkTJohnson
                    wrote on last edited by
                    #11

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

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

                      J Offline
                      J Offline
                      Jon McKee
                      wrote on last edited by
                      #12

                      Oh my. This is what happens when people can get titles like "senior" based on time and not on skill. I need a drink after reading that :laugh:

                      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
                        Mike Winiberg
                        wrote on last edited by
                        #13

                        Mind you the corollary to that is when people have very similar long variable names CompanyIsAgent, CompanyHasAgent, CompanyAgent, IsCompanyAgent, IsAgentCompany etc etc in that they are all nice long descriptive names, but you cannot begin to comprehend the usage or meaning of any of them without studying the program context, and it's easy to use the wrong one and for the code to still run! (this is a real world example!). Using variable names like a, aa, aaa, aaaa and x, xx, xxx, xxxx etc (also a real world example) is hardly any worse. Naming things well is hard, so I would go for brevity where possible and using objects containing properties if at all practical simply so the context can be easily acquired when reading the code

                        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

                          H Offline
                          H Offline
                          h3ph3st0s
                          wrote on last edited by
                          #14

                          If that is Java...then also you can't compare strings that way! fundamental knowledge.

                          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

                            K Offline
                            K Offline
                            kalberts
                            wrote on last edited by
                            #15

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

                            J 1 Reply Last reply
                            0
                            • M Marc Clifton

                              gardnerp wrote:

                              The naming of str bugs me just as much.

                              It had a real name. I sanitized it.

                              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

                              K Offline
                              K Offline
                              kalberts
                              wrote on last edited by
                              #16

                              I was guessing that the programmer had a Fortran background. Fortran has no reserved words (at least it didn't up to F77 - I haven't used more recent versions) so you could define INTEGER to be a REAL variable and COMPLEX to be an INTEGER variable, The result of multiplying INTEGER and COMPLEX could be REAL value stored in the REAL variable REAL. Spaces had no significance, so REALREAL and COMPLEXFUNCTION were perfectly valid variable declarations. (I am really happy that I never had to write a Fortran parser!) When learning Fortran coding at the university, we made up lots of programming exercises for our own fun. One of them was to print out Pascal's triangle using predefined words only, and no literals. Our compiler allowed recursion, which was an extension to Fortran IV, but without it, I doubt that we would have succeeded. The code was completely unreadable. Maybe I should dig it up from the basement and post it here!

                              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

                                B Offline
                                B Offline
                                Bruce Patin
                                wrote on last edited by
                                #17

                                Just in case!

                                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

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