
The worst program I ever worked on - bemmu
http://jacquesmattheij.com/The+worst+program+I+ever+worked+on
======
presidentender
My instructor in the introductory programming course informed us that yes, the
grader did indeed read our source code, and check to make sure we'd commented
it meaningfully.

I decided to test this assertion.

The program in question was trivial - it was one of those contrived examples
of how OOP works, a "Kennel" which had "Dog" objects which possessed various
traits, and would bark() or wag(), stuff like that.

I obfuscated the code as much as I could - indentation all over the place,
line breaks in inappropriate places, code hidden inside multi-line comments,
and multiple dummy variables named one character off from the useful
variables. The useful variables had names like "satrtrek," "maryppopins" and
"pizza." The dummies were "startrek" and "marypoppins."

This exercise taught me nothing about writing code, but because my code gave
the expected output, I still got an A. Source code comments from then on were
made only as needed.

The next semester, I got an email from a friend of mine who just couldn't get
his head around what was supposed to be going on. He asked whether I'd kept
the source to one particular program, so that he could review it and see if he
couldn't make sense of the assignment.

I had indeed kept it, and just sent the .java files to him without opening
them for review. By coincidence, the program he was stuck on was the one I'd
obfuscated. He switched his major to Math and Spanish for what I believe to be
unrelated reasons.

------
boyter
Worst for me was something I was asked to maintain a little while ago. Was
essentially Microsoft Reporting Services implemented in 80,000 lines of
VB.NET.

The first thing I did was chuck it into VS2010 and run some code metrics on
it. The results follow,

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 2500 (the worst I have ever seen on a function before
was 750 odd). It was full of nested inline dynamic SQL all of which refered 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.

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.

EDIT - I forgot to mention, there was so much 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.

------
edw519
I met the guy who wrote this bit that I had to maintain:

    
    
      for(a=0;a<NbrOfAs;a++){
       for(aa=0;aa<NbrOfAAs;aa++){
        for(aaa=0;aaa<NbrOfAAAs;aaa++){
         for(aaaa=0;aaaa<NbrOfAAAAs;aaaa++){
          for(aaaaa=0;aaaaa<NbrOfAAAAAs;aaaaa++){
           if(aaaaa==0)else{ExamineAAAAA()}
          }
         }
        }
       }
      }
    

What really pissed me off was that he was such a nice guy.

