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

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

    The only thing we know for surte is that it isn't 5.

    CQ de W5ALT

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

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

      Yeah, you never know when 4 might turn out to be 5!

      CQ de W5ALT

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

      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

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

        Do you get paid by the line of code?

        CQ de W5ALT

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

        D 1 Reply Last reply
        0
        • S Slacker007

          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 Offline
          D Offline
          Dr Walt Fair PE
          wrote on last edited by
          #44

          Slacker007 wrote:

          hey are checking str if it is not 5 in a case statement where str = 4. Of course it is not 5.

          But it might be next week!

          CQ de W5ALT

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

          1 Reply Last reply
          0
          • D Dr Walt Fair PE

            Do you get paid by the line of code?

            CQ de W5ALT

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

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

            Sadly not. I would have made a million in the first two weeks and then resigned if that was the case.

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

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

              Quote:

              Did the guy knew about IDEs with auto-complete?

              He didn't like auto-complete telling him what to type.

              Quote:

              it will save you several minutes/hours in the future

              He believed that some ephemeral future savings did not outweigh a concrete savings right now! :wtf: And besides, "a real programmer can figure out the code". Extra time to figure things was not important, but the fraction of a second typing time mattered. I believe the saying "Penny wise and Pound foolish" applies. :sigh:

              Just because the code works, it doesn't mean that it is good 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

                T Offline
                T Offline
                TheGreatAndPowerfulOz
                wrote on last edited by
                #47

                By chance was the case "4" a fall-through from cases above it? Not saying it's good coding practice, but that would sorta make sense then seeing the "if" statement. I hate crap like that.... Currently dealing with 20,000 line files with 5,000 line functions. X| X| :mad: I'm NOT exaggerating.

                #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

                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