Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

It's happened to all of us. Maybe the original author is no longer with the company, or maybe the boss just doesn't trust him to fix it (Kernighan's Law). Either way, they gave it to you, and you ended up having to fix it. What was it like? What was the problem? How bad was the code, and what did you end up doing with it?

share|improve this question

closed as not constructive by Mark Trapp Aug 24 '11 at 22:09

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
I think most of the replies here, are a result of "copy-n-paste" code practices. Scary! –  ja72 Dec 6 '10 at 4:23
show 5 more comments

24 Answers 24

up vote 54 down vote accepted

I once had to work on a Classic ASP application where the lead developer had proudly claimed to have rewritten the underlying data-access components in .NET.

Technically, he wasn't lying, and the code was littered with statements like:

set query = "EXEC spDeleteCompany " & intCompanyId
arrResult = ExecuteWebServiceSQL("http://www.url-obscured-for-obvious-reasons.com/Service1.asmx", query)

Yes, that's a web-service, cunningly named 'Service1.asmx' (the default name given by Visual Studio), that will happily run any SQL statement given to it.

Oh, and the web-service was completely open to outside access as well.

share|improve this answer
add comment

The scariest code I've ever dealt with would probably be the code for a .NET 2.0 application:

  • Well, there was the main form, which contains 27,591 lines, 4,754 of which is the auto-generated Windows Form designer code. In other words, over 20,000 lines of actual code written by the original developer, in one file, in one project, for a single form. And lest you think the developer could have only done this by shoving the entire application into a single, super-awesome, monolithic God form, no, no. There are other files in this project, such as the 12,000-line "main module"...

  • We use the fairly well-known convention of prefixing global variables with g_ and module or class-level variables with m_. This vexed and perplexed our dear developer, so much so that at some point he gave up and starting prefixing every variable with g_.

  • Code that combines variable scope and purpose in cruel and inhumane ways: for example, the phrase "global temporary counter variable" actually makes sense in the context of this code (and it may or not be surprising to know that this variable is actually called...wait for it...g_temp).

  • Inner monologues that I think went like this: "Select Case is cool. But, but...I can't Select Case on the currently-selected toggle button control because I don't understand object references! But...oh wait a second! These buttons all have captions! And, and...strings work with Select Case, and...oh boy I know exactly how to solve this problem!!! The only issue with this solution is that this code isn't indented far enough to the right. I need some superfluous If statements around all this Select Case goodness. No wait, five levels of nested If statements, and then I can put the Select Case in there!"

  • So many compiler warnings that the compiler generated a warning saying that no more warnings could be generated.

  • Just opening the project and actually trying to build it has crashed Visual Studio on multiple occasions.

share|improve this answer
1  
Why did he surround Select Case goodness with Ifs? –  galymzhan Jul 27 '11 at 14:56
add comment

Here's some C# code I discovered yesterday, created by a code monkey from a certain country (that shall remain nameless), which specializes in very, very low-cost outsourcing. (Proving once again that you get what you pay for.)

The programmer created a UserControl - let's call it LittleControl. She then created another control (BigControl), which contained all manner of panels and other containers, as well as an instance of LittleControl. Now she wanted to catch click events inside the LittleControl, and under certain circumstances pass them up to BigControl to handle.

So what does she do? Raising an event would have been much too straightforward. ("That's just what they would expect!") Herewith the code inside the Click event of LittleControl:

if (this.Parent.Parent.Parent.Parent.Parent.Name.ToUpper() == "BIGCONTROL") {
  BigControl ctrl = (BigControl)this.Parent.Parent.Parent.Parent.Parent;
  ctrl.HandleLittleControlClick();
}
share|improve this answer
add comment

I once found this monster in our code base. Yes, there is a variable named "the_list".

if (the_list[0].Unit1 != null)
{
    start_time = the_list[0].Times[0][0].AddSeconds(chart_info.Series_Offset.Start[0]);

    stop_time = the_list[0].Times[0].Length > 1 ? the_list[0].Times[the_list[0].Times.Length - 1][the_list[0].Times[the_list[0].Times.Length - 1].Length - 1].AddSeconds(chart_info.Series_Offset.Start[0] + ((chart_info.Series_Offset.End[0] - chart_info.Series_Offset.Start[0]) / (ArrayLength(the_list[0].Times) - 1)) * (ArrayLength(the_list[0].Times) - 1))
: the_list[0].Times[the_list[0].Times.Length - 1][the_list[0].Times[the_list[0].Times.Length - 1].Length - 1].AddSeconds(chart_info.Series_Offset.Start[0] + ((chart_info.Series_Offset.End[0] - chart_info.Series_Offset.Start[0]) / (ArrayLength(the_list[0].Times))) * (ArrayLength(the_list[0].Times) - 1));
}
share|improve this answer
add comment

120,000 lines of pure FORTRAN 77 spaghetti code. Sprinkle in some undocumented OpenGL API, and the worst filename/path handling on the planet (still can't use spaces in path), developed over many years by 3-4 engineers, with no formal training in how to program and there you have it.

share|improve this answer
show 2 more comments

~180,000 lines of PHP code, without a single function defined. A complete mess of cyclic include directives.

And this was before PHP added the goto keyword. I shudder to think what it would have looked like had that been available.

These days it's down to < 80,000 lines of code with an object-oriented approach to design. Most circular includes are gone. Still, a good chunk of original, unmodified, duplicate code exists in the system, but it is much, much more maintainable now.

share|improve this answer
add comment

I don't remember the method itself. It's too long to paste in here anyway (some 2000+ lines). But it had this Javadoc on top of it:

/**
 * NEVER EVER TOUCH THiS METHOD OR EvERYTHING WILL EXPLODE !!!
 */

Haha. But I refactored it away (gradually over 2 years) and then the adapted comment read:

/**
 * NEVER EVER TOUCH THiS METHOD OR EvERYTHING WILL EXPLODE !!!
 * ^^^
 * Chicken! ;-)
 */

But I have to admit, compared to the 120k lines of FORTRAN that I saw around here, that was a piece of cake.

share|improve this answer
add comment

We have a file called Model.cs which is over 70,000 lines long. Yes, some is generated, but most is not. And a class called SomeUtilityThingieClass.. seriously.

share|improve this answer
add comment

In a past job in an industrual automation control company, I used to maintain a large MFC application that was built on a code base that was originally written like this:

Back in the 1980s, they didn't even have programmers. They simply had their electrical and mechanical engineers write code, because the UIs were command line based and simple. All the code was embedded C anyway, so it wasn't so bad for (especially electrical) engineers to do.

When the controls were updated to Windows in the 1990s, they simply got the electrical engineers to take the embedded C code, and turn it into into Windows C code with a simple GUI. Times were changing, so eventually, the market started to demand a more sophisticated graphical interface - so what happened? - They let a small group of their electrical engineers take the code base and attack it with a Visual C++ For Dummies type of book. Difficulty? - All the company had was a C compiler in the early days. They only bought the full version of Visual Studio later down the line, a couple of years before my time.

End result: C code with macros containing function pointers which mimics C++ classes, with some "proper" MFC thrown into the mix on top of this. Absolute. Nightmare. If I never have to see "void***" again for the rest of my life, it'll be too soon.

share|improve this answer
add comment

This is a small chunk of a monstrous VB6 app. (I refactored this into 1 simple stored proc.)

'Figure Tax Rate and Totals
'If we are not viewing or printed a previously created invoice, these will need to be calculated
If mstrCommand <> "PrintInv" And mstrCommand <> "DownloadInv" And mstrCommand <> "View" And mstrCommand <> "Rollup" Then
    'Figure Tax Rate First
    query = "select startdt, enddt from inv_taxcust where billto in (select dbo.trim(c.custacctnum) custacctnum from customer c, caseinfo ci where ci.caseid=" & mCaseId & " and ci.billtoid = c.custid) and shipto in (select dbo.trim(ce.empacctnum) empacctnum from cust_employer ce, caseinfo ci where ci.caseid=" & mCaseId & " and ci.empid = ce.custid) and startdt < dbo.mdy(" & Format(Now + 1, "mm,dd,yyyy") & ") and (enddt > dbo.mdy(" & Format(Now - 1, "mm,dd,yyyy") & ") or enddt is null) and stateval like '%' +'" & branstcd & "'+ '%'"
    Set rs = cn.Execute(query, , adCmdText)
    If rs.EOF Then
        'First, look for tax rate by checking branch's zipcode
        query = "select rate from taxrates where zipcd = (select zipcd from location where locatid = (select locatid from branch where branchid = (select branchid from caseinfo where caseid=" & mCaseId & ")))"
        Set rs2 = cn.Execute(query, , adCmdText)
        If Not rs2.EOF Then
            mxmlApp.SetNode mControlNode, "taxrate", CStr(rs2.fields(0))
            rs2.Close
        Else 'If zipcode doesn't match, then check by state (where zipcode is null)
            rs2.Close
            query = "select rate from taxrates where (zipcd is null Or zipcd = '') And statecd = (select statecd from location where locatid = (select locatid from branch where branchid = (select branchid from caseinfo where caseid=" & mCaseId & ")))"
            rs2.Open query, cn, , , adCmdText
            If Not rs2.EOF Then
                mxmlApp.SetNode mControlNode, "taxrate", CStr(rs2.fields(0))
                rs2.Close
            Else
                rs2.Close
            End If
        End If
        Set rs2 = Nothing
    End If
    rs.Close
    Set rs = Nothing

    mxmlApp.SetNode mControlNode, "amountbt", CStr(amount_bt)
    mxmlApp.SetNode mControlNode, "amount", CStr(Round(amount_bt * (1 + mxmlApp.GetNodeValue(mControlNode, "taxrate")), 2))
Else
    Set rs = cn.Execute("select amount, amountbt,IsNull(convert(varchar,taxrate),'NULL') taxrate from inv_billinv where invid = " & minvid, , adCmdText)
    mxmlApp.SetNode mControlNode, "amountbt", rs.fields("amountbt")
    mxmlApp.SetNode mControlNode, "amount", rs.fields("amount")
    'We need to cstr the taxrate so value less than zero don't get rounded to zero. Null values can not be Cstr however
    mxmlApp.SetNode mControlNode, "taxrate", IIf(IsNull(rs.fields("taxrate")), Null, CStr(rs.fields("taxrate")))
    rs.Close
    Set rs = Nothing
End If
share|improve this answer
add comment

I have quite a few examples of this, but I would have to say the scariest one I've ever had to maintain (read that as fix) was the web client I'm currently working on.

The whole reason I was hired here was to fix this webclient. Every day I find new and exciting code horrors.

To give you some idea of the magnitude of how bad the code is, let me tell you that the bulk of the code was written by co-op students that had no web development experience what-so-ever. What wasn't written by unsupervised newby co-ops, was written by two people who were fired because their code was so bad that it was eating hours on fixing it. Both were sent to webclient limbo before they were fired, because it would cause the least impact on the overall code base.

The one biggest error I've seen in this web client's codebase is the blatant misuse of the word Cache. Cache is used everywhere...most times when it is Session they want. Search results? Cached. Reports? Cached. User permissions? Cached.

What's worse are the hacks that have been written to kinda make the Cache behave like the Session.

I've fixed all of those. Every page I touch I try to leave it in better shape than it was. Rewrite a procedure here. Clean up a method there. If it can't be saved, scrap the page and start fresh. If nothing else, this code base will keep me employeed for a few more years atleast ;)

share|improve this answer
add comment

I used to work on an integrated word processor, spreadsheet, and database package that was originally written in the 1980s. A lot of the internal communication between components was done using a global char array called "bigbuf". If you needed to get some data from one place to some other far away place you'd find a (hopefully) unused portion of bigbuf, cast your data to a sequence of char, slip them into your unused portion of bigbuf, and then pull them out twenty steps away in some other semi-related function. The code was littered with such things. And, of course, there was also "smallbuf" for when you couldn't find a safe place in bigbuf. The developer hired immediately before me quit after one day (but I got his nicer office).

share|improve this answer
add comment

The scariest piece of code I've had to maintain was in some respects a work of Mad Genius, written by a self taught programmer over the course of about 20 years. Some of the code was really clever, but some commonly known problems were solved in excruciatingly complicated ways.

The main things that made it so tough was that variable names averaged between 3 and 4 letters, max of 6, all uppercase, and about 90% of variables were global. No comments ever, 3 pages of docs written 5 years ago.

Plus, he had written a custom database access layer that gave each column name a unique integer ID, and all code referenced only that ID. And his favorite control statement was a goto (why use a loop when you can use a conditional goto to build your own?).

This meant a lot of the code would read like (in pseudocode):

If UBP>GETDATAELEMENT(50312) GOTO VILF

VRX=GETDATAELEMENT(34012)/2+OZP-376

GOTO OIK

and so on for pages and pages (I think about 500k lines of code total). Bear in mind that I would generally have no idea what any of the variable names meant, and would be reading this code as part of tracing a call through one of the myriad pachinko machine paths though the forests of GOTOs that were often based on the values of variables set in some unknown line of code somewhere in the code-base (which, as you might by now assume, was one giant module).

Part of the code was a screen driver for a terminal window, which supported many hundreds of screen-based forms. The driver had been modified to control a VB6 GUI application, with the small problem that the event model of a GUI form simply doesn't match that of terminal, so the form code frequently didn't work (e.g., you can't enter screen-based field values out of order, so you never need to worry that prior fields are undefined- until you switch to a GUI).

The GUI was supposed to handle all of these conditions by doing things like forcing focus back to fields that would have been filled out in a screen based form. The design was inherently a viper's nest of race conditions and I spent most of my time trying to account for most of the possible variations.

share|improve this answer
add comment

I once had to work on a legacy in-house developed content-management system that was based on Classic ASP, VBScript, HTML3 and used MS Access for the back-end database. All of the code was mixed in with the HTML and it was highly dependent on magic-numbers, hard-coded values and other such constructs. To give you a flavour of the code, here's just part of the "function" that works out what intro text to display for a page:

if intCategoryId=2 and intSubCatId=0 then strSubCatName = strCatName
If intCategoryID = 2 AND intSubCatID = 53 Then strCatName = "Training &amp; Conferences Introduction"

intSubCatID = Request("cat")
If IsNumeric(intSubCatID) Then
    intSubCatID = cint(intSubCatID)
Else
    intSubCatID = 0
End If

If catName = "Download" and intCategoryId = 1 Then
    strCatName = "Download"
    strSubCatName = ""
    strArticleName = ""
End If

if intCategoryId=5 and catName="meeting" Then strSubCatName = "Regional Event"
if intCategoryId=5 and session("membername") = "" and catName <> "register" then Response.Redirect "index.asp"

If len(trim(CatName)) > 0 then
    If CatName = "Links" then
        If intCategoryId = 1 or intCategoryId = 5 Then
            strIntroText = objMain.GetIntroText(strConn,intCategoryId,intSubCatId)
        else
            strIntroText = objMain.GetIntroText(strConn,intCategoryId,strSubCatName)
        end if
    Else
        if intCategoryId = 1 or intCategoryId = 5 or intCategoryId = 2 then
            strIntroText = objMain.GetIntroText(strConn,intCategoryId,CatName)
        else            
            strIntroText = objMain.GetIntroText(strConn,0,CatName)
        end if
    End If
Else
    strIntroText = objMain.GetIntroText(strConn,intCategoryId,intSubCatId)
End If

strintrotext = replace(strIntroText, "<FONT size=2>", "", 1)

I think this speaks for itself...

share|improve this answer
add comment

I don't have the code accessible, but it was in the massive VB5 "translator" services (moving/mangling between databases) that I had to maintain. The top of each function contained a dozen lines of DIM statements, multiple dims each line, none with any clear names, all scoped for the entire function. The functions themselves were often hundreds and hundreds of lines of DEEPLY nested if statements (often half the function was encased in a giant if statement). I've never had to scroll to the right so far to read code.

These were ad hoc programs that became the core of the business. Oh, and no one had any of the business rules written down. Anywhere. Only one person actually knew the rules.

There were some nice people at that company, but the software situation was horrendous, and no one wanted to fix it (too risky!). I just couldn't keep going and had to leave.

share|improve this answer
add comment

I got lots of scary code to maintain right now on one of our large projects. It really makes me sick every time I'm facing in front of my laptop untangling spaghetti code. One of those are nonsense for-loops with nonsense variables in it. The person responsible for it already left our company and he didn't fix the code ever.

share|improve this answer
add comment
if (isset($_POST['f003'])) {
        $f003 = escape_data(strip_tags($_POST['f003']));
    }
    if (isset($_POST['f004'])) {
        $f004 = escape_data(strip_tags($_POST['f004']));
    }
    if (isset($_POST['f005'])) {
        $f005 = escape_data(strip_tags($_POST['f005']));
    }
    if (isset($_POST['f006'])) {
        $f006 = escape_data(strip_tags($_POST['f006']));
    }
    if (isset($_POST['f007'])) {
        $f007 = escape_data(strip_tags($_POST['f007']));
    }
    if (isset($_POST['f008'])) {
        $f008 = escape_data(strip_tags($_POST['f008']));
    }
    if (isset($_POST['f009'])) {
        $f009 = escape_data(strip_tags($_POST['f009']));
    }
    ....snip  and on and on and on... to $f036

    if ($f001 && $f002 && $f003 && $f004 && $f005 && $f006 && $f007 && $f008 && $f009 && $f010 && $f011 && $f012 && $f013 && $f018 && $f019 && $f020 && $f021, ....etc) {
    //Update DB ....snip
  1. No use of prepared statements.
  2. No mention of what these vars represent.
  3. No indentation used in the hundreds of lines of HTML/PHP mess after that.
  4. Sometimes $f009 used where $f019 was expected, etc, etc...

I cried a bit when i saw this... sigh

share|improve this answer
add comment

I worked on a loyalty card application once. All the old developers had decided to quit, and we inherited this 'working' app. But, when we looked closer, we found it was difficult to add new data to the DB. turns out it had somehow become normalised so one table had dependancy on data in another table which had dependancy on another which had a dependancy on the original table. God alone knows how they managed to get data in there in the first place. It was the only time I've seen a need for a total rewrite (and I hate the 'lets rewrite' attitude!)

Mind you, perhaps the scariest thing was a report generator written many years ago by some Russian contractors. Nothing wrong there, the product was good, those guys were really, really great (and ridiculously cheap in the days before outsourcing became popular). But all the comments were in Russian. Oh, and to get network connectivity back to their university, my manager had to deal with the KGB. He liked that.

share|improve this answer
add comment

When I was interning at a place I was put in charge of their internal reporting website which used Coldfusion (which I had to learn in 2 days) and some crazy JS to make it look cool. From what I could tell it was a few years old, and of course had little documentation, most of which was out of date. And of course a bazillion people had worked on it over the years.

(Note I haven't touched CF in 2 years, so some of the terminology might be wrong)

It was a pain since code was spread all over the place with no standards in place. SQL (which was MSSQL when I only knew MySQL) was stored all over the place: Stored Procedures, 4 utility classes, and in code. The menus had a utility class to autogenerate some (that was used only twice) and custom implementations everywhere else. And there where classes locked away in some default include directory on the application server that I of course didn't have access to for a while. And of course basic patters like MVC weren't followed, it was just some inline CFM inside of HTML pages and separate utility classes.

You also had some crazy stuff like trying to display 2 million test records one one page, SQL that locked the server for a few minutes trying to run it, along with a few other things. Not only that but apparently projects were hosted on the server, which I accidentally froze a couple of times with infinite loops or giant SQL queries. And then their was IE support...

I spent a long time just removing duplicate code, centralizing stuff, fixing the ridiculous JS, and fixing as much SQL as I could, and of course tons of documentation. I had to rewrite most of the "utility" classes and most of the JS animations. I was so happy when I did the final commit, knowing that I wouldn't have to touch that mess again.

It might seem like I'm whining when you compare it to C++ or Ruby, but for me it was hard.

share|improve this answer
add comment

It was part of rather large C++ application. Original programmer probably thought, that it would be very smart, to create two sets of database tables for single entity such as mail address book. Main addrbook data was kept in a 'simple' table with one blob field. That blob contained all addressbook fields joined with special escape characters like '\x2'or '\x5' between them. And there was second set of tables, that looked pretty normal. But they were used only for reading by some functions. Worst things happend when those two got out of sync.

I wasn't allowed to change this, because 'new addrbook is almost ready'. But there was no week without some bug reported in old code, that I was supposed to fix ASAP. :)

share|improve this answer
add comment

In my case, was a REALLY big piece of software in C++, about 15 years old since the start, with bizillions of coders working on the code during that time, and each one with their particular code standards...

Two different modules can appear almost as written in different languages. Sometimes you'll expect a complete file with just one comment line (the date) and then another one with more comments than lines (and usually out of date)

There were also some "funny" features of C++, like overloading the call (bracket) operator (you'll think that it's calling a function, but not, it's an operator on the object). Overloading operator is 99.9% of the times a VERY BAD IDEA. Makes your code a lot more difficult to read.

Sometimes the code was highly object oriented, other times was more like plain C. Sometimes makes use of non-evident mathematical properties, like using matrix determinants (of course, without stating that or comment it on any way).

The most important work I had to do was completely redesign from scratch one of the modules that was been considered as completely unmaintainable from a long time, and have severe performance problems on the long run. It contains some parsing to describe functions. The parsing was made completely by hand, by some really weird code (I didn't even try to understand it, one of the directives at the start was "everyone that has try it has gone mad", maybe that was some sort "Necronomicon code"). I used Bison. The testing was completely black-boxed, set the same inputs, run the module and check the outputs.

Well, at least everything ended fine, the CPU time was reduced in about a 80%, memory in about 30% with better resolution and lower latency. But sometimes working with that you wanted to commit suicide...

share|improve this answer
6  
Operator overloading can be a very useful tool, but it can very easily get into nightmare land. Overloading () is essential when making a function-like object ("functor"), but using it for anything else is almost certainly a Bad Idea. –  David Thornley Nov 23 '10 at 22:50
3  
@Mason: Yes, it tells me it was designed for intelligent people to use, and leaves itself open for possible serendipitous use of features. Also, what's the missing feature that functors emulate? –  David Thornley Dec 16 '10 at 19:43
2  
@David: Closures, which just about every modern language (except C++ and Java) supports these days. –  Mason Wheeler Dec 16 '10 at 19:49
4  
A common thought process behind rejecting operator overloading is "I assume I'll never encounter operator overloading, therefore when I do encounter it it confuses me, therefore operator overloading is bad". You could use the same logic to reject virtually anything. The correct conclusion is "therefore the assumption is bad". Obviously operator overloading (like anything) can be abused, but it isn't a bad thing when used appropriately. –  Steve314 Jul 27 '11 at 14:54
1  
If overloading the ()-operator is a "funny" feature to you, then you haven't programmed C++ for a long time, haven't you? But you're right in that it can confuse people who don't have much experience with C++ or operator overloading in general. –  Christian Rau Aug 25 '11 at 1:37
show 2 more comments

I'd have to say the scariest piece of code I ever had to maintain was this windows service... written in Visual Basic... as a control... in French. (The company I worked for had bought a French software company for their code.)

Yes, that means that the function names were in French, the variables were in French, and the comments were in French. It was amazing. I would have an online translator in one browser window the whole time, translating things so I could get an idea of what they were. As I figured out what the private methods did, I would convert their names and arguments into english, but anything that was public had to stay in French, although I did update the comments.

I found a Visual Basic testing framework that I was able to connect the control up to so I could try automating tests and nail down what it was supposed to do.

Eventually, of course, I left the company and it became someone else's problem, although I believe the whole framework was being rewritten in Java anyway.

share|improve this answer
2  
One should hire a developer who knows French for such a task. –  Paŭlo Ebermann Jul 27 '11 at 18:55
show 1 more comment

Back in 1997 I was given my first developer job which consisted of supporting an accounts package written in QuickBasic 7.1. The code for this app had many hallmarks of poor practise:

  • The .bas files were split into not very logical portions. Often duplicated code had to be changed in more then one file, which lead to problems being reported by customers if we missed a bit. The SOLID principles certainly did not exist at this place!

    The worst example was during the time I had go through all the code to make it Y2K compliant. There were tons of places that made use of dates - calculating them, formatting them, you name it. All of this could have been placed into a separate "Date Routines" module, but instead, I had to spend many days changing the same patterns of date logic in hundreds of locations. Not much fun :(

  • The layout of the code was difficult to follow. Almost 99% of the time you could guarantee that there will be variables named such as "a$" in a module. Not only that, those variables were used for more then one purpose. In one file, the variable "a$" was an account ID and then later a loop index helper for reading an external file.

There were no useful comments in any file. Likely the only comments you'd get were the usual, pointless, file header comments like this:

 ''***************************************************************
 ' Account.bas
 ''***************************************************************

I wasn't sure what the name of the file was, but thanks to this comment, I was enlightened.

Debugging problems in the code took ages. Seriously, trying to solve a particular bug could be a real MENSA challenge due to the poor code.

One time, the managing director of the company was standing next to me whilst I was debugging an issue. In my frustration I asked him "Who wrote this poor code?", he said "It was me". You would have thought I'd feel a little awkward at that moment, but, in my mind, I was laughing my head off. Not many get the chance to tell their boss that they're a shit developer!

Cheers. Jas.

share|improve this answer
add comment

I found several uses of the goto statement in a 5000+ line static method inside a class filled with other static methods; this in C# 3.5. The entire class might as well have been a VB6 module.

Also, Classic ASP with zero indentation and variables that looked like vowels were removed, and duplicate logic with like one thing different. Along the lines of:

rs.open()
while rs.MoveNext()
' do stuff
if rs("foo") = True then
prodnam = rs("prodnam")
prodprce = rs("prodprice")
ordttl = rs('ordttl")
else
prodnam = rs("prodnam")
prodprce = rs("prodprice")
ordttl = rs("ordttl2")
end if
wend
rs.close()
share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.