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. Bugs in the funniest of places

Bugs in the funniest of places

Scheduled Pinned Locked Moved The Lounge
designcomgraphicsiotjson
11 Posts 7 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.
  • honey the codewitchH honey the codewitch

    I built out a lexer and half baked parser to scan a C header and produce a CSV with certain data pulled out of it. I got the lexing and parsing of the header done in no time, and with a minimum of fuss. But outputting the CSV

    if (s.Key == "data_packet" || s.Key == "status_packet" || s.Key == "config_packet")

    This code exists in two places. Between those two places I got this simple line wrong 3 times, and caused relatively a lot of churn w/ my colleagues in terms of their own work, which relied on this to function properly. Why sometimes its the simple parts of the code that cause the most problems I'll never know.

    Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

    FreedMallocF Offline
    FreedMallocF Offline
    FreedMalloc
    wrote on last edited by
    #2

    Because we're always so careful on the big stuff. It's tricky to begin with so more care is taken. But the small stuff, it's so simple. What can go wrong? I once made an oh so minor 2 character change to a simple program. It was so simple and so obviously correct that I just dropped it back into production. And thus tipped over an entire healthcare claims reporting system. Oops! :~

    M 1 Reply Last reply
    0
    • honey the codewitchH honey the codewitch

      I built out a lexer and half baked parser to scan a C header and produce a CSV with certain data pulled out of it. I got the lexing and parsing of the header done in no time, and with a minimum of fuss. But outputting the CSV

      if (s.Key == "data_packet" || s.Key == "status_packet" || s.Key == "config_packet")

      This code exists in two places. Between those two places I got this simple line wrong 3 times, and caused relatively a lot of churn w/ my colleagues in terms of their own work, which relied on this to function properly. Why sometimes its the simple parts of the code that cause the most problems I'll never know.

      Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

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

      I create my own function when dealing with these types of statements. For any number of reasons. It just compares objects.

      bool ok = MyFunc.IsInList( s.key, "data_packet", "etc" ); // Uses "params" to handle a variable number of objects.

      "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

      1 Reply Last reply
      0
      • honey the codewitchH honey the codewitch

        I built out a lexer and half baked parser to scan a C header and produce a CSV with certain data pulled out of it. I got the lexing and parsing of the header done in no time, and with a minimum of fuss. But outputting the CSV

        if (s.Key == "data_packet" || s.Key == "status_packet" || s.Key == "config_packet")

        This code exists in two places. Between those two places I got this simple line wrong 3 times, and caused relatively a lot of churn w/ my colleagues in terms of their own work, which relied on this to function properly. Why sometimes its the simple parts of the code that cause the most problems I'll never know.

        Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

        0 Offline
        0 Offline
        0x01AA
        wrote on last edited by
        #4

        return 0++ ;P :laugh:

        1 Reply Last reply
        0
        • FreedMallocF FreedMalloc

          Because we're always so careful on the big stuff. It's tricky to begin with so more care is taken. But the small stuff, it's so simple. What can go wrong? I once made an oh so minor 2 character change to a simple program. It was so simple and so obviously correct that I just dropped it back into production. And thus tipped over an entire healthcare claims reporting system. Oops! :~

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

          My favorite was, in my C++ days, putting a ; at the end of a for statement and then spending several hours in the debugger wondering why the code in the for loop executed only once! :laugh:

          Latest Articles:
          A Lightweight Thread Safe In-Memory Keyed Generic Cache Collection Service A Dynamic Where Implementation for Entity Framework

          1 Reply Last reply
          0
          • honey the codewitchH honey the codewitch

            I built out a lexer and half baked parser to scan a C header and produce a CSV with certain data pulled out of it. I got the lexing and parsing of the header done in no time, and with a minimum of fuss. But outputting the CSV

            if (s.Key == "data_packet" || s.Key == "status_packet" || s.Key == "config_packet")

            This code exists in two places. Between those two places I got this simple line wrong 3 times, and caused relatively a lot of churn w/ my colleagues in terms of their own work, which relied on this to function properly. Why sometimes its the simple parts of the code that cause the most problems I'll never know.

            Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

            J Offline
            J Offline
            jmaida
            wrote on last edited by
            #6

            I have had such weird code snags in C. Had one that two of us could not see the error. We laughed when we solved it. So simple. Wish I had saved the code, but good riddance.

            "A little time, a little trouble, your better day" Badfinger

            1 Reply Last reply
            0
            • honey the codewitchH honey the codewitch

              I built out a lexer and half baked parser to scan a C header and produce a CSV with certain data pulled out of it. I got the lexing and parsing of the header done in no time, and with a minimum of fuss. But outputting the CSV

              if (s.Key == "data_packet" || s.Key == "status_packet" || s.Key == "config_packet")

              This code exists in two places. Between those two places I got this simple line wrong 3 times, and caused relatively a lot of churn w/ my colleagues in terms of their own work, which relied on this to function properly. Why sometimes its the simple parts of the code that cause the most problems I'll never know.

              Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

              G Offline
              G Offline
              GKP1992
              wrote on last edited by
              #7

              Sometimes overthinking/overengineering something has this effect. Recently came across a piece of code which went something like this during one my code review sessions.

              bool condition;
              viewmodel.AllowSomething = !condition == true ? false : true;

              We laughed for about 30 minutes, including the guy who wrote this.

              honey the codewitchH J 3 Replies Last reply
              0
              • G GKP1992

                Sometimes overthinking/overengineering something has this effect. Recently came across a piece of code which went something like this during one my code review sessions.

                bool condition;
                viewmodel.AllowSomething = !condition == true ? false : true;

                We laughed for about 30 minutes, including the guy who wrote this.

                honey the codewitchH Offline
                honey the codewitchH Offline
                honey the codewitch
                wrote on last edited by
                #8

                It looks like that code evolved to be that, rather than written that way to begin with. At least I hope. I've been there. In fact, I've had code I wouldn't touch because it was like that, took forever to get right, and it worked, including handling difficult corner cases.

                Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                G 1 Reply Last reply
                0
                • honey the codewitchH honey the codewitch

                  It looks like that code evolved to be that, rather than written that way to begin with. At least I hope. I've been there. In fact, I've had code I wouldn't touch because it was like that, took forever to get right, and it worked, including handling difficult corner cases.

                  Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                  G Offline
                  G Offline
                  GKP1992
                  wrote on last edited by
                  #9

                  honey the codewitch wrote:

                  At least I hope.

                  It was written that way. We laughed at it as it meant that we assign true when the condition is true and false when it's false. Just the way to go about it was really through Caradhras mountains and then through the mines of Moria.

                  honey the codewitch wrote:

                  took forever to get right

                  At first glance my thought was also to replace with !condition. As I missed the first ! to begin with.

                  1 Reply Last reply
                  0
                  • G GKP1992

                    Sometimes overthinking/overengineering something has this effect. Recently came across a piece of code which went something like this during one my code review sessions.

                    bool condition;
                    viewmodel.AllowSomething = !condition == true ? false : true;

                    We laughed for about 30 minutes, including the guy who wrote this.

                    J Offline
                    J Offline
                    jmaida
                    wrote on last edited by
                    #10

                    :) It is a funny piece of code.

                    "A little time, a little trouble, your better day" Badfinger

                    1 Reply Last reply
                    0
                    • G GKP1992

                      Sometimes overthinking/overengineering something has this effect. Recently came across a piece of code which went something like this during one my code review sessions.

                      bool condition;
                      viewmodel.AllowSomething = !condition == true ? false : true;

                      We laughed for about 30 minutes, including the guy who wrote this.

                      J Offline
                      J Offline
                      jmaida
                      wrote on last edited by
                      #11

                      :) It is a funny bit of code. love it

                      "A little time, a little trouble, your better day" Badfinger

                      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