He still works a lot. Makes a lot of money. And his customers love him. (No, I
don't think they review his code.)

~~~
arethuza
Unless there is a lot of creative abuse of operator overloading or macros
lurking in there that code really doesn't look too awful compared to some
monstrosities I've had to work with.

~~~
rubergly
I agree. At first glance, I thought that the NbrofA/AA/etc names were just
gibberish. The most nonsensical part to me is starting the for-loop iterator
at zero, and then only executing the function if the iterator is non-zero.

~~~
arethuza
I hadn't even noticed the if - I was thinking it was loops all the way
down....

------
redredraider
You really don't know bad programming until you have spent some time in a
50000 line cobol program. I'd post some crap I work on every day but I don't
want to make anyone cry. Nevermind. Here's some random code I'm working on.

    
    
                 MOVE SPACES TO LISTBAT-NAME.
                 STRING WORK-FILES "LIST.BAT" DELIMITED BY "  "
                 INTO    LISTBAT-NAME.
                 OPEN OUTPUT LISTBAT.
                 MOVE SPACES TO SCR-S.
                 STRING "DIR /B " DATA-PREFIX " > " 
                 WORK-FILES "TMPLIST" DELIMITED BY "  " 
                 INTO  SCR-S.
                 MOVE SCR-S TO LISTBAT-REC.
                 WRITE LISTBAT-REC.
                 CLOSE LISTBAT.
                 CALL "C$system" USING LISTBAT-NAME, 96 
                 GIVING STATUS-VAL.
                 MOVE SPACES TO TMPLIST-NAME.
                 STRING WORK-FILES "TMPLIST" DELIMITED BY "  " 
                 INTO  TMPLIST-NAME.
                 OPEN INPUT TMPLIST.
                 MOVE LOW-VALUE TO LIST-NAME.
                 PERFORM UNTIL 1 = 2
                 READ TMPLIST
                 INTO SCR-S
                    AT END EXIT PERFORM
                 END-READ
                 ADD 1 TO PROGRESS-REC-CT
                 INSPECT SCR-S CONVERTING LOWER-CASE-ALPHA TO 
                  UPPER-CASE-ALPHA
                  PERFORM VARYING SCR-X FROM 50 BY -1 UNTIL 
                  SCR-X = 1
                  IF SCR-S(SCR-X:1) = "."
                  MOVE SPACES TO SCR-S(SCR-X:)
                  EXIT PERFORM
                  END-IF
                 END-PERFORM
                 CALL "CC/STRINGER" USING SCR-S, STRING-INFO
                 MOVE SCR-S(1:STRING-INFO-LENGTH) TO TMP-RID
                 PERFORM LOAD-RPT-FILE THRU END-LOAD-RPT-FILE
                 END-PERFORM.
                 CLOSE TMPLIST.
    
    

The newline on some of those lines is off because HN makes it wrap but you get
the idea

~~~
rorrr
Note to self: do not learn COBOL.

~~~
jtolle
That's funny, because I look at that and think it's too bad I don't know
anything about COBOL. It's not like I'm planning to learn it or anything, but
it's quite different from anything I've ever worked with.

So, questions: I know I'll never program in COBOL. But I'm interested in
programming languages in general. How much of a "quick intro" would be worth
digesting just for the purpose of contrasting to C, VBA, Lisp, etc.? Is there
a good one to look at?

~~~
redredraider
I'm interning with a company that is a COBOL shop. It took me months to make
the transition from "normal languages". I don't think it's worth learning
honestly unless you get a job in it. Here are some things it has taught me.

It's taught me to create pretty code that is indented correctly. I pretty much
live in a debugger. Most people out of a CS program think they know how to
debug stuff. They don't have a clue. It's taught me to be very meticulous and
review every single thing I do down to periods(which BTW terminate loops and
if statements making life hell) If you can't understand what you just wrote it
needs rewritten.

As far as language comparisons. All variables are declared at the top of the
program. All variables are fully global. If you move a variable to a smaller
variable it doesn't throw an error it just gets truncated. Loops start at 1
instead of 0. There is very limited error handling.

I don't know of any resources online. I searched when I started working but I
didn't find anything real helpful. I did have a 25 year old 30 million line
code base to learn from though

------
Stormbringer
I worked on a piece of code that literally drove the guy who wrote it round
the bend. He had a mental breakdown, ran away, and eventually ended up in a
different state ~3000 miles away.

It wasn't so bad.

Now debugging code written by _Chemistry Students_... that's some scary stuff
right there.

Which is not to go all elitist and put Comp Sci degrees up on a pedestal, one
of the better coders I've had the pleasure of working with was a trained vet.
He was very methodical.

Actually, now that I think about it, working with something that if you make
it angry it will bite your hand off, is probably good preparation for dealing
with a compiler...

~~~
rwmj
You should try working with code written by hardware engineers. Those guys are
extremely smart when it comes to digital and analog electronics, but never
ever let them write a device driver ...

~~~
dkarl
Those guys are _too_ smart. When you start to write programs that are too big
to understand as one lump, you start to learn to decompose your code and
organize it in ways that help you understand it a little bit at a time. They
never do that; they just keep the whole program in their head at one time.
Tell them that a function should do one "simple" thing that makes sense as a
unit, and they have no problem putting the whole program in that function.

Actually, I shouldn't say they are _too_ smart, because they will continue to
program like that even when it causes them problems....

------
ladon86
I worked with a guy (I won't name the company) who wrote Java code in one,
huge, static class as much as possible. In fact, everything was largely in one
function too.

He decided to name his fields alphabetically.

static int a

static int b

static String c

static float d

static int e...

What, I wondered, would happen when he ran out of letters? Scrolling down
further I saw this:

static int aa

static float ab

static String ac

static int ad...

~~~
Stormbringer
To really bork up the Java, you need a pattern fanatic. Once you stand working
with Handler Adapter Handlers you know you should have taken the other colour
pill.

~~~
klaut
Yes, i remember working for a company (java devs) where at some point we ended
up having wrappers around wrappers around wrappers delegating stuff around,
factories of factories ... It made your head spin.

~~~
kaylarose
Yes. APIDelegatorInvocationHandler and APIAbstractFactoryFactoryProvider.
(actual Java class names)

~~~
Sandman
When you said 'actual Java class name' I thought for a moment that those were
actually classes in one of Java's libraries. I googled the names, though, and
fortunately, they're not...

------
Luyt
I think the best way to guarantee job security is to solve hard problems for
the company you work for, and make it visible (i.e., communicate about it).
This will gain respect from your peers and give you a reputation of being
useful and very worthy keeping around.

Writing some kind of obfuscated code is shooting yourself in the foot - after
a while not even you can maintain it. Plus, your peers will notice and
probably not like it. This notion will percolate up to management.

Another way to guarantee job security might be when you are the only person
able (or willing) to maintain some old legacy system. This carries the risk
that if that system is finally scrapped or replaced, your job is being
scrapped too ;-)

edit: horrible grammar

~~~
rahoulb
Not a pleasant story, but true...

I used to work at a place where one of the guys wrote a horribly complicated
piece of code that about half of the system depended on. He was also quite an
unpleasant man who routinely mocked everyone else in the company for not being
as clever as he was.

The company ran out of money and needed to halve its workforce - one of my
friends overheard him boasting that there was no way that they could get rid
of him, as no-one understood what he had written.

I was asked about his code - I said no-one but him could maintain it, but give
me three months and I could rewrite it.

I don't like to revel in other's misfortunes but the look on his face as he
left the office on the day of the redundancies was a picture.

In the end I kept half of his code (ring-fenced so it was effectively a black
box that no-one touched) and rewrote the rest in about a month.

Personally, I work hard, make it visible (as Luyt says), own up to my failures
and every now and then go beyond the call of duty. And I try very hard to be
nice to people, even when they're acting like idiots.

------
suppergenius
_The only place where the names made any immediate sense was 'main' and any C
stdlib calls._

Any job worth doing is worth doing right. Contrariwise, any job worth fucking
up is worth fucking up stupendously. He didn't go all the way.

    
    
      #define monkeymeat printf
      #define turtlescrotum malloc
      #define wolfnipplechips gets
      #define chipotlaway exit
      ...

~~~
statictype

        #define HEREWEGO {
        #define ENOUGHNOW }

~~~
suppergenius
Well we are diverging from the theme, but the proper form of that is

    
    
      #define O_HAI {
      #define KTHXBYE }

~~~
pjscott
You can even go a little further and use trigraphs, which is one of those
ancient features that most people have forgotten because it doesn't make much
sense anymore. ??< and ??> are equivalent to { and } in C, which could be
handy for further obfuscation.

<http://en.wikipedia.org/wiki/Digraphs_and_trigraphs>

------
michael_dorfman
Back in the day, I was an RPG programmer (on an AS/400), and I had a co-worker
who insisted upon using geographical labels for all of his GOTO targets: GOTO
BARCELONA, GOTO TOKYO, etc.

Needless to say, maintaining his code took some getting used to.

~~~
Stormbringer
That sounds kind of funny. Where do you go on error?

One time I had to debug this incredibly obfuscated Word Basic subroutine. It
was such a mess of gotos (deliberately so) that the company that wrote it for
us thought they had us over a barrel and could charge us like a wounded bull.

That is, until I showed my cow-orkers the superior technology of "paper,
scissors and sticky tape".

~~~
Someone
_Where do you go on error_

Hell, Arizona or any other village with that name. Real C# code can be like
this:

    
    
        if(John is evil){ goto Hell};
    

([http://msdn.microsoft.com/en-
us/library/scekt9xw%28v=vs.71%2...](http://msdn.microsoft.com/en-
us/library/scekt9xw%28v=vs.71%29.aspx))

~~~
michael_dorfman
GOTO HELL showed up with predictable frequency. I don't recall if he used it
for errors, though.

~~~
Gibbon
Which Hell would that be? The one in California, Michigan, the Cayman Islands
or Norway?

------
joelhaasnoot
A project I worked at during an internship had an unmanaged C++ portion for
rendering complex typography, which was written when every letter in a
variable cost $10 (or so it seems). The result was that "pointer to a metadata
character" became the variable "pmc", and that was just the beginning of it. I
never quite did understand what the variable lpmnoics meant, and debugging the
C++ was quite the drag and the task everybody avoided, and pushed off to the
original developer of that code (who happened to be in a different geographic
location).

~~~
kragen
That sort of thing is a lot easier to understand if you have the secret
decoder key: <http://www.joelonsoftware.com/articles/Wrong.html>

But it's probably a defensible idea, in context. The idea is to supplement the
type system of a low-level language with a manually-checked type system that
helps you find semantic errors.

~~~
joelhaasnoot
You're right, eventually I did get the hang of the chunk of code and wasn't
afraid of it. Lots of others in the team were however. Also, because of
eXtreme Programming and pairing, I knew the C# and what it was doing in 2
weeks and was writing code, having never seen C# before. I had some C++
experience, but by the end of my 6 month internship wasn't comfortable with
the "views code". Yes, it was high performance code that did black magic, but
making it readable is halfway to being able to understand it. It worked and it
was fast enough and did good stuff (ever try doing a vertical unicode editing
view?).

------
gst
It does not need to be that complicated :)

