TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: What's the largest amount of bad code you have ever seen work?

428 pointsby nobody271over 6 years ago
I think I've broken my own record with this one ~2500 lines of incoherent JavaScript/C#. Works though.

116 comments

oraguyover 6 years ago
Oracle Database 12.2.<p>It is close to 25 million lines of C code.<p>What an unimaginable horror! You can&#x27;t change a single line of code in the product without breaking 1000s of existing tests. Generations of programmers have worked on that code under difficult deadlines and filled the code with all kinds of crap.<p>Very complex pieces of logic, memory management, context switching, etc. are all held together with thousands of flags. The whole code is ridden with mysterious macros that one cannot decipher without picking a notebook and expanding relevant pats of the macros by hand. It can take a day to two days to really understand what a macro does.<p>Sometimes one needs to understand the values and the effects of 20 different flag to predict how the code would behave in different situations. Sometimes 100s too! I am not exaggerating.<p>The only reason why this product is still surviving and still works is due to literally millions of tests!<p>Here is how the life of an Oracle Database developer is:<p>- Start working on a new bug.<p>- Spend two weeks trying to understand the 20 different flags that interact in mysterious ways to cause this bag.<p>- Add one more flag to handle the new special scenario. Add a few more lines of code that checks this flag and works around the problematic situation and avoids the bug.<p>- Submit the changes to a test farm consisting of about 100 to 200 servers that would compile the code, build a new Oracle DB, and run the millions of tests in a distributed fashion.<p>- Go home. Come the next day and work on something else. The tests can take 20 hours to 30 hours to complete.<p>- Go home. Come the next day and check your farm test results. On a good day, there would be about 100 failing tests. On a bad day, there would be about 1000 failing tests. Pick some of these tests randomly and try to understand what went wrong with your assumptions. Maybe there are some 10 more flags to consider to truly understand the nature of the bug.<p>- Add a few more flags in an attempt to fix the issue. Submit the changes again for testing. Wait another 20 to 30 hours.<p>- Rinse and repeat for another two weeks until you get the mysterious incantation of the combination of flags right.<p>- Finally one fine day you would succeed with 0 tests failing.<p>- Add a hundred more tests for your new change to ensure that the next developer who has the misfortune of touching this new piece of code never ends up breaking your fix.<p>- Submit the work for one final round of testing. Then submit it for review. The review itself may take another 2 weeks to 2 months. So now move on to the next bug to work on.<p>- After 2 weeks to 2 months, when everything is complete, the code would be finally merged into the main branch.<p>The above is a non-exaggerated description of the life of a programmer in Oracle fixing a bug. Now imagine what horror it is going to be to develop a new feature. It takes 6 months to a year (sometimes two years!) to develop a single small feature (say something like adding a new mode of authentication like support for AD authentication).<p>The fact that this product even works is nothing short of a miracle!<p>I don&#x27;t work for Oracle anymore. Will never work for Oracle again!
评论 #18463181 未加载
评论 #18448546 未加载
评论 #18452654 未加载
评论 #18451311 未加载
评论 #18443581 未加载
评论 #18452542 未加载
评论 #18459897 未加载
评论 #18449187 未加载
评论 #18453013 未加载
评论 #18480715 未加载
评论 #18443400 未加载
评论 #18451030 未加载
评论 #18443253 未加载
评论 #18444747 未加载
评论 #18443112 未加载
评论 #18451598 未加载
评论 #18450291 未加载
评论 #18458502 未加载
评论 #18449372 未加载
评论 #18458227 未加载
评论 #18467347 未加载
评论 #18443195 未加载
评论 #18459325 未加载
评论 #18459621 未加载
评论 #18472655 未加载
评论 #18463161 未加载
评论 #18458674 未加载
评论 #18452457 未加载
评论 #18454061 未加载
评论 #18468375 未加载
评论 #18452612 未加载
评论 #18460129 未加载
评论 #18495626 未加载
评论 #18490959 未加载
评论 #18458752 未加载
评论 #18451017 未加载
评论 #18495614 未加载
评论 #18453902 未加载
评论 #18463943 未加载
评论 #18483555 未加载
评论 #18458255 未加载
dejvover 6 years ago
I am maintaining one application in construction industry space. That application was created 25 years ago by construction worker that never wrote single line of code before, but because he caused a lot of problems on construction site they give him Programming 101 book and let him build it.<p>15 years later the app was close to half milion lines long of huge bowl of spaghetti code. Only comments in whole codebase were timestamps. I don&#x27;t know why he dated his code, but I find it fascinating: he never deleted basically anything so you can find different timeframes of when he discovered various concepts. There is use-exception-instead-of-if period, there is time when he discovered design patterns, there is time before he learnt SQL so all the database queries was done by iterating over whole tables and such. I am sure I will find commented Hello world somewhere in the code someday.<p>I am working on this codebase for 10 years. Code quality improved and major issues get fixed, but there is not enough budget to actually rewrote whole system, so after all it is more or less huge spaghetti monster and I get used to it.
评论 #18448452 未加载
评论 #18449519 未加载
评论 #18449307 未加载
评论 #18448302 未加载
评论 #18448453 未加载
评论 #18448269 未加载
评论 #18449339 未加载
评论 #18448947 未加载
评论 #18448075 未加载
评论 #18452765 未加载
评论 #18456167 未加载
评论 #18448187 未加载
评论 #18448181 未加载
wcarssover 6 years ago
Years ago as an intern at Microsoft, I had code go into the Excel, PowerPoint, Word, Outlook, and shared Office code.<p>Excel is an incomprehensible maze of #defines and macros, PowerPoint is a Golden Temple of overly-object-oriented insanity, and Word is just so old and brittle you&#x27;d expect it to turn to dust by committing. There are &quot;don&#x27;t touch this!&quot;-like messages left near the main loop _since roughly 1990_.<p>I had a bug in some IME code causing a popup to draw behind a window occasionally, and a Windows guru had to come in to figure it out by remote-debugging the windows draw code with no symbols.<p>I learned there that people can make enormous and powerful castles from, well, shit.
评论 #18443313 未加载
评论 #18449083 未加载
评论 #18447752 未加载
评论 #18452008 未加载
评论 #18457454 未加载
评论 #18459494 未加载
评论 #18442881 未加载
boyterover 6 years ago
The worst program I ever worked on was something I was asked to maintain once. It consisted of two parts. The first was a web application writen in ASP. The second portion was essentially Microsoft Reporting Services implemented in 80,000 lines of VB.NET.<p>The first thing I did was chuck it into VS2010 and run some code metrics on it. The results were, 10 or so Methods had 2000+ lines of code. The maintainability index was 0 (number between 0 and 100 where 0 is unmaintainable). The worst function had a cyclomatic complexity of 2700 (the worst I have ever seen on a function before was 750 odd). It was full of nested in-line dynamic SQL all of which referred to tables with 100+ columns, which had helpful names like sdf_324. There were about 5000 stored procedures of which most were 90% similar to other ones with a similar naming scheme. There were no foreign key constraints in the database. Every query including updates, inserts and deletes used NOLOCK (so no data integrity). It all lived in a single 80,000 line file, which crashed VS every time you tried to do a simple edit.<p>I essentially told my boss I would quit over it as there was no way I could support it without other aspects of work suffering. Thankfully it was put in the too hard basket and nobody else had to endure my pain. I ended up peer reviewing the changes the guy made some time later and a single column update touched in the order of 500 lines of code.<p>There was one interesting thing I found with it however, there was so much repeated&#x2F;nested if code in methods you could hold down page down and it would look like the page was moving the other way, similar to how a wheel on TV looks like its spinning the other way.
评论 #18449940 未加载
评论 #18448149 未加载
评论 #18448552 未加载
rollulusover 6 years ago
At my first gig I teamed up with a guy responsible for a gigantic monolith written in Lua. Originally, the project started as a little script running in Nginx. Over the course of several years, it organically grew to epic proportions, by consuming and replacing every piece of software that it interfaced with - including Nginx.<p>There were two ingredients in the recipe for disaster. The first is that Lua comes &quot;batteries excluded&quot;: the standard library is minimalist and the community and set of available packages out there is small. That&#x27;s typically not an issue, as long as one uses Lua in the intended way: small scripts that extend existing programs with custom user logic (e.g. Nginx, Vim, World of Warcraft). The second is that Lua is a dynamic language: it&#x27;s dynamically typed, and practically everything can be overridden, monkey patched and hacked, down to the fundamental iterators that allow you to traverse data structures.<p>This was the playground for the guy to create his own reality.<p>Lacking a serious standard library, he crafted his own. Where a normal world e.g. file rename function would either do the job or return a error to the caller, he chose a different approach. Functions were autonomous highly intelligent pieces of code that tried to resolve every possible problem, entangled with external logic, so grokking the behaviour of the most fundamental things was challenging - let alone understanding fragments of code composed of library calls.<p>Lacking a OO model in Lua, he built his own. I can spend a lot of time describing with what was wrong with it, but it suffices to say that each object had SIX different &#x27;self&#x27; or &#x27;this&#x27; pointers, each with slightly different semantics. And highly entangled with external unrelated logic of course.<p>I&#x27;ll save the stories about the scheduler and time series database he built for another time.
评论 #18449548 未加载
评论 #18449504 未加载
评论 #18449494 未加载
评论 #18486016 未加载
评论 #18453973 未加载
评论 #18449531 未加载
评论 #18486020 未加载
hprotagonistover 6 years ago
Behold, academia.<p>The only maintainers of this code, ever, have been grad students and postdocs. I estimate there have been about 12-15 generations worth. This code has supported hundreds of publications in its lifespan.<p>A codebase that began life in 1987, in C. First ported to matlab in 1999. First source control was added (as SVN) in 2015. Between 2015 and 2018, there were 6 commits total, yet 3 people graduated out of the lab from it. Probably 100,000 loc total, of which I estimate maybe a third is ever used. 1400-line matlab functions are normal-ish. I&#x27;ve found loops nested 11 levels deep.<p>It&#x27;s a series of psychophysical experiments. Each experiment exists in at least 4 different versions side by side in source, each named slightly different, often by incorrect datestamp of last modification. Version control across machines is not well maintained, so you have to diff everything before you can copy or move files lest you accidentally blow something away completely.<p>Oh, and it&#x27;s mexed and wrapped for use on a mac on exactly one snow leopard machine, hardware from 2007.<p>edit: I think this counts as a job, not a student experience, because I am not a student. I just have to clean this mess up once in a while.
评论 #18447620 未加载
评论 #18447404 未加载
madmax108over 6 years ago
A customer-facing dashboard. Yes, a dashboard. How bad can a dashboard be bad you ask? Well, for one, the dashboard had tabs, and each tab was a separate webapp hosted on a separate server. And each team was responsible for developing and maintaining the webapp that their team was incharge of (i.e the User team in charge of Users webapp, Feature1 team incharge of Feature1 webapp).<p>Now add on the fact that different teams had varying levels of frontend competence. This led to some webapps being in (badly written) React, some in Angular, some in JQuery and one in Angular2 as well. Some were java API backed, some were NodeJS backed and one used Ruby in the backend. Oh yeah, and each had different datastores as well.<p>Now alongside this, there&#x27;s no central auth framework, so each webapp had their own way of how to determine user auth (there was a shared cookie thankfully on the *.company.com domain), so there were 6-7 possible login and logout pages as well.<p>When the company had a brand redesign and needed all customer facing stuff to re-align with new design, we had to literally re-design 6 dashboards which have used different paradigms and different tech stacks.<p>To this date, the dashboard still exists and is used by customers (Main dashboard for a company valued at $500M+) and the most common issues are issues related to Auth (eg. random logouts when switching tabs), data inconsistency (They have crons which update data from one DB to another, but it&#x27;s not immediate) and an inconsistent design and UI behaviour (since JS is also different for each app) which pisses off many users.<p>Till date, I&#x27;m not sure who signed off on this pointless dashboard design.
评论 #18448278 未加载
评论 #18447758 未加载
评论 #18447832 未加载
评论 #18448079 未加载
评论 #18447836 未加载
评论 #18458363 未加载
评论 #18458550 未加载
gnulinuxover 6 years ago
We have absolutely no idea how to write code. I always wonder if it&#x27;s like this for other branches of engineering too? I wonder if engineers who designed my elevator or airplane had &quot;ok it&#x27;s very surprising that it&#x27;s working, let&#x27;s not touch this&quot; moments. Or chemical engineers synthesize medicines in way nobody but a rockstar guru understands but everyone changes all the time. I wonder if my cellphone is made by machines designed in early 1990s because nobody was able to figure out what that one cog is doing.<p>Software is a mess. I&#x27;ve seen some freakishly smart people capable of solving very hard problems writing code that literally changes the world at this very moment. But the code itself is, well, a castle of shit. Why? Is it because our tools (programming languages, compilers etc) are still stone age technology? Is it because software is inherently a harder problem than say machines or chemical processes for the human brain? Is it because software engineers are less educated than other engineers? .....?
评论 #18448587 未加载
评论 #18447476 未加载
评论 #18443674 未加载
评论 #18444561 未加载
评论 #18449192 未加载
评论 #18447508 未加载
评论 #18448623 未加载
评论 #18447390 未加载
评论 #18449247 未加载
评论 #18448668 未加载
评论 #18450169 未加载
评论 #18444196 未加载
评论 #18443500 未加载
评论 #18454124 未加载
评论 #18450521 未加载
评论 #18448591 未加载
评论 #18449568 未加载
评论 #18447457 未加载
mb_72over 6 years ago
At one stage a company I worked for was considering licensing the code for a school time-tabling application, rather than paying the company to do the (fairly minor) changes we required to meet (non-USA) state requirements. The company was started by a couple of teachers, the same people who wrote their product. It was 10s of ks of Pascal code, but with not a single variable name or function name that made any sense; everything was A, AA, AA1, X, XX, XX2 etc. I spent a few days looking at it, then recommended we keep paying the somewhat steep cost for the modifications. Then at least if anything broke it was on them to fix it.<p>Incidentally we had a small falling out with this company, and they were refusing to update their executable until this issue was resolved. This looked like affecting some hundreds of schools and their timetables. I did some checking, and it turned out their &#x27;non-updated&#x27; executable was doing a simple date check on the local PC; if it was past a certain date, the executable refused to run. So I did a quick hack in our application that involved: - setting the local PC date to prior to the &#x27;cutoff date&#x27; - running their executable with the required parameters, and grabbing the results - setting the local PC date back correctly<p>This led to interesting negotiations as they were puzzled why their &#x27;gun to our heads&#x27; no longer appeared to be working, and things were resolved to the benefits of both parties soon after.
评论 #18458333 未加载
LanceHover 6 years ago
I took over a Perl project where every SQL call was an exec to a java program which would make the query.<p>The largest madness was a J2EE mess where persistence was achieved by taking your current object, sending a message bean to the server, it would touch the database and return the result which was being polled for (making it synchronous). The amazing thing is that the client and the server were the same J2EE instance. So Class A could have just called Class B. Instead it was A -&gt; turn it into a message bean -&gt; send it to the &quot;server&quot; (same machine) -&gt; unwrap it into A again -&gt; transform it into B -&gt; message bean it back to client -&gt; unwrap into B.<p>Literally three months of 8 people ripping all of that out and replacing it with A.transform() &#x2F;&#x2F; returns B<p>Oh, and at the same time, none of this was in source control. It was being worked on by 12 people up until that point. They didn&#x27;t know who had the current files which were in production. So my first job was taking everyone&#x27;s files and seeing which ones would compile into the classes being used in production, then checking those into source control. Up until then, they just kept mental track of who is working on which files.
评论 #18448554 未加载
评论 #18449358 未加载
评论 #18455168 未加载
评论 #18464580 未加载
mattzitoover 6 years ago
My first job was sysadmin of a third tier ISP back in the dialup days. The account management and provisioning system that ran EVERYTHING was probably close to 100k lines of csh. Everything was done via a UI that the shell generated as a sort of curses-style interface.<p>What was horrible about it was that it controlled everything from who got a website, active domains, what POPs users could dial into, metered billing, you name it. And it did all of this by manipulating flat files of pipe-delimited data on a central server, then rcp’ing those files to the various machines, then rsh’ing to the various machines and kicking off THEIR scripts, which parsed the source files and generated their own files, which called another set of scripts that parsed THOSE files and generated the software config files.<p>This included doing things like updating init scripts so that new IPs got added to interfaces, and what email server a user was provisioned on, so it had to generate new exim configr with routing rules.<p>All this to say that it all worked, but I dreaded having to go in to manipulate anything. Adding a server at least had a dedicated procedure so that was fine, but anything else was a nightmare.<p>Case in point - as part of a gradual plan to remove this nightmare, I swapped out the radius server that they were using for one that could support a database backend, and modified the local config generator script to make a new config for the new software as a stopgap until I could get it into a database.<p>The config file had a series of fields that just had numbers in them, and after much digging, it seemed like that controlled whether a terminal dial in user was presented with a menu of options, and what options. I had to reimplement that logic for the new software, made a mistake, and accidentally removed the option for UUCP for the 10 customers that were still using UUCP. One of them was on an ISDN line and their mailer decided to continuously redial looking for the UUCP, tacking up thousands of dollars in carrier rate charges for the weekend that it took anyone to notice something was broken.
评论 #18447618 未加载
评论 #18443427 未加载
评论 #18447460 未加载
Rebelgeckoover 6 years ago
The project around 10 million lines of code. Some of it was written in a very specific version of Fortran that was a PITA to compile. One fun experience was opening a file and seeing it was created on my birthday. Not in the sense just matching the day and month of my birtdhay. The code was literally written on the day I was born.
评论 #18447551 未加载
评论 #18448325 未加载
pengoover 6 years ago
Ten years ago I was called in to remediate a new web application which had been subcontracted to an Indian development company. The PHP developers who&#x27;d put it together evidently didn&#x27;t know about classes, and each page in the application was hundreds, sometimes thousands, of lines of spaghetti code, most containing the same duplicated (but subtly changed) blocks providing database connectivity etc. Security had not been a concern either; passwords and credit card details were stored unencrypted in database text fields.<p>I was called in because, while most of the application worked, some of the requested features were not yet complete. When I made my initial recommendation (scrap the whole thing and start again) I was told the client&#x27;s board would not agree to that because of the money already invested and the fact that the board had seen a demonstration proving that &quot;most of it worked&quot;.<p>It took two developers eighteen months to beat this sorry mess into a maintainable state while ensuring it remained &quot;usable&quot;. It would have taken one third of that time to rewrite it from scratch.
评论 #18447368 未加载
评论 #18448919 未加载
评论 #18449898 未加载
评论 #18447375 未加载
评论 #18448190 未加载
dustinmoorenetover 6 years ago
I use to work on hospital lab software.<p>* It was over 20 years old by the time I started<p>* It was written in Fortran<p>* Variable names were single and double digits<p>* Each fortran program would run in isolation but had a shared memory process<p>* It was formally a terminal program but a weird Java frontend was created so everything looked like Windows GUI<p>* All program names were four letter acronyms<p>* All data was stored in fixed width binary &quot;flat&quot; files<p>* It previously was under CVS version control, but each install slowly drifted apart, so each site had it own unique features and bugs.<p>* I once had to move a significant feature from one install to another using only patch files generated from the work done on the original install.
ohthehugemanateover 6 years ago
The worst for me was a rescue project: a site for a US tech sector Public-private partnership. Nothing too complicated: recurring donations, paid events, a small members area. They had sent it to an Indian firm to build in Drupal 7 - not a lightweight system to begin with.<p>I would like to say &quot;cue the stereotypes for Indian developers&quot; and we could all have a good laugh. But no. This is more like Heart of Darkness. They must have traveled to the darkest corners of the subcontinent to find a mind capable of the eldritch horrors we found there. We started keeping a wiki of design patterns, to save us WTF time. Here are a few.<p>* Memory management. What&#x27;s that? This site required 16 GIGABYTES as a PHP memory limit in order to load the front page for an anonymous user.<p>* Security. What&#x27;s that? Part of the reason it required so much memory, is that it would include a complete debug log of the site&#x27;s entire transaction history, including PII and credit card numbers, in every session. Meaning any vulnerability was a critical vulnerability.<p>* They would arbitrarily include the entirety of Zend framework to access a single simple function. This happened several places in the codebase, with different versions of Zend committed.<p>* Can&#x27;t reach the ERP to get the price for an event? Let&#x27;s set it to $999,999.00 and proceed with the transaction.<p>* Invoice numbers were random numbers between 1-1000. Clashing numbers meant a fatal exception that would fail to store the invoice or payment record... But not until after payment had been processed. Birthday paradox means this happened a lot.<p>* The developers used arcane bits of Drupal API to do totally mundane things. Like, if you know about hook_page_alter, you know there&#x27;s a setting in the UI for the frontpage. But we&#x27;ll just use hook_page_alter instead.<p>* Write queries using Drupal Views, rewrite the query in code, override the views query with their custom (identical) version using an unusual API hook, just to add a sort.<p>I could go on, but I think you get the picture. Eldritch horror of a codebase.
评论 #18457936 未加载
lucozadeover 6 years ago
I used to own a C++ application that was a morass of abstractions and indirections so it was impossible to reason about. It took a number of hours to compile.<p>On one infamous occasion we were making a, relatively small, patch release. The debug version worked fine but the release version crashed systematically. Even when we backed out <i>all</i> the changes we had the same behaviour. We were screwed.<p>Until one of the team had a bright idea. She stripped strings from the debug build and tested it. To our surprise it not only worked, it was only slightly bigger than the previous release version and it was also slightly faster! We shipped.<p>This experience was the trigger to make me go all-in on a full re-write that I had been contemplating. One of only a couple of times in my career that I&#x27;ve made that decision on a major piece of software.<p>The re-write was a huge success. It was also about 10% of the original in terms of LoC. The day our testing finished, we held a ceremony where we deleted all the old code from the current version.<p>This caused a slightly different issue. At the time, code metrics were starting to get fashionable but LoC wasn&#x27;t yet the pariah it became.<p>So, a couple of days later I got a concerned call from the metrics guys. Apparently, we had deleted more code than all the other teams combined had added in the previous measurement period. This caused their metric calculation to barf. Their solution? We should add all the code back in! This led to a somewhat heated argument that ended up with me persuading them that deleting code was good and they should, at least, abs(LoC) it. It didn&#x27;t make the metrics any more useful but meant that we had an application we could reason about. Happy days.
评论 #18449094 未加载
zhengyi13over 6 years ago
From 10+ years ago when I worked at PayPay, webscr (the frontend at the time, where you&#x27;d log in) was a total of 2GB of C++ that would get compiled into a 1GB CGI executable, deployed over some ~700+ web servers.<p>Debug versions would never get compiled, as I&#x27;m told the resulting file was too large for the filesystem to handle.<p>Apparently a great deal of the code was actually inline XML.<p>They <i>knew</i> this was a bad pile of technical debt, too: at one point, a senior&#x2F;staff engineer gave a company presentation where they brought a fanfold printout of the main header file for this monstrosity, and literally unrolled it across the entire stage.
评论 #18443330 未加载
评论 #18443337 未加载
thepp1983over 6 years ago
I&#x27;ve worked on a CMS that was partially done in .NET, Iron Python and used an XSLT templating system to generate HTML for the front end.<p>The architecture looked like something from the Early Java days.<p>The system used Iron Python &#x2F; C# in the following way.<p>1. A web request would hit the CMS 2. There was a massive switch statement to work out how the query would be rewritten 3. If it the url was prefixed with processor it would attempt to find the processor in the db. 4. The code would then find the python script associated with the processor. 5. The processor would then spin up a command line instance in a hidden command window on windows server. 6. The processor would have to return XML that had to be built up using strings (not element tree for you). 7. This would return the XML to the C# which would then try to render into the XSL Transform.<p>If at any time this failed. Silent failure. There was no way to debug easily (There was a magic set of flags that had to be set in Visual Studio or wise you couldn&#x27;t debug the python scripts).<p>To get the software to build on a new machine. It took a contract 4 months to reverse engineer an XP machine. None of it was documented anywhere.<p>It used ImageMagick to generate thumbnails on the fly which doesn&#x27;t work to well with windows server.<p>The lead engineer was an alcoholic. He used to go to the local pub for 4 hours in the middle of the day and come back smelling like a brewery.
评论 #18448173 未加载
评论 #18447424 未加载
TheRealDunkirkover 6 years ago
I wanted to tackle a rewrite of a legacy LISP program, used by AutoCAD, to take in a list of 3D coordinate points, and output a DWG of a 2D projection (from which to create a jig on which to assemble a prototype). Cool stuff, right? My intent was to create a &quot;proper&quot; script in AutoCAD to actually create 3D objects from the input data, and let the program do the projection to a 2D drawing. (I&#x27;m still not sure if that would have been possible; I never got that far.)<p>I had never written in LISP before, so I bought a book!<p>I was having trouble reading the program on the computer, so I printed out the roughly 15,000 lines. Not a lot, I know, but it was about an inch and a half thick stack of paper. I started going through it.<p>It consisted of LOTS of subroutines. Thousands. Each one neatly formed; no more than a couple hundred lines. It gave me hope.<p>It read in the text file, created a blob of a string, and then passed that blob to the first subroutine. Then it passed to the next subroutine. And then the next, and so on. As far as I could tell, it never called a subroutine a second time, and it never returned to the starting method. Given the strangeness of LISP, I couldn&#x27;t figure out what it was doing, or why.<p>The guy who wrote it had retired, and we didn&#x27;t get along anyway, so I didn&#x27;t try to chase down what his thinking was.<p>I gave up.<p>To my knowledge, they&#x27;re still using that program 17 years later.
le-markover 6 years ago
Bad is not a good measure. But taking &#x27;bad&#x27; to mean large, convoluted, zero documentation; I was once at a financial services company that had a 25 million+ LOC mainframe cobol application that had been under active development since 1969. This was a batch and CICs system. It was spaghetti on every level; database (db2, vsam, isam), the screens of the app, the batch jobs, the cobol. It was truly astounding. It was also the source of about $500 million in revenue. They were doing software as a service in the 1970&#x27;s. It&#x27;s still going today. Customers in that space don&#x27;t have many options.
评论 #18447365 未加载
评论 #18444979 未加载
评论 #18447356 未加载
Softlyover 6 years ago
In my first year of university, I wrote a Java swing game which had classes for literally every part of the GUI (I was young, carefree and unwilling to yield on the principals of OO I&#x27;d been taught earlier in the year. I think it had somewhere in the region of 100 classes. Of which only about 3 had the real logic in them.<p>Now I&#x27;ve put it in perspective, I went on to an intern position between years 2 and 3 of uni. I was handed a <i>lovely</i> piece of code which had:<p>- Around 300 classes - 3 or 4 layers of nested generics - Factories, factory factories, generator factory factories - 90% of the parameters were passed in from the build engine running the code, so it was impossible to run locally, ever. - 0 tests - Some 100 pages of documentation, which had been lost until I was about halfway through my placement (and mostly documented how to set up and run it, not how to maintain it)<p>Seriously, this thing was designed to the extreme, made to be generic to every single scenario in existence.<p>So what did it do? It took items from a customer facing system, transferred it onto the internal work tracking system. Then when they were updated in the modern system, mirrored the relevant updates back to the legacy.<p>The best part? Every time the internal work tracking system updated (once every 6 months), this thing broke horribly and it was practically impossible to fix. Even if you managed to set up stuff so you could work in a development environment, it still connected to the customer facing system, so you had to be incredibly careful what you did during testing.<p>It wasn&#x27;t the biggest in terms of LOC, but it astounded me just how much effort (apparently the guy who wrote it squirreled away for a year to write it, then moved to Canada, and was famous in the department for having one too many beers during a outing to a local Indian) went into designing this behemoth.<p>I still have the occasional nightmare about it!
Rjevskiover 6 years ago
I once had to look at a client’s code to determine if&#x2F;how we’d go about taking over their application. Their only developer threatened to quit and this is when they realised it would be best to outsource this and reduce the bus factor.<p>It was a huge <i>folder</i> (not repo - and there were zip files of different “versions” of the code in there). The main monster was a huge Visual Studio solution with hundreds of targets, one would be an application for entering some data, the other was for entering data from a hardware device (a scale if I remember right), etc.<p>The main source of truth was an MSSQL database to which all these apps would connect <i>as root</i>. There is no backend as such to ensure access control &amp; consistency, and any misbehaving app could essentially trash the entire DB.<p>Database credentials were hardcoded in every app’s main entrypoint, with earlier “versions” of the credentials commented out below.<p>I thought that surely these must be either staging DBs or at the very least there would be network-level access control meaning the DB wasn’t accessible from outside... but no - I managed to connect to their production DB <i>as root</i> from a random, untrusted location. I do not know if MSSQL uses encryption by default but I would bet good money there was none and they were essentially connecting to their DB as root, over plaintext, from hundreds of different locations across the country without any kind of VPN.<p>In terms of code you obviously have your standard &amp; expected “spaghetti monster” with UI &amp; business logic scattered everywhere. What struck me the most was an <i>empty</i> exception handler around the main entrypoint.<p>In the same folder there was also source for an iOS app. Didn’t look at it but I don’t see <i>any</i> valid reason why this should be in the same place as the Windows apps.<p>Thankfully I no longer work there and even if I were I had no major C# experience (which gives me a very convenient excuse not to touch this mess).
评论 #18453701 未加载
评论 #18448248 未加载
8fingerlouieover 6 years ago
I worked for a company that makes sortation devices (conveyors etc), and i inherited an old product from a previous colleague.<p>The software was largely a standard base with modifications done for the individual customer to suit their business needs.<p>In this particular project, it was a batch sortation, meaning we received a large batch file from their mainframe, which would then be parsed and executed by the controller software.<p>Everybody feared this particular project, and estimates on new functionality were sky high, but I didn&#x27;t think much of it until i had to modify the batch parsing code. I was met with 22000 lines of C code in a single function. This single function was modified multiple times each year, usually adding more code in the process.<p>It took me the better part of a month to refactor into &quot;manageable&quot; chunk sizes, and in the end i was left with a 1700 LOC function that was still &quot;too big&quot;, but nobody really understood how it worked, and we couldn&#x27;t test it, so i just left it at that.<p>After my refactor could implement new functionality somewhat faster, but in the end it was still a very complex algorithm, so despite being in smaller functions, you still had to be very careful when modifying it.
badjobthrowawayover 6 years ago
(I am a regular of HN. I don&#x27;t want this attributed to my acct.)<p>Previous job. Was sysad. This code runs most of the academic US internet.<p>Everything was Perl5. There were over 150 different major applications written with it, ranging from 40 lines to 500k lines. The older the recent commit, the worse. Touching any of this would cause errors, either in itself OR in associated applications! You&#x27;d be working on thing A, get it working well, and 4 weeks later thing B would fail horrendously.<p>The worst was a tie between a variable that was a 6 line long SQL query, which was packed to the brim with function calls that ended up expanding a query to something like 50 lines long.<p>The tie was a gem in code that wasn&#x27;t touched for 7 years. This wasn&#x27;t at the top, or even in a config file. It was hardcoded in the middle of the perl5 program...<p><pre><code> $db_server = (servername); $db_user = root; $db_password = (password); </code></pre> Other dishonorable mentions are as follows:<p>1. No primary keys for the main database....<p>2. Goober had the idea of storing pictures in said MySQL database. 70 GB of pics...<p>3. Redhat 4 still in production, along with RH 5.<p>4. Its everyone for themselves. The goal is you hobble it along enough for the next oncall. Let them get hit with it.<p>5. Running iron from 10 years ago. Contracts pull in $$$, but you&#x27;re dealing with paleo-datacenter crap<p>6. Just retired LTO3 tapes. Now they have &quot;shiny&quot; LTO5....
评论 #18451089 未加载
评论 #18456617 未加载
binalpatelover 6 years ago
At a former employer someone created a framework to try and create a generic process to process and load data (i.e. ETL). It was written with the best of intentions, but was terrible.<p>This framework was given to an offshore team, and they were told to use it to farm out hundreds of requests. The framework was inflexible enough that they each started adding snippets here and there to make it work for those projects, with no code review.<p>When I joined there were well over a hundred different projects, all using this framework at the core, most having little bespoke tweaks to make the code work. Every failure was essentially a new failure in a new way.<p>It was a useful experience - it&#x27;s one of those experiences that teaches me via a negative example. This was the worst example of how &quot;roll your own&quot; resulted in incredible technical debt I&#x27;ve seen.
评论 #18448107 未加载
andaiover 6 years ago
My own! For a university assignment we had to make a simple Excel clone as a group.<p>We divided the work and I ended up working on the formula parser. I spent a week thinking about it and couldn&#x27;t figure it out (I wanted to work it out from scratch). Eventually I had a flash of insight: I know how to parse simple formulas, so I can use string replacement to recursively rewrite a formula until I can parse it.<p>By the time I had written all of it, I didn&#x27;t understand how it worked anymore, but it did work!<p>FormulaParser ended up being longer than the rest of the codebase combined, and I eventually learned the other groups did it with a regex and ~50 LoC...
jacquesmover 6 years ago
Most large enterprise systems that are more than a few years old tend to be pretty bad, and almost all of them work just fine, as long as you respect the &#x27;dragons be here&#x27; signs and you don&#x27;t attempt to fix that which isn&#x27;t broken.<p>Millions of lines of code (or even 10&#x27;s of millions of lines) are really not all that exceptional. The original programmers are typically in some home or are pushing up the daisies.
letientai299over 6 years ago
I came here was about to complain about some projects of my previous companies. But reading this thread makes me feel ashamed for getting angry with them, compare to how much more pain you guys went through.<p>Thanks for all the sharing. Young devs (like me) should really read and appreciate this thread.
logfromblammoover 6 years ago
My previous job. More than a million lines of code for a glorified CRUD app, with more than a $7 million annual budget.<p>Accruing technical debt was a process feature. More bad code that everyone is afraid to touch means more budget for terrified developers and testers, and insane networked database design means more budget for servers and sysops. The fear leads to meetings, the meetings lead to suffering, and suffering leads to the dark side. It still works according to spec, and is human-fixed quickly whenever it doesn&#x27;t, but the poor quality of the codebase is likely costing at least $2 million per year.
评论 #18443905 未加载
farhanhubbleover 6 years ago
More than a million lines with a single file containing more than 100,000 lines of spaghetti code consisting of macros and badly indented C code in a single function! This powered the GUI for an entire generation of low cost phones (pre Android era).
评论 #18444349 未加载
overcastover 6 years ago
I&#x27;m guessing by bad, you mean ugly. I&#x27;m fairly convinced there is no &quot;good&quot; code, or that it&#x27;s such a minuscule subset that you&#x27;ll never likely encounter it in your career. Every year I look back on last years stuff I&#x27;ve written, and I can find ten ways to clean things up.<p>In my opinion, if it works, and provides the utility it was designed to bring, then it doesn&#x27;t matter. If it makes money, then who really cares!
评论 #18442934 未加载
评论 #18443238 未加载
评论 #18447518 未加载
评论 #18449406 未加载
itsreallymeover 6 years ago
300,000 lines of Python…<p>The company had bought Ellington, a Django based CMS, but the team basically rewrote the entire thing using multi table inheritance (unintentionally), so everything in the database had two copies, and we had over 70 tables, hundreds of gigabytes, disasters every week and tons of bugs... I discovered this more than a year later and nobody was even aware. Even the DBA wasn’t aware the tables were duplicates.
dfinningerover 6 years ago
Not the largest, but the most insane.<p>At an old employer there were 15,000 lines of batch script across 14 .bat files on a Windows laptop. Old director of IT used it to onboard new customers. It basically copied a DB and turned &quot;CHANGE ME&quot; in some columns to the client&#x27;s name.<p>It had it all. 5k lines of date validation, 3k lines of &quot;UI&quot;, 400 goto statements, hard-coded passwords, versioning by incrementing the file names (leading to a bunch of code that was never called), and to top it off a static IP granted to the laptop that used as a part of authentication.<p>Took me two weeks to unravel it and replace with ~20 lines of Ruby.<p>Later, all of my complaining on Facebook led an old professor to invite me back to give a talk on the importance of code quality!
neyaover 6 years ago
A while ago, I was tasked with maintaining production code written in R by an enthusiastic junior developer. He loved R so much that it blinded his ability to use the right tool for the job.<p>Instead, he wrote web applications in R, instead of Python or Ruby, which my company had many developers who had expertise in, and eventually handed it over to to me. He even persuaded our bosses to invest into R Studio Server and had an instance installed in one of our machines. It&#x27;s not only the choice of the programming language that made me furious, it&#x27;s also the quality of code. He also mixed up snake case and camel cased variables all over the code. In addition, the same name would refer to different things, eg. `abc` and `Abc` and `a_bc` would mean totally different things. And stuff that could be written in a simple Sinatra or Flask application were written in R Shiny.<p>As a non-R person, I quickly learnt the language, (while mentally cursing it all the way for the bad choices it had made and the terrible inexplicable syntax it had) but getting used to this bad code was quite a challenge. We had several top tier clients whose reports were critical and reliant on this R code and it would frequently, randomly fail while maxing out on memory, no matter how much you threw at it. Debugging was another issue and I struggled with this codebase for 8 months while this junior developer had moved on to other technologies.<p>Eventually, my main role <i>almost</i> switched to devops which I hated, because I enjoyed writing web applications and good code that doesn&#x27;t require maintenance nor devops much. Eventually, I realized I couldn&#x27;t take responsibility for this anymore as it would cost me my reputation and I really didn&#x27;t like the way the company handled the situation as well. They were quite supportive of the junior dev encouraging him to move on to newer technologies while he half-assed everything and threw it on other people&#x27;s heads who already had other responsibilities. They did this so that they could show off at meetups &quot;We use the latest tech stack..blah blah&quot; while adding 0 value for clients.<p>So, I quit the company, along with a dozen others and never looked back. But, I did learn quite a lot..my my.
评论 #18452801 未加载
pmarreckover 6 years ago
Here&#x27;s a metaquestion:<p>Is it possible for <i>any</i> codebase to <i>NOT</i> eventually (given enough time) become a crufty pile of garbage?<p>I suspect (but have no real evidence... yet) that SOME of this spaghetti garbage is due to the traits of procedural, OOP, mutable languages. But this would then imply that things like functional-language codebases have much longer lifespans... and I don&#x27;t have evidence for that... but I&#x27;m hoping someone can chime in
评论 #18447716 未加载
评论 #18447485 未加载
评论 #18448842 未加载
评论 #18447479 未加载
评论 #18447733 未加载
评论 #18448749 未加载
评论 #18451407 未加载
apiover 6 years ago
The worst I&#x27;ve personally seen was a many tens of millions of lines C++ Qt GUI app. Won&#x27;t mention the name to protect the guilty but it&#x27;s something some people here might recognize.<p>It didn&#x27;t really need to be that big. A lot of its size was a result of pathological over-engineering. Apparently a previous (of course) engineer who built much of the original app thought boost::bind and functional binding was awesome. He also absolutely loved template meta-programming.<p>The code base was full of templates that contained templates that contained templates that contained... layers upon layers upon layers of templates, generics, bind, and so on. The horror. The compile times were awesome too. Local builds on an 8-core machine took 15-20 minutes.<p>I once made a commit to that code base where I replaced two entire subdirectories of files and tens of thousands of lines of code with one function. It took me weeks to understand and then finally to realize that <i>none of it was necessary at all</i>. It was all over-engineering. The function contained a case statement that did the job of layers of boost::bind and other cruft.<p>I definitely had a net negative line count at that job. The experience helped to solidify my loathing of unnecessary complexity.<p>It also made me respect languages like Go that purposely do not give the programmer tools like complex templating systems, dynamic language syntax, etc. It&#x27;s not that these features have no uses, but honestly their uses are few. I&#x27;ve used Go for a while now and have found maybe two instances in tens of thousands of lines where I missed generics. I imagine I&#x27;d miss operator overloading in heavy math code, but that&#x27;s about it. The problem is that these features are dangerous in the hands of &quot;insufficiently lazy&quot; programmers that love to over-engineer. I&#x27;d rather not have them and have to kludge just a little than to deal with code bases like the one I described above ever again.
gargravarrover 6 years ago
I never actually saw the code that makes this work (thank Christ) but at the previous place I worked, we did everything in SQL. Believing SQL Agent to be &#x27;too limited&#x27;, my boss had taken it upon himself to reimplement it... in SQL...<p>Just let that sink in for a moment.<p>There were 20+ tables all modelled after how SQL Agent does its own scheduling, 30+ stored procedures for interacting with it, and it was all intended for use with a GUI that was (naturally) never written. A relationship diagram of the tables sat on my personal Wall of Shame board for most of the time I was there. And yes, I had to use it from time to time. It was installed in every database for 200+ clients, in production, UAT, development, you name it.<p>The most delicious irony is, the only way such a thing could run automatically... was to use a SQL Agent job to poll it once a minute.
评论 #18449126 未加载
poulsbohemianover 6 years ago
As many experienced commenters below have already noted, nearly any piece of substantial, revenue-generating, long-lived code will ascend to a place full of dragons and mysticism. The more interesting debates revolve around:<p>1) How did it get that way, and what can we learn from that? 2) Is it inevitable that all software will end up like that? 3) How can an organization ever successfully sunset or move to a more maintainable system? Or should they even aspire to that?
评论 #18448206 未加载
评论 #18443939 未加载
评论 #18447221 未加载
bogdanuover 6 years ago
My worst experience was with a PHP app (no framework), 60K LOC per file, 6 dimension arrays, variables and comments in 3 different languages, elseif statements spread over 2-3k LOC, no kind of separation of concerns (HTML mixed with php, db calls, etc).<p>It was a 3 months nightmare with an arrogant as fudge client&#x2F;developer.
bayindirhover 6 years ago
I have seen a complete project. The project was maintained by one person. Former developer left and transferred his work to the next.<p>It was a C project, but the second developer was coming from a Java background. So his half is all written with Java notation and naming conventions.<p>The thing was maths-heavy and had no comments. Instead they were consulting to a documentation book which also had file names and approximated line numbers.<p>The error tracing was done with function call stacks, so every function pushed some data into a global stack before a critical operation and, popped the same data if everything went without any problems.<p>Some libraries they were using were ad-hoc patched to taste, and grafted into the code tree. So, debugging was 5x harder and longer.<p>The functions were not divided into headers in a logical way, they were ad-hoc. So finding something was dependent on an source indexer or a grep sprint.<p>Last but not the least, the developer was so arrogant that the bugs were resolved by threatening to force him to clone his code and sent it out to another developer to debug and clean. Otherwise he pretended that the bugs were not present, because it was running on his test bed.<p>... and yes. It was in production.
bungie4over 6 years ago
A nested if statement approximately 75 levels deep all because the author didn&#x27;t understand that an ID can be unique. So he manually checked the value (which meant it could never be changed without a code change).<p>He did&#x27;t understand the concept of a join. So he&#x27;d nest queries in VBScript with join key supplied from the outer query to the inner. Row by row. Essentially, a manual cursor.<p>Same programmer wrote an ASP portal app. The login of which got most of its security because they didn&#x27;t know how to iterate over a returned dataset. Same code would set a cookie for access IN THE PRESENCE of a password. It could be wrong, you would still get access. Worse, the logout function didn&#x27;t delete the access cookie, it just redirected you to the login page. Meaning you could impersonate anybody if knew thier username. Included admin.<p>I once corrected bug, by using a view. I sent him the view. He had no concept what a view was &quot;That&#x27;s like a stored procedure right?&#x27;. I&#x27;m shocked he knew what a stored procedure was.<p>He&#x27;s still in business and the software is deployed worldwide. He refuses to fix it. He&#x27;s a multi-millionaire.
mixmastamykover 6 years ago
Worked on a file-sync system written in Python 2.6&#x2F;7 by B-players in a hurry.<p>Lots of microservices, before it was cool, that was fine. Shitty code everywhere, commented code, dead code, 5 blank lines here and there. Many lines over 100 chars, lots pushing 150 or 200+. Didn&#x27;t understand how to use argparse or logging but tried. Crazy mixed-case WTFExtremelyLongSillyNamesEverwhereSendThis at the command-line interface, instead of verbs like send.<p>Had a custom ORM that didn&#x27;t want to look like one and took 5 times the code to do similar things. Little handling of exceptions, things like wrong permissions or IO like tar file creation might cause a 6 hour job to crash.<p>Daemons couldn&#x27;t be shutdown gracefully, had to tail their logs until they paused for a moment, cross fingers, and kill process, often kill -9. Old daemontools made it more difficult. Bad timing could mean you are in for 3 to 6 hours of manual job cleanup work. Would happen a few times a week anyway, cutting into dev time. Still you could count on it to work about 90% of the time.<p>Token test suite and docs. Embarrassing web interface that would look amateurish in the 90&#x27;s. Original developer made us do a standup everyday at 10:30am just when getting into the zone. They felt worthless for a while, and then it dawned on me why, we were all working on different projects.<p>The punchline: spent three months of 60 hour weeks taking out the trash, writing tests, paying down debt. Spent the next month or two with another dev designing&#x2F;writing a vastly improved V2 with graceful shutdown, Django-style ORM, and quality as headline features.<p>A few weeks before we&#x27;re about to knock it out of the park and deliver, the old author of V1 comes back in a panic, says we need to finish at end of month as a huge project is finishing. Doesn&#x27;t seem to make sense, big changes at end are a bad idea. Takes over control of project, designs&#x2F;implements V1.1, pushing aside our improvements and whips it up in a few weeks while I sit there with nothing to do. 6 months work of 60 hour weeks flushed down toilet.<p>After picking jaw off floor and offering a few choice words I left the job by mutual agreement a few weeks later and didn&#x27;t look back. Good times.
评论 #18447811 未加载
walrus01over 6 years ago
Not exactly code but people would be scared if they found out how much of the Internet, at OSI layers 1, 2 and 3, is held together by the metaphorical equivalent of duct tape and twine. At OSI layer 1, sometimes almost literally. Major ISP outages that have been caused by somebody tripping over the $5 power strip that was powering the authoritative nameserver.
评论 #18447869 未加载
mikekcharover 6 years ago
I worked on the DMS switch in Nortel (if PRI broke for you, I&#x27;m sorry, I tried my best!). 31 millions lines of absolutely horrific code. You&#x27;d think <i>somewhere</i> in that mess there would be some redeeming code, but if there was I never found it.<p>To give you some examples, I originally came on as a contractor because they had some refactoring they wanted done. The entire system was home built (including the programming language) and there was a file size limit of 32,767 lines. They had many <i>functions</i> that were approaching this limit and they didn&#x27;t know what to do, so they hired me. Probably you can imagine what I did.<p>One time I went to a code review. They were writing a lot of data into some pointers. I asked, &quot;Where do you allocate the memory&quot;? The response was, &quot;We don&#x27;t have to allocate memory. We ran it in the lab and it didn&#x27;t crash, proving that allocating memory is a waste of time&quot;. No matter how much I tried reasoning with them, I couldn&#x27;t convince them. The code shipped like that.<p>One of my more amusing anecdotes is that when I worked there the release life cycle was <i>five years long</i>. The developers would work on features for 3 years. The developers were responsible for testing that their own code worked. There was no QA. After 3 years, we would ship the code to the telcos (telephone companies) and they would test it for acceptance for 2 years. We would fix the bugs that they found.<p>I started working there at the end of a release cycle, so people were only fixing bugs. I got an interesting bug in that I couldn&#x27;t find any code that implemented the feature. The feature had apparently been implemented at the beginning of the cycle (so around 4 years before), by someone who was now my C level manager. I started looking at the other features that person had implemented. There was no code. It seems that this enterprising person had started work and realised that nobody would check his code for 3 whole years. He just checked off all his work as done without actually doing anything. Since he was an order of magnitude faster than everybody else, he was instantly promoted into management. When I reported my findings to my manager, he made it clear I wasn&#x27;t to tell anybody else ;-)<p>Such a messed up place. <i>But</i> the switch worked! It had an audit process that went around in the background fixing up the state of all the processes that ended up in weird states. In fact, when I worked there, nobody I worked with knew how to programmatically hang up a call. If you were using a feature like 3 way call, etc, they would just leave one side up. Within 3 minutes, the audit process would come by and hang up the phone. Tones features &quot;worked&quot; that way -- by putting the call into weird states and waiting for the audit process to put it back again. You could often hang up after a 3 way call, pick up the phone and still be connected to the call.<p>Most people don&#x27;t know it, but because of some strangeness with some of the protocols, telcos used to &quot;ring&quot; their main switches with Nortel DMS switches. This would essentially fix the protocols so that everything could talk to everything. So, if you ever made a long distance telephone call 20 or 30 years ago, it almost certainly went through a DMS switch. The damn thing worked. Somehow. I have no idea how, though ;-)
评论 #18447366 未加载
评论 #18452010 未加载
stabblesover 6 years ago
Nobody mentioned Wordpress yet? Last time I checked it was a terrible pile of procedural code
评论 #18448157 未加载
agentultraover 6 years ago
A web application written in C++ before there was the STL or many libraries written for C++... in 2007 or so. It was probably 200k LOC or so of CGI application code, libraries to render PDFs, manage a filesystem of XML files, an XML parser... none of it documented or tested.<p>The developer who was leaving the company dropped a copy of Michael Feathers&#x27; <i>Working Effectively with Legacy Code</i>. There was a small amount of Python to wrap the API to the C++ code using Boost against which a small suite of unit and functional tests were being developed. I learned a lot on that project.<p>I never fully understood how the C++ code all worked but having that API interface in Python helped to grok parts of it (and eventually replace it with a few hundred lines of Python code at a time).
billwearover 6 years ago
Actually, if you want to see clean code that works well, try the traditional ex&#x2F;vi source. It&#x27;s something like 20K lines, but very neat functional programming all the way down.
评论 #18444833 未加载
pacoWebConsultover 6 years ago
12k line code-behind for an ASP.NET page that duplicates PDF files, driven off of a spreadsheet, and adds some additional information at the top of each page. This has generated the majority of a major state&#x27;s ballots for at least the past 4 elections.
andyhasitover 6 years ago
I might have a slightly different record, if you count lines in a single source file...<p>One client wanted to hire me to continue developing his AutoCAD plugin written in AutoLisp (a cut down version of lisp for writing macros in AutoCAD). He had all his code in a single file which was around 63,000 lines long. (I calculated this as 504 meters of screen&#x2F;paper top to bottom).<p>This was for a product that was in production, used commercially, and he&#x27;d been going for 15 years, adding bits as he went. There were loops hitting 300 lines, well over a hundred global variables, no consistency, and duplication like you wouldn&#x27;t believe because he hadn&#x27;t grasped the idea of moving code out to reusable subroutines.<p>I asked him what he did when his clients found a bug. The answer was &quot;knuckle down for a few weeks&quot;.<p>I just couldn&#x27;t believe that this was his daily work for 15 years, and he never thought to learn anything about programming other than what was immediately required to solve the problem in front of him...<p>Another unbelievable part of this, is that AutoCAD has an absolutely superb IDE built into it (i.e. it&#x27;s fricking free!) which has features like the ability select &amp; run code in current scope with minimal clicks which make for the fastest development environment I have ever played with, as in, you have no idea how much functionality you can churn out in a day. But he didn&#x27;t like it, so he edited his code in....wait for it... WordPad! (That&#x27;s a Windows built in Rich text editor where double clicking on an underscored_word only selects up to the underscore because it&#x27;s not made for code, and that on its own makes it impossible to work with).<p>I tried to modify his code for several hours but had to stop myself because it was madness. So I told him the only way forward would be to rewrite everything from scratch after which point I could make it do anything he wanted. I reckoned it would only take 4 weeks to rebuild his 15 years of mess - partly because the IDE makes development so damn quick, and was even willing to do it on a fixed price, but he declined, which I think was utter madness.<p>The thing is, he had 15 high paying clients, and two other part time employees helping with other aspects of the business, and drove a brand new Audi A3, which means he probably holds a world record for highest ratio of money earned to quality of code written, at least in the CAD subcategory :-D
cat-turnerover 6 years ago
In my past life I was an oceanographer at a consulting company. Essentially we wrote Matlab code that processed data we get from ocean and meteorological models. Many of these models, used by NOAA, are all written in Fortran. While most were well documented, one thing you could not get around is the use of parameters for these models ( think of global variables used everywhere) and a never ending game of go-to statements. I had to figure out how this one flood model worked... literally had to read 5,000 lines of Fortran. This is what we use to determine potential flood impact from hurricanes, today. Software written for oceanography is a whole other beast.
gassissover 6 years ago
Three years ago I was hired as a Business Analyst, with 0 background in anything related to IT. Our team was responsible to maintain a legacy base in COBOL.<p>As time went by, everything started to make sense and I was able to grasp almost everything about the environment and the tech stack. Even perform a little bit of system analysis in COBOL to try and identify some gaps in the code base.<p>But what always intrigued me is that even those senior developers in the team with 25+ years of experience with COBOL wouldn&#x27;t ever touch this one program. The program responsible for 90% of the logic of the product of that company. Every now and then, this program would ABEND for whatever reason and sometime, no one could figure out why. They respected (cute way of saying they were afraid) this program so much that, instead of refactoring it, they would just throw an if statement and let it run.<p>This program was built in the 60s and had I don&#x27;t know how many hundreds of thousands of lines of code. It is still running to this day.<p>Now I don&#x27;t have the expertise to say if that was bad code, and even if I had, I didn&#x27;t deal with this program enough to say this anyway, but I was very intrigued why would this particular program ABEND out of nowhere, and no of these super experienced developers would have the guts to touch it.
dotdiover 6 years ago
I was given the opportunity to work with iOS at one of my former employers and I quickly agreed (I was a backend developer back then). It was a rather popular application at a rather large Austrian media company, with around 50k unique monthly users.<p>Boy did I regret that decision!<p>- 100KLOC<p>- Initial development outsourced to India. Comments, variable names in Indian.<p>- Subsequent development outsourced to Belarus. Add comments, variable names in Russian.<p>- &quot;Why use ObjC OO features when we can write buggy and incoherent C&quot;?<p>- Global, implicit state everywhere. Tapped on something? Hope it didn&#x27;t mess up the state you are relying on.<p>- Obviously no tests, and no testers.<p>- Inheritance chains of up to 20 classes.<p>- iOS kindly forces MVC, but you can obviously write empty controllers and all spaghetti-logic into your views. Needless to say, that was what they did.<p>- Complete lack of proper structure. Several views iterated up their parent controllers to the desired one, grabbed its views, iterated over them until the right view was found and something was done to that view.<p>- Building and running the application was controlled by 10+ env variables (the other dev was fired after he pushed a dev build to the App store, which mysteriously passed review. &quot;Whoopsie, forgot to set one of the env variables correctly&quot;).<p>- about 80% of the logic was copy-pasted for the iPad build instead of reusing anything. It was not a different target, it was a separate project.
评论 #18449204 未加载
wbsunover 6 years ago
Two case:<p>1. Millions lines of messy Java code with annotations and dependency-injection form a multi-shard distributed job with tens of distributed downstream backends, some of which provide fake always-success synchronous RPCs hiding the fact that the underlying operations are actually asynchronous and may fail very often. What makes it worse to work on these code is it was built with a single transactional underlying database but then due to reliability issues of the single database, data are now across at least three different transactional databases. This causes endless race conditions and concurrency issues to fire everywhere. The production release of this distributed job used to be once every week, now multi-months is normal, and quarter rollback is not a surprise to people.<p>2. Almost million lines of messy C++ code with several .cc&#x2F;.cpp files containing tens of thousands C++ code, some class implementations are across multiple .cc&#x2F;.cpp files. I have always been scared when touching some of these giant .cc&#x2F;.cpp files. People who have been working on the code for years can still easily make ignorant mistakes when adding&#x2F;modifying a small feature (with so-called fully unit-test overage of course). There are multi-million lines of testing code, which is almost 10x of the code be tested, but most of them are bogus and almost test nothing, hence silly mistakes are everywhere, everyday. Even the original author of the code base needs 5 follow-up fixes in order to make a 10-line behavior change work.<p>For both code bases and the jobs running these code, people are now talking about breaking them into microservices, by converting function calls in the existing code bases into RPCs. I can foresee a tremendous number of service outages are coming...
a-dubover 6 years ago
NaN kloc.<p>Nobody could even describe definitively where all the code could be found in version control. The best part was that nobody trusted version control either, so even if you did find something that looked relevant, there was a good chance it was dead and only served the purpose of confusing you or forcing you to memorize unstructured structure just to be able to get around.<p>It was madness inducing.
shadoxxover 6 years ago
Here&#x27;s a story I haven&#x27;t shared in awhile.<p>One of my first gigs actually getting paid to code was getting hired on as a last ditch effort to save what was (unknown to me at the time) a failing business. It was a company that basically relisted real-estate auctions on their own site, coded entirely in PHP, by a single developer who had read &quot;How to Code PHP in 24 Hours&quot;. They had one client that was basically keeping them afloat. It was so disorganized that at one point I was tasked with making a quick YouTube commercial in Adobe Premier for a client, showing off the features of our whitelabel product with their logos, edited from a stock template. I do not know Adobe Premier. I digress.<p>The main PHP file (yes) was 20,000 lines of code. Want to add a new feature? Copy that file into a new file and save it as newfeature.php. Database operations weren&#x27;t transactional, there was no change management, and for about a week we were using production systems to code until development environments were made for us.<p>There was other shady stuff going on too, like using over a hundred proxy accounts to scrape content from other listing sites. I refused to touch or even look at that logic in the codebase, and it was always talked about in kind of a hushed way. I was young, didn&#x27;t know any better, would nope the eff out if a similar opportunity came along at this stage in my career.<p>They folded shortly after laying off pretty much everyone but the CEO and the lone coder. Dumpsterfire would be an understatement, but my coworkers were chill and helped make the best out of a bad situation.<p>EDIT: Oh yeah! I forgot to mention the hardcoded password the was site wide that we used as a sort of &quot;impersonation&quot; feature. You could type in any user account and this password, and it would log you in no problem. No, we did not have auditing controls.
rageagainst20over 6 years ago
When I took over my current job a outsourcing company who employed developers based in Islamabad (Pakistan) wrote most of the code. It&#x27;s C#, they didn&#x27;t understand the concept of null, by ref or by value.<p>It was interesting. The database was Mongo and they had some horrible Entity Framework port that they forked on Github and used which wasn&#x27;t maintained and at the time in 2015, 3 years old.<p>The data layer had business logic. Let&#x27;s say they were getting a user record from the database but they didn&#x27;t want to include the first and last name they&#x27;d write a method called<p>GetUserWithoutFirstAndLastName();<p>That would be in the User repository. Another requirement would come up to get the user but not include the user&#x27;s language for instance and they&#x27;d create another method<p>GetUserWithoutFirstAndLastNameAndLanguage();<p>Ended up with about 70 or so methods which basically gave different levels of hydration for the User object.<p>The frontend was written in Extjs which took about 25 seconds to load.<p>They had no tests.
评论 #18449985 未加载
jancsikaover 6 years ago
If you search youtube for something like &quot;pure data dance music&quot; you&#x27;ll find some excellent spaghetti diagrams that produce music&#x2F;video.<p>Since the environment provides realtime feedback, it&#x27;s a drag to try to refactor the current diagram into a reusable abstraction. Instead, many users optimize their creative time and just keep adding functionality to the diagram in a single graphical window. By the time they are done there is text overlapping other text and a bunch of lines obscuring most of the diagram.<p>Even with the ones that have a simple set of controls for a sequencer or whatever, there is usually a &quot;guts&quot; module that hides all the spaghetti.<p>Also, for any running program you can instantly make it twice as spaghetti by doing &quot;select all&quot; and &quot;duplicate.&quot; :)
jtolmarover 6 years ago
All code is bad and Google puts almost everything in one repository, so I&#x27;m going to say that ;-).<p>For more traditionally defined bad code, I worked with a team that rewrote an existing service from scratch using with 40000 lines of spaghetti. The service that it replaced was 80000 lines, and was replaced despite working perfectly fine because it was a total clusterfuck with dependencies interwoven across every service anyone had ever heard of. This was a payments system for a major online retailer. All of this code has been removed since.<p>I also used to participate in Java4k, a competition to make games fit in 4 kilobyte jar files. Writing almost everything inside a while loop in a single function is basically table stakes for that.
评论 #18448458 未加载
ryanmarshover 6 years ago
Any large company. I’m being serious. As a development coach I see a lot of code and I must say the DEFAULT is “how does any of this even work?”
评论 #18447301 未加载
baron816over 6 years ago
I’d like to hear people describe why the code they’ve seen is bad.
评论 #18447361 未加载
评论 #18443103 未加载
评论 #18447668 未加载
JoeAltmaierover 6 years ago
A 10,000-line C++ module for transmitting hundreds of different packets to a radio module from the driver, all cut-pasted copies of the same code with different structure name. Bugridden (bad copy-paste-edit bugs).<p>I replaced it with an 11-line template.
clausokover 6 years ago
I worked on an Excel\vba swat team at an investment bank. Whenever someone in the various business units got themselves into more trouble than they could handle with an Excel model, we&#x27;d try to set things right. We saw a lot of wonderfully creative vba code from industrious programming beginners (or, as we liked to call them, &quot;Macro Recording Cowboys&quot;. The most amusing I saw was a model where the vba code used a Greek mythology variable naming convention:<p>Dim Hermes As String, Artemis As Long, Odin As Range
apnkvover 6 years ago
A few weeks ago I had to reproduce one of the recent papers on deep learning theory. It had ~3000 lines of code over around 10 files, but when I just removed stale and unused calls and spaghetti (just like static analysis does), it reduced to ~1000 lines with identical functionality.<p>Original code also computed the most time-consuming routine twice to thrice each run and had many many typos, e. g. &quot;calculte_infomration&quot;. Imagine this, but in every second function&#x2F;variable.<p>However, it worked.
YeGoblynQueenneover 6 years ago
There should be an award. Like the Turing award, but not quite.<p>The trophy should be a plate of spaghetti, in gold.
评论 #18449227 未加载
osrecover 6 years ago
I worked in investment banking as a quant. Once had the misfortune of working with a regulator-approved custom built market risk system from the 90s. It had code in every language you can imagine, from cryptic Perl, to Java, to C. The thing worked, but development cycles were a year long, primarily to allow for regression testing. It was a monster to debug, as very few people have the brain space to simultaneously comprehend that many moving parts.
wernseyover 6 years ago
My first job out of university was to program IVR systems for a telecom company using an in-house developed framework.<p>An IVR application would typically play a recording to the user, then wait for the DTMF signal, then maybe take the user to a sub-menu, prompt the user to choose another option and do a database query and then play another recording and so on.<p>The IVRs had to repeat a menu if the user made an invalid selection, and &quot;press &#x27;star&#x27; to return to the main menu&quot; and so on.<p>So most of the applications I maintained were thousand line C++ functions that looked something like this (paraphrased):<p><pre><code> void ivr_main(int ch) { main_menu: play(&quot;mainmenu.vox&quot;); d = get_dtmf(ch); if(user_hung_up(ch)) return; switch(d) { case &#x27;1&#x27; : goto menu_1; case &#x27;2&#x27; : goto menu_2; case &#x27;3&#x27; : goto menu_3; case &#x27;4&#x27; : goto menu_4; } goto main_menu; menu_1: play(&quot;menu1.vox&quot;); d = get_dtmf(ch); if(user_hung_up(ch)) return; switch(d) { case &#x27;1&#x27;: goto menu_1_1; case &#x27;2&#x27;: goto menu_1_2; case &#x27;*&#x27;: goto main_menu; } goto menu_1; &#x2F;&#x2F; etc... }</code></pre>
Lattelandover 6 years ago
After many years as a software engineer, I can only say that every large old application is a pile of messy junk. Whether it&#x27;s database software at Microsoft, visualization software at (another company), a database at a third company, another database at a 4th company, another database at a 5th company, they are all filled with junk and crap.
joddystreetover 6 years ago
The one I am currently working with - Multiple calls to the database (a lot of times in a loop) - Rather than reference, or variable passing, DB id is passed as a parameter to functions, so multiple calls to the database for a single object per API call - Database design was normalized initially, for &quot;optimization&quot; most of the database has been denormalized. - Queries without index - If we were to create an index, probably have to create index on every column - one of the function has more than 36 if else (including nested if else) - Does not work with database partitioned or multiple databases - OLAP like queries running wild on OLTP systems, just because we can - Fastest API call - 1 second, slowest - &lt;i dare no say&gt; It started as an outsourced project and the same codebase is being dragged on, with features being added every day and with no coherent plan.
boomlindeover 6 years ago
I&#x27;ve been patching a configuration user interface web application that uses the same codebase for a bunch of different product categories. Some 40 files totaling 15000 lines of HTML&#x2F;js combining filepp preprocessing (a C-like build time pre-processor) and SSI (server-side includes and conditional rendering with directives snuck into HTML comments) split over several repositories that are all tightly interdependent. Adding to that, obviously no one wants to claim ownership over this codebase and changes are frequently made by people that understandably don&#x27;t know exactly what they&#x27;re doing and reviewed by other people shooting from their hips. Any change to it has to be considered for every product that uses it, which I&#x27;ve never seen a full list of.<p>Not too many LOC but the badness&#x2F;LOC ratio is terribly high.
cghover 6 years ago
Microsoft Biztalk. By &quot;work&quot;, I mean it didn&#x27;t crash. It also didn&#x27;t do anything useful.
评论 #18443036 未加载
daprejaover 6 years ago
ADP Retirement Services first generation of PES (Plan Entry System) program. It was&#x2F;is an internal tool with all the horror stories that you hear about internal tools. The people who made it wrote obscure logic with encrypted variable naming with the main purpose of having job security, it&#x27;s a core tool in their business model but treated like gutter trash, built with visual basic and embedded angular code to make it look more modern, the supposed rewrite talk went on for 8 years, and to put icing on the top it was QAd&#x2F;maintained by underqualified offshore old-school contractors (you cant even call this group devs&#x2F;engineers).
joecool1029over 6 years ago
The leaked Windows source some years back was pretty damn ugly.<p>And it was only a small portion of the OS.
btbuildemover 6 years ago
Microsoft Word back in &#x27;99 -- can&#x27;t really estimate the amount of code, I didn&#x27;t have the experience to handle something like that. What I saw of it and what I worked on, that alone made me reconsider my career path.
andrewfover 6 years ago
If Foo1.php, Foo2.php and Foo3.php are all copies of the 1000-line Foo.php, each with a different smattering of bug fixes, each included by a different 10 - 20% of the overall codebase... am I allowed to count all 4 separately?
rocfreddyover 6 years ago
I worked for a cell phone company. They had a large piece of software that is used by all customer-facing employees to manage accounts (billing, network, provisioning). Over its life, the software had been rewritten in many languages. Prior to my joining the team, someone thought to take a .NET application and rebuild it as a web application (Spring MVC and ExtJS4).<p>The first day on the team, before even looking at the code base, I ask our development lead what unit testing framework we are using for the Java code and what we are using for the front end code. He gives me this funny look and tells me to speak the guy onboarding me. I of course go and ask the lead onboarding me and he gives me an answer that turned my world upside down.<p>&quot;Automated testing is a waste of time. You will spend too much time writing test then developing code and delivering stories to the business&quot;<p>I need to point out that this guy eventually goes on to an executive level position. proving that it is not the quality of work you deliver, but the optics of delivering quality software that counts in large corporations. I digress.<p>I receive my SVN credentials later that day and come to the realization that I have made a very poor career choice. The front end code alone is over 5k Javascript files with functions spanning thousands of lines long all full with 100&#x27;s of nested asynchronous callbacks. Not only is the code crap, but the tools that we had were not used correctly. For example comments.<p>&#x2F;&#x2F;01&#x2F;01&#x2F;2018 - Fix bug - Begin &#x2F;&#x2F;01&#x2F;01&#x2F;2018 - Fix bug - End<p>The code base was riddled with these. What story was this for? would have been useful to pull the Jira story and see what you were trying to do. I guess I&#x27;ll spend the day going through your 5k line function that does everything, but nothing. Or, better yet, let me check the SVN commit date. Maybe they committed some good notes for me there.<p>01&#x2F;01&#x2F;2018 - Fix bug<p>Damnit!<p>I did my year, which is the minimum you can be in a job before posting out. I left without a second thought. When I left the business was complaining because the testing team was larger than the development team. I wonder why?
INTPenisover 6 years ago
Bad code is a relative term. It might look awful but the design might be decent and of course it works or it wouldn&#x27;t qualify.<p>I&#x27;m maintaining two semi-large applications right now that I wish I had the time to fix.<p>The bad stuff is basically no documentation, no attempt at pep8 compliance, written before decorators existed in python and very dependent on Python 2 syntax.<p>But it works and it&#x27;s actually a very good distributed monitoring system that was ahead of its time. Closed source but it would remind people of prometheus if it was released, yet it was several years ahead of that product.
geekbirdover 6 years ago
The ugliest, most incomprehensible code I&#x27;ve ever see was when I had to mess with RedHat&#x27;s version of Anaconda (for building distros) back in the early 2000s. It was worse than the multi-thousand line TCL screen-scraper that I had to occasionally fix in 1999. It was the first code I&#x27;d even seen written in Python. You couldn&#x27;t really trace anything, it was all so nested and idiomatic. It made the Perl code I inherited from a long-time Perl guru downright comprehensible. I&#x27;ve looked askance at Python since.
blobmarleyover 6 years ago
Had to maintain a web code from the pre JSP era,i.e, servlets and writing UI code in Java classes (think writing html in s.o.p). The beauty of it all was that there were only two classes for the entire application: one was the servlet, and the other held all the UI code for all the pages. Requests bounced between the both of them, held together and dictated by a series of &quot;if&quot; conditions checking for &quot;string equals&quot; in a method with 50 variables, all strings, named s, s1, s2..s49. And no comments anywhere.
zie1onyover 6 years ago
Magento.
评论 #18447439 未加载
评论 #18443247 未加载
h4y44over 6 years ago
I was in an outsourcing team working for Panasonic door-phone system, the source code was big, but what my team &#x27;s done was to develop some more functionalities including video call. It was about ~20 KLOC written in C for the UI &amp; stuff (what we were ordered to do, since the behind layer was not disclosed to us). The source code was a mess since it&#x27;s written by low-experienced programmers and even intern students. Later I quit that job :)
thomover 6 years ago
I once had to wade into a PHP app for a government procurement website that was just horrifyingly messy. I used to maintain records for the highest line number on which the opening &lt;html&gt; tag appeared in a template (well into the thousands) and the highest number of opening&#x2F;closing PHP tags (hundreds in a single file). There was no structure beyond bunging stuff in the session and hoping it all hung together.<p>The app ran on Mac servers.
tluyben2over 6 years ago
A million+ lines of Java code for a product we (in a previous company) had; it started out nice and design pattern etc but after 5 years with ~200 different coders adding&#x2F;changing things and no time to refactor, it became bad enough to trigger a phase out of the product and replacement by another product. I actually moved roles to figure out how to not make the same mistakes: those lessons work for them until today.
kissgyorgyover 6 years ago
Two projects with 300000 lines of Python code each at a small company handling physical access control systems with smartcards and stuff. Once I looked the most critical part; the logic which decides if a door should be opened or not and it was implemented with the assumption that in Python, the bitwise operators work the same way as in C (they doesn&#x27;t at all).
Tade0over 6 years ago
An Angular app with ~50k LOC.<p>Barely any tests and several hand-rolled components, some of which were merged only because the author managed to implore somebody to give them an R+ after a few sprints of the branch just sitting there.<p>A total of 21 people were involved in creating this system and for some insane reason we still had daily standups with almost full attendance.
评论 #18443468 未加载
DaveSapienover 6 years ago
My codebase I&#x27;m working on right now. Went from a proof of concept demo, to small mini game, to a bigger mini game, to full game, to SAS product. With no time(budget) to rewrite it up until delivery to a customer. Its pretty frustrating, as its my fault, but budget and tight deadlines forced my hand.
bigredhdlover 6 years ago
So since we are on this subject, does anyone have advice for wrangling spaghetti QT apps into submission? We have two of them here and of course their creators aren&#x27;t here anymore and we find it very difficult for developers that weren&#x27;t involved in their development to grok all the shared state.
icedchaiover 6 years ago
Server code written in C++ that called into a lower level C library. There was a 4000 line case statement that handled message replay. I am not sure why it wasn&#x27;t broken out into functions, but it was &quot;sensitive&quot; code and refactoring it was considered a no go.
chad_strategicover 6 years ago
Drupal 8
评论 #18447482 未加载
评论 #18443963 未加载
UziTechover 6 years ago
My first PHP app was an invoicing application. It is ~3500 lines of php in a single file. Most of which is a few heredocs with javascript to be in lined on the client side. I haven&#x27;t touched the code in 10 years. I still use it for my freelance invoicing.
voldacarover 6 years ago
As a budding programmer (hobbyist), what can I do not to fall into the mistakes others talk about in the comments? Is there any particular set of mental habits that could lessen the chance of spaghetti occurring, or is it just a matter of when rather than if?
评论 #18449920 未加载
评论 #18449807 未加载
评论 #18448805 未加载
评论 #18448837 未加载
评论 #18448908 未加载
评论 #18448998 未加载
En_gr_Studentover 6 years ago
Windows Vista. It is practically a virus, and ran ~5x slower than XP on the same hardware.
评论 #18442930 未加载
hnrussover 6 years ago
Largest amount? 13k lines in a single Java file, none of which was boilerplate. Who knows how many lines were in the whole project... a million seems about right.
atilanevesover 6 years ago
C functions that span over 10k lines with 46 parameters.
jedimastertover 6 years ago
Not as big as some of the examples here, but still kind of interesting. I worked for a city government, and the entire backend code for our work-bids site was a few hundred files of PHP written with some sort of Dreamweaver framework that was deprecated years ago. Old enough that the entire site had to be run on PHP 5.7. I ended up rewriting the entire thing with Laravel (the framework of choice for the other webdev that was in the IT dept). It really didn&#x27;t take that long; he just had too much on his plate to worry about it before I showed up.
spsrichover 6 years ago
has to be itunes. What a bloated pile of crap that is.
评论 #18443439 未加载
brianpgordonover 6 years ago
Once upon a time, there was a search product and one of the data sources that it could search was a Solr&#x2F;Lucene database. This should be no problem, since search is what Solr does. It should be as simple as passing the user&#x27;s query through to Solr and then reading the response. The problem was, it was important to know exactly which parts of any matched records were relevant to the search.<p>The Guy Before Me™ decided that the best way to implement this would be to split the user&#x27;s search into individual words, perform a <i>separate</i> search query through Solr&#x27;s HTTP API for each <i>individual</i> word, and then do a bunch of very clever and complex post-processing on the result sets to combine them into a single set of results.<p>This led to endless headaches due to horrible performance. Imagine if you wanted to implement web search this way. How would you synthesize the results for the search &quot;boston plumbers&quot; given the search results for &quot;boston&quot; and the search results for &quot;plumbers?&quot; You would need tens of thousands of results for each search term to find even one match that applies to both terms. Now scale this to getting hundreds of results to present to the user. Now scale this to n search terms.<p>I was tasked with making this take less than 8,000ms for a simple query. I spent a while getting to understand how this code worked and building out performance tests so that we could determine how it would behave under load (we didn&#x27;t have any users yet). The results were pretty grim. I presented two possible options for moving forward:<p>1. Move this crazy result-set-intersection logic closer to the data. I could build a custom Solr plugin to do this stuff inside the Solr server so that we didn&#x27;t need to copy gigantic result sets across the network from Solr to the application server for every query.<p>2. Delete ALL of this nonsense because <i>literally exactly</i> what this whole mess of code was meant to accomplish is already implemented in Solr. They call it highlighting. It&#x27;s one of the marquee features of the program. I can&#x27;t stress enough that this is precisely, perfectly, unequivocally, the exact thing that all of this complexity was meant to accomplish.<p>My manager thought it would be a shame to throw away all of that very expensive code and lose the flexibility of an in-house solution. So we went with option one. I spent the next month writing a Solr plugin that reproduced the original logic. It was still slow as mud so I sharded the data across multiple Lucene servers and distributed the algorithm across them with a map&#x2F;reduce sort of scheme.<p>In the end, it all worked great. It was fully ten times slower than the solution already built into Solr, but it worked.<p>The startup later ran out of runway trying to build a big-data-sized in-memory distributed database from scratch to speed up search. The founder (also the lead developer while I was there) insisted that everyone use raw C-style arrays and a custom in-house hash table implementation because he thought STL was too slow. Basically, &quot;not invented here&quot; was in the DNA of that company. I&#x27;m surprised we even used commodity hardware and didn&#x27;t design some kind of in-house search coprocessor that would do everything in silicon.
评论 #18449601 未加载
bayindirhover 6 years ago
Obligatory XKCD: <a href="https:&#x2F;&#x2F;xkcd.com&#x2F;303&#x2F;" rel="nofollow">https:&#x2F;&#x2F;xkcd.com&#x2F;303&#x2F;</a>
评论 #18449295 未加载
评论 #18449168 未加载
shapiro92over 6 years ago
Huge ecommerce company. Code written from the 90s in .NET was ported into PHP using an auto-library... nothing else to say
sigi45over 6 years ago
ah my godness that brings back bad memories... :|<p>I was at a project were every new developer said &quot;i have never seen such bad code&quot;. Srsly! 3 new People said it and me as well.<p>- Bad testability - no tests - hidden 3 bad bugs surfaced in just one year - ...<p>I had very little trust in that code. And it was not much fun. On Upside: Cleaning it up was a great feeling.
waleedsaudover 6 years ago
Thank you for the question it gave us so much knowledge in the replies.<p>Wish you all the best
zerrover 6 years ago
A million lines of mostly 90s style C++ codebase - works like a charm :)
sonaltrover 6 years ago
One of the startups I worked at had 3 frameworks in PHP - all grown, all messed up in all the wrong ways - and that was just the backend. We had a homegrown framework written in JQuery for the frontend as well. never Again.
评论 #18443301 未加载
Jaruzelover 6 years ago
Every line of code I&#x27;ve written over the past 30 years.
lumostover 6 years ago
100k lines of semi generated, semi handrolled java&#x2F;c
admin1234over 6 years ago
I made scones with the wrong flour once. (<i>¿</i>)
cyberveganover 6 years ago
Amavisd. About 11,000 lines of crufty perl.
sandwellover 6 years ago
The most insidious cases are those where bad processes are developed around bad software, leading to a vicious cycle of co-dependency.<p>I once worked for a reasonably large business that ran all of their invoicing and stock management through an MS Access project. The whole thing was wacky. half the business logic was implemented in VBA. The other half was stored procedures, but there was no obvious pattern (predictably, anything that involved a task the DB was optimised for was written in VBA). &quot;Deployment&quot; consisted of saving to a network drive and waiting until everyone opened it again in the morning. Data integrity seemed optional and inconsistent. The symbol naming convention could be described as cryptographic. The only documentation was a comment over each function stating the original developer&#x27;s name and a timestamp. It had a proud splash screen stating &quot;Developed by Dave Davidson&quot; that was shown for 5 seconds on startup - this was of course completely simulated and there was no reason to have a splash screen. I could never quite fathom the magnitude of this guys delusions of grandeur or why they would want to put their name to it.<p>The worst part about it all was that for the most part, it worked. The parts that didn&#x27;t work were well known to the people using it and worked around. So processes were developed around it, and over time these became so deeply ingrained in the teams using it that they couldn&#x27;t imagine working any other way. Most of this consisted of taking telephone orders, printing off the invoices that were generating in Access, and then rekeying that information into an accounting system (for efficiency purposes of course, these printed copies were passed to another team member with notes scribbled on the original document. Mistakes were commonplace and accepted as a CoB).<p>Part of my role was to implement a web based ordering system. We did a reasonably good job but of course had plenty of our own WTFs. The biggest pain was integrating this with a particular team. They could not imagine a process that did not involved printing off orders and rekeying. After a while we realised that the reason we got so much push back was that once fully integrated, our system would make half of the team members redundant.<p>With support from management we went ahead, and over time the wrongs were righted. When I left there was still a deep level of distrust in the new system. Mistakes that were daily occurrences in the old world were &quot;proof that the new system won&#x27;t work&quot;. Orders were still printed &quot;just to make sure I don&#x27;t lose it&quot;. New bugs were treated as if the sky were falling. I would spend more time managing expectations than writing code. But we got there in the end.<p>Buggy software can be fixed. Buggy humans are an entirely different kettle of fish.
bitwizeover 6 years ago
Windows.
ivthreadp110over 6 years ago
SAS Viya. Enough said.
bigiainover 6 years ago
git ls-files | xargs wc -l<p>&lt;puts face in palms, starts weeping gently&gt;
评论 #18449003 未加载
weatherlightover 6 years ago
The Internet.
jbigelow76over 6 years ago
While not related to LOC, warranted nonetheless: <a href="https:&#x2F;&#x2F;xkcd.com&#x2F;2030&#x2F;" rel="nofollow">https:&#x2F;&#x2F;xkcd.com&#x2F;2030&#x2F;</a>
aerovistaeover 6 years ago
The entire Athenahealth stack.
评论 #18475647 未加载
superdexover 6 years ago
if it works, it&#x27;s not bad code
评论 #18447962 未加载
PavlovsCatover 6 years ago
My own CMS. Here&#x27;s the function signature of the heart of it, which depending on circumstance may call itself recursively.<p><pre><code> function a_nodes_list_trees( $site_url, $base_url, $mode, $site_id, $max_subtree_depth, $nlevels, $node_id = 0, $tree_id = 0, $nleft = 0, $nright = 0, $nlevel = 0, $current_subtree_depth = 0, $flags = 0, $order = &#x27;tree&#x27;, $inline = false, &#x2F;* needed when loading stuff via ajax*&#x2F; $skipped_types = [], $items_per_page = 10, $min_tag_count = 2, $min_author_count = 2, $is_site_root = false, $skip_pagination = false, $ignore_404 = false, $skip_display_options_and_batch_ops = false, $display_bottom_pagination = true) </code></pre> As you can tell from the default values, it started out having 6 arguments. And it has things like this in it:<p><pre><code> $mysql_the_rest = &#x27;FROM &#x27;.DBTP.&#x27;node n LEFT JOIN &#x27;.DBTP.&#x27;node n2 ON n.tree_id = n2.id AND n2.perm_view &amp; &#x27; . A_PERMS . &#x27; &#x27;.$mysql_join.&#x27; WHERE &#x27;.$mysql_where2.&#x27; &#x27;.$mysql_where.&#x27; n.perm_view &amp; &#x27; . A_PERMS . &#x27; AND n.site_id = &#x27; . $site_id . &#x27; &#x27;; $total_count = $A-&gt;db-&gt;fetch_one_column(&#x27;c&#x27;, &#x27; SELECT COUNT(*) c &#x27;.$mysql_the_rest); </code></pre> .. you know? The whole CMS is 20k lines of PHP, with HTML, PHP, and MySQL all happily living together in the same files (it&#x27;s not that I don&#x27;t have templates, I just have plenty HTML in the PHP, too)<p>Yet, it works like a charm, PHP updates made it faster even, and I can use it for everything I needed so far, and use its output in a variety of ways. I still want to rewrite it, but it seems a lot of work to just shave off a few ms and have nicer code, with the same result for the visitor, and also having to write something that migrates the content. I suspect with enough content, it will slow down, and then I&#x27;ll think about the next iteration. But it&#x27;s still a mixture of pride, plain being happy to have it, and groaning whenever I fix a bug or add a feature.
评论 #18447384 未加载
评论 #18447490 未加载
评论 #18447509 未加载
评论 #18443973 未加载
excaliburover 6 years ago
Windows