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.
  • 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
          • J Jorgen Sigvardsson

            I was hired to port a case management system for intellectual properties (patents, trademarks, etc) to Java/EE. It was written in Power Basic (Sybase 3.5 GL language) by someone who learned programming in C64 basic. I have not seen such clutter before in my life. I found huge blocks of code that literally could've been removed, countless dependencies on global variables, ugly SQL (they often stored their queries in the database - WTF?). Such a mess. I still have nightmares. On several occasions, my design decisions were overridden by their management. One case involved user role management. I proposed the standard role/object/model that is well understood. They agreed, but refused to understand basic set theory. An empty set of access rights would mean "all access to everything" according to them. I responded that is a bad idea, and makes security administration overly complex, and potentially insecure. They would not understand (even after countless of negative use cases). I implemented their stupid ideas. Later on they did not want to pay for my work on the role management, because "it was implemented badly". WTF? They said I did not implement it according to their specifications. Guess what? The "specifications" was my original design! I told them I don't do business with liars, and we went to court. I got half in a settlement. If I had wanted 100% of what they owed, the case would've taken at least one more year. I don't want to spend time in court, I want to create, so I grabbed the 50% and vowed to myself not to fall into that trap again. I was screwed royally on that gig. Code wise and business wise. I have also encountered code for an installer driver that was spaghetti in several dimensions. Structure wise, and thread wise! The code had bugs that the original authors could not track down in 6 months. I spent two weeks with a colleague trying to track it down. I just gave up and kept bugging the management until I was approved to ditch the code, and rewrite it. It turned out that another division in the company had written a really good installer driver, so the story had a good ending!

            -- Kein Mitleid Für Die Mehrheit

            R Offline
            R Offline
            Russ Warner
            wrote on last edited by
            #48

            Jörgen Sigvardsson wrote:

            they often stored their queries in the database - WTF?

            Haven't you ever heard of a "stored procedure?" :laugh:

            J 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

              U Offline
              U Offline
              User 3859823
              wrote on last edited by
              #49

              The worst code I have seen lately was a .net application that had been updated from through the .net versions .net 1.1 to .net 4 using the vs migration update tools but other than sorting out a couple of build errors no changes were made. I was asked to review the code for the company and to add some additional functionality. I was told it would only take a few days. it was terrible created over time by about several consultants hired over the years it had the joy of using 4 of the .net languages (java.net, c#, vb (which is bad enough on its own), and c++) a couple of purchased library for .net 1.1 still being used in .net 4 version, all in a single project no comments never sticking to a single coding style, variable names were just funny words and no unit testing at all. (oh it was also not in version control and was mission critical to the company) Having explained all this o the boss using pretty pictures and fancy words I spent 4 days putting it in to version control and adding in the new functionality to the code that they wanted, and making it live. I then had 10 weeks of fun sorting the whole hornets mess out. The first few weeks converting all the code into just one language c# just to make life easier and adding some basic unit tests. Then started to actually get the code up to scratch and taking advantage of .net 4.0 changes and even the use of masterpages, after about 6 weeks efforts getting the code up to scratch the source code was less than half the size their was unit testing and a heck of alot of major bugs were fixed. Alas after all that effort and actually getting accurate reports about the state of the company from the app they learnt the company was doing crap (were as before due a error were negative were being treated as positive numbers in the finacial system), the company decided ot hire some consultants who advised to move to a purchased system, the company is now bust shame but managements fault.

              Good luck

              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

                M Offline
                M Offline
                mrchief_2000
                wrote on last edited by
                #50

                Norm .net wrote:

                ON ERROR RESUME
                 
                Nothing more, nothing less...

                This one beats yours:

                On Error Resume Next
                'Do Somthing
                Err.Clear()
                On Error Resume Next
                'Do Somthing
                Err.Clear()
                On Error Resume Next
                'Do Somthing
                Err.Clear()
                On Error Resume Next
                'Do Somthing
                Err.Clear()
                ...

                And it goes on for every single line in the code.

                1 Reply Last reply
                0
                • R Russ Warner

                  Jörgen Sigvardsson wrote:

                  they often stored their queries in the database - WTF?

                  Haven't you ever heard of a "stored procedure?" :laugh:

                  J Offline
                  J Offline
                  Jorgen Sigvardsson
                  wrote on last edited by
                  #51

                  Lol! I guess they put the newbie in charge of the stored procedures... :-D

                  -- Kein Mitleid Für Die Mehrheit

                  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

                    S Offline
                    S Offline
                    Steven O
                    wrote on last edited by
                    #52

                    One system that I worked on about 10 years ago, required a heck of a lot of database work. We were on SQL Server 6.5, and the database collation was set up so that code was case sensitive. The big problem on this project was that developers loved writing these monser stored procedures that were thousands of lines long. The stored proc in question was about 2000 lines long, and riddled with the same variable names, with different cases, e.g. @PatientRx @patientRx @patientrx @PATIENTRX @Patientrx @PatientRX This wasn't limited to one variable either, but multiple variables. I eventually re-wrote the stored proc after about a week of trying to figure it out.

                    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
                      Thomas McGrath
                      wrote on last edited by
                      #53

                      A quick list of the things I've seen: ON ERROR RESUME starting every routine Using 70 textboxes to simulate a spreadsheet Everytime the database was opened it was never closed Everytime data was retrieved it was using 'Select * from', even when getting 1 field Variables declared and never used, and Variables used that were never Declared, both in the same routines. Creating temporary records in the database and never deleting them. A whole section dedicated to an internal email system, in a program where a majority of the clientele were mom & pop used car dealers with 1 computer. All of these were in the same code I was hired to maintain. I eventually gave up trying to wade through fixing it and re-wrote the entire program in my spare time.

                      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

                        K Offline
                        K Offline
                        KP Lee
                        wrote on last edited by
                        #54

                        Let's see, this was years ago. FORTRAN. Uncommented? Of course, real programmers don't use comments. (I'm not a real programmer.) This subroutine was about 5000 lines long, label numbers randomly organized, goto statements all over the place, going up/down and if he could do it, sideways. Some of the code, I'm sure is dead because I can't see any way to reach it, but I'm not about to remove it because I've been wrong before.

                        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