When a company I worked for was bought the new companies tried to lay of some
(most) of the employees. At this time our team was working on a product that
was to a large degree implemented in Scheme (because management didn't really
care about the programming language). I quit at the company (for unrelated
reasons) soon thereafter, but it seems that my colleague (with whom I've
implemented the system) had quite a good job security at this time.

~~~
mattdeboard
I can't tell if the number of parentheticals in your post is a pun about using
Scheme or not.

------
mberning
The legacy system that I'm working on now has about 20-30 distinct
classes/data types that it needs to manage and persist to the database. The
previous developer chose to implement all of these different data structures
in one uber-table named 'object' and in the application code with one uber-
class named 'Thing'. Relationships between 'Things', regardless of meaning or
type, are simply dumped into a 'relationship' table. It wouldn't be so bad
except for the meaning and nature of relationships is often inferred based on
the order or 'direction' of the relationships in the database.

So pretend that I have a 'Thing' representing a table, and another 'Thing'
representing a column. If the relationship was from the table to the column
then that might indicate that the column simply belongs to the table. However,
if the relationship is from the column to the table, then that might indicate
that the column is a primary key.

There are also other gems deep within the bowels of the system. Many functions
named things like 'doItForRealThisTime' and 'reallyDoIt'.

~~~
nicpottier
One of my favorite accessor method names I've run across is 'maybeGetCube()'.

