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. Worst source code EVER

Worst source code EVER

Scheduled Pinned Locked Moved The Lounge
questioncareer
54 Posts 41 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.
  • R Ravi Sant

    For me, Worst code I see everyday is Catch block with no statements

    // ♫ 99 little bugs in the code, // 99 bugs in the code // We fix a bug, compile it again // 101 little bugs in the code ♫

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

    Oh, yeah, on the assignment I just started there are lots of those... :sigh: One in particular is around an access to a Dictionary -- in case the key doesn't exist I guess. Personally, I'd check with ContainsKey, but not the guy who wrote this.

    1 Reply Last reply
    0
    • J Jorgen Sigvardsson

      I think I know what your first programming language is... :-D

      -- Kein Mitleid Für Die Mehrheit

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

      The second time I took a course in C, the textbook was "C as a Second Language, For Native Speakers of Pascal", I still have it right here. (But BASICplus was my first programming language.)

      1 Reply Last reply
      0
      • _ _beauw_

        "The data was imported daily from SAP" But wait... I thought SAP did everything. Aren't all of those annoying little side-apps with their interface and import requirements supposed to just go away after a successful SAP implementation? And shouldn't costly, difficult-to-manage programmers be a thing of the past? Or was I misled on these points?

        V Offline
        V Offline
        Vivi Chellappa
        wrote on last edited by
        #30

        SAP requires costly, difficult-to-manage programmers be available in very large numbers so that one may be sacrificed daily to appease the beast! The same thing goes for Oracle ERP too!

        B 1 Reply Last reply
        0
        • G Ger Hayden

          Code that forced Oracle tables to behave like ISAM files

          Ger

          V Offline
          V Offline
          Vivi Chellappa
          wrote on last edited by
          #31

          Oracle was implemented on IBM mainframes using VSAM! ;P

          1 Reply Last reply
          0
          • Brian C HartB Brian C Hart

            Okay, last day or so ago, I asked what your favorite programming job was. Now, what is the worst, nastiest, ugliest source code you ever saw and what made it so horribly bad? Not commented (heh heh yeah, as if) or one-letter (or zero-letter?) variable names? Written in a dead programming language that should be dead, but your client is still using it for some God-awful reason? The list goes on...so spew!

            Sincerely Yours, Brian Hart

            W Offline
            W Offline
            was8309
            wrote on last edited by
            #32

            not even the code, but the name. A while after a nice old dude named Larry retired, I figured it was safe to delete a clist (old mainframe stuff) named 'Larry'. soon enough the phone was ringing off the hook - "what happened to the Larry command?!"

            1 Reply Last reply
            0
            • Brian C HartB Brian C Hart

              Okay, last day or so ago, I asked what your favorite programming job was. Now, what is the worst, nastiest, ugliest source code you ever saw and what made it so horribly bad? Not commented (heh heh yeah, as if) or one-letter (or zero-letter?) variable names? Written in a dead programming language that should be dead, but your client is still using it for some God-awful reason? The list goes on...so spew!

              Sincerely Yours, Brian Hart

              T Offline
              T Offline
              tuningd
              wrote on last edited by
              #33

              A MS Access app(lol) that a accountant wrote over some years. It looked a excel documents and another access database all over the network using mapped drives. It produced a huge excel document that all the executives used every day. Oh and the excel documents were created by our own programs which we had full access to the database so I have yet to understand why this was created.

              1 Reply Last reply
              0
              • N NormDroid

                ON ERROR RESUME Nothing more, nothing less...

                Software Kinetics Wear a hard hat it's under construction
                Metro RSS

                D Offline
                D Offline
                destynova
                wrote on last edited by
                #34

                And its more verbose but equally horrible Java cousin:

                try {
                mystery1();
                mystery2();
                mystery3();
                mystery4();
                theRestOfTheProgram();
                } catch(Exception e) {};

                I've been bitten by that a few times, testing something that is not behaving as it should, but not producing any error messages. What's the point of having exceptions, and just as importantly, a managed language with automatic line-numbered stack traces etc, if you're going to suppress all of that goodness? :omg:

                O 1 Reply Last reply
                0
                • Brian C HartB Brian C Hart

                  Okay, last day or so ago, I asked what your favorite programming job was. Now, what is the worst, nastiest, ugliest source code you ever saw and what made it so horribly bad? Not commented (heh heh yeah, as if) or one-letter (or zero-letter?) variable names? Written in a dead programming language that should be dead, but your client is still using it for some God-awful reason? The list goes on...so spew!

                  Sincerely Yours, Brian Hart

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

                  I had to check on some Visual Basic code a few month ago, and saw a funcion called

                  isNada(obj)

                  The function returns true if the obj = Nothing I'm no saying that the funcion is wrong, but the mix of languages just pissed me of, if he just called it isNothing, isNull or esNada maybe I'll just smile a little

                  Saludos!! ____Juan

                  1 Reply Last reply
                  0
                  • Brian C HartB Brian C Hart

                    Okay, last day or so ago, I asked what your favorite programming job was. Now, what is the worst, nastiest, ugliest source code you ever saw and what made it so horribly bad? Not commented (heh heh yeah, as if) or one-letter (or zero-letter?) variable names? Written in a dead programming language that should be dead, but your client is still using it for some God-awful reason? The list goes on...so spew!

                    Sincerely Yours, Brian Hart

                    D Offline
                    D Offline
                    Danny Martin
                    wrote on last edited by
                    #36

                    Brian C Hart wrote:

                    Now, what is the worst, nastiest, ugliest source code you ever saw

                    I'm still writing it :-D Danny

                    1 Reply Last reply
                    0
                    • Brian C HartB Brian C Hart

                      Okay, last day or so ago, I asked what your favorite programming job was. Now, what is the worst, nastiest, ugliest source code you ever saw and what made it so horribly bad? Not commented (heh heh yeah, as if) or one-letter (or zero-letter?) variable names? Written in a dead programming language that should be dead, but your client is still using it for some God-awful reason? The list goes on...so spew!

                      Sincerely Yours, Brian Hart

                      F Offline
                      F Offline
                      Fabio Franco
                      wrote on last edited by
                      #37

                      There was this code they wrote a SQL Server stored procedure just for completing a string with zeroes to the left until its maximum length, in pseudo code it was like this:

                      if value.Length < 2
                      value = "0000000" + value
                      else
                      if value.Length < 3
                      value = "000000" + value
                      else
                      if value.Length < 4
                      value = "00000" + value
                      else
                      if value.Length < 5
                      value = "0000" + value
                      else
                      if value.Length < 6
                      value = "000" + value
                      else
                      if value.Length < 7
                      value = "00" + value
                      else
                      if value.Length < 8
                      value = "0" + value

                      When I saw this, I was like :omg: and wondered what else I was going to find :~. I feared that I would :(( on the course of this project and really hoped no to :sigh: along the way. In the end I had a lot of :doh:

                      "To alcohol! The cause of, and solution to, all of life's problems" - Homer Simpson

                      L 1 Reply Last reply
                      0
                      • N NormDroid

                        ON ERROR RESUME Nothing more, nothing less...

                        Software Kinetics Wear a hard hat it's under construction
                        Metro RSS

                        R Offline
                        R Offline
                        Roy from Detroit
                        wrote on last edited by
                        #38

                        I once had to take over a VB6 project (maybe 300 modules, each a few hundred lines) which had "On Error Resume Next" at the start of each and every routine. There were errors being thrown (and ignored) everywhere. I spent days just unraveling the circular references :sigh:. In critical places, I was able to add proper error handling (or at least check Err.Number to see if something important was being ignored) but did not have time to address them all. Truth be known, after a while, I got to LIKE "On Error Resume Next" :-D. Maybe it was Stockholm Syndrome, but it seemed like there was a certain..."freedom" in knowing the code just will not stop. Kind of like being a passenger an automobile accident. Once stuff starts happening, there is not a lot you can do until the big crunch at the end. :omg:

                        1 Reply Last reply
                        0
                        • Brian C HartB Brian C Hart

                          Okay, last day or so ago, I asked what your favorite programming job was. Now, what is the worst, nastiest, ugliest source code you ever saw and what made it so horribly bad? Not commented (heh heh yeah, as if) or one-letter (or zero-letter?) variable names? Written in a dead programming language that should be dead, but your client is still using it for some God-awful reason? The list goes on...so spew!

                          Sincerely Yours, Brian Hart

                          A Offline
                          A Offline
                          Alan Balkany
                          wrote on last edited by
                          #39

                          About a decade ago, I was a consultant at a data-mining company where most of the software "developers" were self-taught programmers with PhDs in other areas. One of the programs resulting from this had a 40-page C++ function! This company's software was unreliable, and was constantly crashing and being patched. Another place I worked at had convoluted C# code with no comments in their main system. The simplest modifications required a goddamn research project to trace the interactions among multiple files/classes. The owner of the company told me when he had the software written, he told the developer not to bother with comments to speed up development; "we don't need those!". And he wondered why bug fixes and new features took so long to add!

                          1 Reply Last reply
                          0
                          • Brian C HartB Brian C Hart

                            Okay, last day or so ago, I asked what your favorite programming job was. Now, what is the worst, nastiest, ugliest source code you ever saw and what made it so horribly bad? Not commented (heh heh yeah, as if) or one-letter (or zero-letter?) variable names? Written in a dead programming language that should be dead, but your client is still using it for some God-awful reason? The list goes on...so spew!

                            Sincerely Yours, Brian Hart

                            T Offline
                            T Offline
                            thoiness
                            wrote on last edited by
                            #40

                            The correct answer is always: "Any code that isn't mine."

                            1 Reply Last reply
                            0
                            • F Fabio Franco

                              There was this code they wrote a SQL Server stored procedure just for completing a string with zeroes to the left until its maximum length, in pseudo code it was like this:

                              if value.Length < 2
                              value = "0000000" + value
                              else
                              if value.Length < 3
                              value = "000000" + value
                              else
                              if value.Length < 4
                              value = "00000" + value
                              else
                              if value.Length < 5
                              value = "0000" + value
                              else
                              if value.Length < 6
                              value = "000" + value
                              else
                              if value.Length < 7
                              value = "00" + value
                              else
                              if value.Length < 8
                              value = "0" + value

                              When I saw this, I was like :omg: and wondered what else I was going to find :~. I feared that I would :(( on the course of this project and really hoped no to :sigh: along the way. In the end I had a lot of :doh:

                              "To alcohol! The cause of, and solution to, all of life's problems" - Homer Simpson

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

                              I had to do something similar recently to fix all the data in a column in a SQL DB cos the leading zeros had been lost in the data export. I think I did if length < 8 value = "0" + value and kept running it over and over until it changed no records. In my defense I don't really know SQL. More recently I had to stick trailing zeros back on that had been lost by an export routine (123456.789 exported and becomes 123456789, 123456.700 exports as 123456.7 and needs to become 123456700). I have to do this in xpath, which I am also just starting with. I would hate to post what I have come up with to achieve that.

                              Every man can tell how many goats or sheep he possesses, but not how many friends.

                              F 1 Reply Last reply
                              0
                              • L Lost User

                                I had to do something similar recently to fix all the data in a column in a SQL DB cos the leading zeros had been lost in the data export. I think I did if length < 8 value = "0" + value and kept running it over and over until it changed no records. In my defense I don't really know SQL. More recently I had to stick trailing zeros back on that had been lost by an export routine (123456.789 exported and becomes 123456789, 123456.700 exports as 123456.7 and needs to become 123456700). I have to do this in xpath, which I am also just starting with. I would hate to post what I have come up with to achieve that.

                                Every man can tell how many goats or sheep he possesses, but not how many friends.

                                F Offline
                                F Offline
                                Fabio Franco
                                wrote on last edited by
                                #42

                                ChrisElston wrote:

                                I think I did if length < 8 value = "0" + value and kept running it over and over until it changed no records.

                                Can I assume you used a loop? Because that's completely different. Imagine if the guy that coded the sample I provided had to do this for a 255 characters field. You get the idea right? I really hope you didn't do the same. And worse, this was a procedure on database for a common task of the application.

                                ChrisElston wrote:

                                I would hate to post what I have come up with to achieve that.

                                :~

                                "To alcohol! The cause of, and solution to, all of life's problems" - Homer Simpson

                                1 Reply Last reply
                                0
                                • Brian C HartB Brian C Hart

                                  Okay, last day or so ago, I asked what your favorite programming job was. Now, what is the worst, nastiest, ugliest source code you ever saw and what made it so horribly bad? Not commented (heh heh yeah, as if) or one-letter (or zero-letter?) variable names? Written in a dead programming language that should be dead, but your client is still using it for some God-awful reason? The list goes on...so spew!

                                  Sincerely Yours, Brian Hart

                                  B Offline
                                  B Offline
                                  Battlehammer
                                  wrote on last edited by
                                  #43

                                  After reading some of the responses, I guess I am lucky. However, one of the worse was at my last job I had to constantly fix bugs in my college's code. He almost always used two letters for variable names. All data tables were "dt" for example. Probably the worst was that he always used "ln" for "Last Name" and also used it for "Loan Number". (Banking applications) What a mess, you never knew what you were looking at. When stepping through the code I would be in one module looking at the Last Name and the next thing I knew, I was in another module looking at the Loan Number thinking "what happen"?

                                  1 Reply Last reply
                                  0
                                  • Brian C HartB Brian C Hart

                                    Okay, last day or so ago, I asked what your favorite programming job was. Now, what is the worst, nastiest, ugliest source code you ever saw and what made it so horribly bad? Not commented (heh heh yeah, as if) or one-letter (or zero-letter?) variable names? Written in a dead programming language that should be dead, but your client is still using it for some God-awful reason? The list goes on...so spew!

                                    Sincerely Yours, Brian Hart

                                    M Offline
                                    M Offline
                                    MacRaider4
                                    wrote on last edited by
                                    #44

                                    The worst I have come across so far is a vb program where the one sub is 2600 lines long. Yes I said "the one sub" :confused: I had to update that from VB 6 to 2010, took a few days to just figure out the flow of the application as it jumped all over the place with GOTO's. I hope who ever replaces me at some point in time finds the new version much easier to follow. There were some comments but they were things like "s = the count of something" not what was actually trying to be accomplished or anything...

                                    1 Reply Last reply
                                    0
                                    • E ekolis

                                      A month or two ago I got to see this Java codebase that I was supposed to work on; whoever wrote it apparently was a fan of this incredibly awesome (NOT!) paradigm I like to call "Hashtable Oriented Programming"... Basically, all business-tier classes implement a BusinessObject interface, which contains four methods: loadFromDb, saveToDb, a third one I can't remember, and the infamous getHashtable... The classes themselves do indeed implement these methods... and nothing else - no bean-style getters or setters! That's right, a Loan object has the exact same structure as a Realtor object; the only difference is the convention of "which keys do we stick in the hashtable?" It's almost as if they were trying to implement some sort of dynamically typed language on top of Java... just with none of the advantages, and all of the disadvantages! Thankfully I've been transferred to another project, so I don't have to mess with that nonsense! edit: Now I remember what the third method was... it was isInDb! This method was implemented rather... erratically, one might say: several of the classes implemented it by executing "select count(*) from theTable" and comparing to zero; if the count was not zero, the object was "in" the database! And no, I doubt that there were all THAT many "singleton tables" in the DB!

                                      J Offline
                                      J Offline
                                      Johnny Ess
                                      wrote on last edited by
                                      #45

                                      My project in a nutshell, they even did this with the session user object in a web application. A couple dozen columns accessible by name only, shared across the entire subsequent processing flow. The column names were aliased in the query so they didn't necessarily match the actual database names either. Then, to add insult to injury, any exceptions caught in any DML (insert, update, delete) simply put a zero in the rowcount value and calmly return. The caller has no other option but to wonder if no rows were affected or an error occurred. Since it's a server app, all the logs are hidden behind an alligator filled moat of: 1. A VPN account which not only kills your local network access (folder shares, email, printers, etc.), but also a roaming profile which makes it impossible to open an application from the start menu once the VPN connection is up. 2. Constantly expiring UNIX account passwords with limited file access privileges. (DEV environments included)

                                      1 Reply Last reply
                                      0
                                      • V Vivi Chellappa

                                        SAP requires costly, difficult-to-manage programmers be available in very large numbers so that one may be sacrificed daily to appease the beast! The same thing goes for Oracle ERP too!

                                        B Offline
                                        B Offline
                                        Br Bill
                                        wrote on last edited by
                                        #46

                                        In fact, I believe SAP stands for "Sacrifice A Programmer".

                                        1 Reply Last reply
                                        0
                                        • D destynova

                                          And its more verbose but equally horrible Java cousin:

                                          try {
                                          mystery1();
                                          mystery2();
                                          mystery3();
                                          mystery4();
                                          theRestOfTheProgram();
                                          } catch(Exception e) {};

                                          I've been bitten by that a few times, testing something that is not behaving as it should, but not producing any error messages. What's the point of having exceptions, and just as importantly, a managed language with automatic line-numbered stack traces etc, if you're going to suppress all of that goodness? :omg:

                                          O Offline
                                          O Offline
                                          oPhoenixo
                                          wrote on last edited by
                                          #47

                                          I've done this for ONE specific... case... now I wonder if there's a better way or if given the context it would be considered excusable. A file or a database call, I don't remember which that can fail via exception. Thing is, I believe the defaults were suitable, I was just checking the db/file for more correct values. That may not be exactly it (I really don't remember...) and if I left it empty I'd think comments explaining WHY would be neccessary. The rest of these comments are making me feel a lot better about my file and function length ^_^;;

                                          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