The idea was that if it was cached, then it would return the cube, otherwise
null. Cube was actually relatively aptly named, it was a big matrix of data
BTW.

I guess really it wasn't THAT horrible, but the whole idea of 'maybe' doing
something in code has always made me chuckle.

~~~
rpeden
I guess you've never tried Haskell then. :)

[http://hackage.haskell.org/packages/archive/base/4.1.0.0/doc...](http://hackage.haskell.org/packages/archive/base/4.1.0.0/doc/html/Data-
Maybe.html)

------
xiaoma
One of my former classmates names _everything_ he can get his hands on after
various obscure anime references-- database names, variables, servers, you
name it. Once in a blue moon, I'd recognize a function name as being a
character or item from one of the few animes I'd seen and after a bit of
tortured logic based on the background it almost seemed like a reasonable
choice.

Needless to say, he does better working on his own.

~~~
artmageddon
I wonder if he read the Manga guide to databases:

[http://www.amazon.com/Manga-Guide-Databases-Mana-
Takahashi/d...](http://www.amazon.com/Manga-Guide-Databases-Mana-
Takahashi/dp/1593271905/ref=sr_1_3?ie=UTF8&s=books&qid=1300285857&sr=8-3)

~~~
xiaoma
My god... I guess it shouldn't surprise me that an EduManga industry exists.

------
travisglines
Call me Captain Obvious, but I feel like quite often the time spent in
obfuscating code in many cases might be a major component of why programmers
that do this sort of thing get fired in the first place.

What goes on in someone's mind that says: "Maybe if I spend some time making
my source code hard to understand I can better preserve my job." ?

In reality all it does is slow them down, waste their time and lead to the
firing of the developer. (At which point we get to hear funny stories from
people like jacquesmatteij)

If that time was spent improving/refactoring their code and working on new
things, they'd actually have the job security they were so desperately
seeking.

~~~
danenania
While this is true, there's a lot of space in between a model developer and a
purposely-obfuscating twit. There's definitely a line that lazy developers can
walk where they contribute just enough to make firing them more of a pain than
putting up with them. I suppose the lesson for businesses is: be very careful
about who you hire in the first place, because you may end up stuck with the
person whether you like it or not.

~~~
msluyter
And there are a lot of subtle little ways in which a developer can drift into
this state. For example, not bothering to document how systems work, or opting
to make band-aid patches to brittle systems rather than refactoring. After a
while of doing the easy/lazy thing, you're eventually lording over a complex
black box that only you understand.

Some may find that a comfortable place to be. You become an expert; you have
opportunities to be the hero. And it doesn't necessarily even happen via
malicious intent. Sometimes you just don't have time to document or refactor
anything, and you find yourself in a suboptimal local minimum. (Speaking from
experience.)

------
RiderOfGiraffes
I've watched enough "programmers at play" and read enough code to happily
believe that this guy was just letting his sense of humor have its day. I'm
not at all convinced that things like this are deliberate obfuscation. Of
course, I'm not the one who had to disentangle it all.

We've all read bad code with bad names that nonetheless "works" (except
perhaps for the occasional minor glitch). This is perhaps just one that
combines poor programming style with a mis-placed sense of humor.

~~~
Stormbringer
I agree. Tomato and Pizza aren't any less silly than Foo, Baz and Bar, and
certainly much less offensive than Fubar...

... It's not just programmers that do this either, also network admins name
their computers R2D2 and C3PO, Shodan, Skynet etc.

~~~
eftpotrm
Oh, yes......

My previous employer, you could work out the function of a server and its
platform from its name; it was embedded within the name. There were index
numbers when we had more than one which wasn't ideal, but....

My current employer, it helps if you know your nature taxonomies in some
detail. We may have more to keep track of and so more namespace clashing, but
I can't help but feel it's a suboptimal solution.

------
karamdeep
I once took over some work that was previously the domain of our most highly
paid ($150-200k a year) "architect"/contractor. Imagine my surprise when I
actually examined his code and realized that it looked like it had been
written by a student in an intro-level C101 class. At one point, I asked him
what his approach to program design was...he replied "brute force and
ignorance" and walked away laughing. We fired him shortly thereafter.

------
scrrr
This is off topic but I find it difficult to read the blog-articles from
jaquesmattheij.com . Zooming doesn't help because the text doesn't wrap
correctly. Just a suggestion for the author to change the layout of the page.

~~~
techiferous
The typography is off. The body text is written in Arial, which is not a great
choice for body text (it's better for display). When in doubt, use Verdana
(sans-serif) or Georgia (serif) for body text. Also, the font size is too
small.

Here is an example of his blog with better typography. I used 18px Georgia as
the body text instead of 12px Arial. I used Droid Sans (a nice display font)
for the blog title.

<http://i.imgur.com/jhjJA.png>

~~~
jtreminio
I was under the impression that serif fonts were best left to headlines that
are supposed to catch your attention, and that body text should always be a
serif font - and that Arial is one of the better serif fonts if you use set
the size to at least 14px and line-height to 150%.

~~~
wiredfool
You are missing the word "sans" from that comment.

The general opinion used to be that serif was better for bodytext, and sans
for title, and Arial is sans serif, but not one of the better ones.

~~~
jtreminio
Yeah, I meant sans serif for body text :)

------
jgrahamc
This story reminded me of the poor sod I met who coded for a government
department: [http://blog.jgc.org/2007/08/why-you-dont-want-to-code-
for.ht...](http://blog.jgc.org/2007/08/why-you-dont-want-to-code-for.html)

------
edge17
One semester I was TA'ing a certain course all electrical and computer
engineering students are required to take.

One student named all his variables in phonetic chinese (using the utf8
character set of course).

Another student named all his variables after superheros.

~~~
PakG1
For the Chinese guy, I wonder if the code would have been way easy to maintain
for the average Chinese developer. That would be an interesting analysis.

~~~
beilabs
I once worked in a Chinese software company on the mainland and often
maintained code written by Chinese developers.

I'm Irish and didn't appreciate their comments in Chinese, they didn't
appreciate my comments in Irish.

Once that was understood we swapped quickly over to English for all comments /
variables / declarations.

~~~
mithaler
On that note, Python's style guide, PEP 8, contains this:

"Python coders from non-English speaking countries: please write your comments
in English, unless you are 120% sure that the code will never be read by
people who don't speak your language."

<http://www.python.org/dev/peps/pep-0008/>

------
jordw
I worked with a guy a couple years ago who used the planets and nearby stars
as a version numbering scheme. For example, the first revision of a file might
be "Jupiter" and the second revision might have been called "Mars." (Of
course, he didn't use the planets in their natural order)

He also refused to use real version control or even any kind of on network
backup and insisted on using a Zip drive to back up all of the code he was
working on. Needless to say, we had an intervention that involved hiding the
Zip drive, and he quit in disgust shortly after.

------
yalforreca
I once worked on a game for the Wii using a 7 year old engine originally
developed for the PS2. The company had a high turnover rate and the code was
atrocious. The engine had been used for several games and each title
introduced a new hack in the engine. You had the tipical spaghetti with
meatballs mess with 2000+ lines functions and hacked code with comments like:
"This code is for the E3 demo of the game xxx". Once I had to extend a 1000+
line switch statement.

But the worst I saw was something like this:

struct weapon { #ifdef xxx #include xxx #else ... #endif }

------
kragen
I remember that one of the sample robots that shipped with the game CROBOTS
had all of its variables named variations on ll1l11l1, which is actually even
worse in a VGA font than it looks here.

------
motters
I came across a similar thing in the mid 1990s. The program had been written
in the late 1980s, and the original author had since died, so he couldn't be
consulted. In those days memory was scarce, so the program had been
"compacted" by removing all spaces and with all variables represented by
single characters. The original non-compacted source code had disappeared
along with its originator. For any practical purpose, the whole program was
unreadable.

------
merraksh
The OP's post and all the examples in the comments are good candidates for The
Daily WTF (<http://thedailywtf.com>).

------
wr1472
code from a 150 line long method which is part of a 6000 line class. Obviously
I can't post the actual code on here (but what it is doing isn't important in
this context).

    
    
       private XXXXXXXXXXX XXXXXXXXXXX(final XXXXXXXXXXX[] XXXXXXXXXXX, final int XXXXXXXXXXX,
              final Long XXXXXXXXXXX, final Long XXXXXXXXXXX, final int XXXXXXXXXXX, final Long XXXXXXXXXXX,
              final XXXXXXXXXXX XXXXXXXXXXX, final int XXXXXXXXXXX, final int XXXXXXXXXXX, final Long XXXXXXXXXXX,
              final XXXXXXXXXXX XXXXXXXXXXX) {
       
             if (XXXXXXXXXXX || XXXXXXXXXXX) {
                XXXXXXXXXXX
                return null;
             }
       
             final XXXXXXXXXXX
             if (XXXXXXXXXXX) {
                XXXXXXXXXXX
                return null;
             }
       
             XXXXXXXXXXX
    
          if (XXXXXXXXXXX) {
    
             XXXXXXXXXXX
             XXXXXXXXXXX
    
             final XXXXXXXXXXX
             final XXXXXXXXXXX
             if (XXXXXXXXXXX {
                for (XXXXXXXXXXX) {
                   final XXXXXXXXXXX
                   final XXXXXXXXXXX
                   if (XXXXXXXXXXX) {
                      if (XXXXXXXXXXX) {
                         if (XXXXXXXXXXX || XXXXXXXXXXX) {
                            if (XXXXXXXXXXX || XXXXXXXXXXX)
                                || XXXXXXXXXXX)) {
                               final XXXXXXXXXXX
                               if (XXXXXXXXXXX) {
                                  if (XXXXXXXXXXX) {
                                     final XXXXXXXXXXX
                                     if (XXXXXXXXXXX) {
                                        int XXXXXXXXXXX
                                        if (XXXXXXXXXXX) {
                                           if (XXXXXXXXXXX) {
                                              XXXXXXXXXXX
                                           }
                                           if (XXXXXXXXXXX) {
                                              XXXXXXXXXXX
                                              XXXXXXXXXXX
                                              XXXXXXXXXXX
                                              XXXXXXXXXXX
                                           }
                                        }
                                     }
                                  }
                               }
                            }
                         }
                      }
                   }
                }
             }
    
          } else {
    
             XXXXXXXXXXX
             XXXXXXXXXXX
             XXXXXXXXXXX
             XXXXXXXXXXX
             XXXXXXXXXXX
    
             final XXXXXXXXXXX
             final XXXXXXXXXXX
             
             if (XXXXXXXXXXX) {
                for (XXXXXXXXXXX) {
                   final XXXXXXXXXXX
                   final XXXXXXXXXXX
                   if (XXXXXXXXXXX) {
                      if (XXXXXXXXXXX) {
                         if (XXXXXXXXXXX) {
                            if (XXXXXXXXXXX)
                                || XXXXXXXXXXX) {
                               final XXXXXXXXXXX
                               if (XXXXXXXXXXX) {
                                  if (XXXXXXXXXXX) {
                                     final XXXXXXXXXXX
                                     if (XXXXXXXXXXX) {
                                        if (XXXXXXXXXXX) {
                                           final XXXXXXXXXXX
                                           if (XXXXXXXXXXX) {
                                              if (XXXXXXXXXXX) {
                                                 XXXXXXXXXXX
                                                 XXXXXXXXXXX
                                                 XXXXXXXXXXX
                                                 XXXXXXXXXXX
                                              }
                                           }
                                           final XXXXXXXXXXX
                                           if (XXXXXXXXXXX) {
                                              if (XXXXXXXXXXX) {
                                                 XXXXXXXXXXX
                                                 XXXXXXXXXXX
                                                 XXXXXXXXXXX
                                                 XXXXXXXXXXX
                                              }
                                           }
                                        } else {
                                           final XXXXXXXXXXX
                                           if (XXXXXXXXXXX) {
                                              if (XXXXXXXXXXX) {
                                                 XXXXXXXXXXX
                                                 XXXXXXXXXXX
                                                 XXXXXXXXXXX
                                                 XXXXXXXXXXX
                                              }
                                           }
                                           final XXXXXXXXXXX
                                           if (XXXXXXXXXXX) {
                                              if (XXXXXXXXXXX) {
                                                 XXXXXXXXXXX
                                                 XXXXXXXXXXX
                                                 XXXXXXXXXXX
                                                 XXXXXXXXXXX
                                              }
                                           }
                                        }
                                     }
                                  }
                               }
                            }
                         }
                      }
                   }
                }
             }
    
          }
    
          if (XXXXXXXXXXX) {
             XXXXXXXXXXX
          }
    
          return XXXXXXXXXXX
    
       }

~~~
Tiomaidh
For a second I thought you meant that all variable names were a varying number
of X's, and I almost crapped myself.

~~~
mirkules
I thought the same - if it weren't for your comment, I would still be
laughing. Brilliant!

------
endtime
I had an assignment for a security class where I did just this. We each had to
write code to print the contents of a file with 600 permissions upon entry of
the correct password. The source code, password file, and any logs were all
readable by everyone; the next project was to obtain the contents of other
students' secret files (using John the Ripper, exploiting race conditions,
etc.). So I replaced all my identifiers with the most distracting words I
could think of - superman, flashbang, lassie, sparkles, etc. If I recall
correctly, only one person in the class even tried looking for vulnerabilities
in my code.

------
amitraman1
The worst program I ever worked on was spaghetti code with HTML, Javascript,
PHP and PERL all entangled in one file. This was in 2003.

In 2010, I encountered something very similar at a well known start up. Some
things never change...

------
torial
The article and the comments here remind me of a great article on how to write
unmaintainable code:

<http://freeworld.thc.org/root/phun/unmaintain.html>

------
nadam
foodfuscator.com is available if anyone is interested. :)

------
nrkn
Oh you wanna try doing code golf, after a little while it warps your thinking
and this sort of thing starts looking reasonable :)

﻿using C=System.Console;class S{static int p,v,x,y,t=10;static void D(char
c='@'){C.SetCursorPosition(p%t,p/t);C.Write(c);}static void Main(){var
s="";for(;v<100;v++)D((s+="#### # ### ## #
"[((y=v/t)<5?y:5-y+4)*5+((x=v%t)<5?x:5-x+4)])[p=v]);p=22;for(D();;D()){v=p+new[]{-1,-t,1,t}[(int)C.ReadKey(1>0).Key-37];D('
');p=s[v]==' '?v:p;}}}

~~~
nrkn
That's from here btw <https://github.com/nrkn/SimpleRLGolf>

------
akent
Maybe with proper code review these kinds of ridiculous problems would get
caught early and stomped on rather than turning into actual problems.

~~~
chadgeidel
Honest question - how does code review work among "peers" with no seniority.
Hypothetically speaking _snicker_ say one peer likes to churn out reams of
nonsense code and the other peer is looking forward to a sense of
maintainability.

Yes, I already know your first answer: "Switch jobs".

~~~
xsmasher
If he's simply green or ignorant then experience is the cure; a few good code
reviews (yours and his) should transfer enough experience to make work less
painful.

If he's simply lazy or doesn't care... Well, all you can do is go through the
pockets and look for loose change. No amount of "process" can make a bad
employee into a good one.

~~~
chadgeidel
Thank you - I appreciate the answer. I'm not sure I will be able to apply it
however as my scenario is not quite as clear cut (although it's a little more
of #2 than #1).

------
puzz
I'll never forget when I saw a code in a production java app with lots of JSP,
SQL, jdbc, html and javascript in the same file. One of the lines was
something like:

<a href=#
onclick="document.getElementById('field').innerHTML+=parseInt(this.parentNode.parentNode.parentNode.parentNode.parentNode.parenNode.childNodes[7].childNodes[13].split('|')[3])">...</a>

------
pramanat
Reminds me of my first programming job. One of my colleagues used variables
named after baseball players.

------
wil2k
I'll summarize it by saying that one can have a lot of debugging 'fun' when
you have to maintain code that starts including all kinds of other files in
nested control structures which, in turn, reside in things like while-loops..

------
jrockway
_whatever goal this guy had with his trick it failed in a terrible way_

Not really. The company had to pull in an expensive consultant, causing it
financial damage.

------
teyc
actual variable name I have seen in production code I was trying to maintain:

TheThing

