

Art of writing unmaintainable code. - amirdhagopal
http://thc.org/root/phun/unmaintain.html

======
0x12
What a fantastic piece. Check the bottom for the sign-off: "People paid no
attention when I harped about how to write __maintainable code. I found people
were more receptive hearing all the goofy things people often do to muck it
up."

You can tell that he's not talking about this from a theoretical point of view
and that the majority of those samples were encountered in real life code.

I've seen a couple of them myself over the years (and I've been guilty of at
least a few, especially in the beginning). To be able to compile such a vast
set of examples must point to a very colorful career.

The best part of the whole thing is that you can read it two ways, invert
every line in meaning and you get a pretty good naming conventions and coding
standards guide.

------
gnoupi
The most amazing thing of this essay is that somehow, I know people who never
read it, yet seem to know it by memory.

------
FuzzyDunlop
The Drupal developers must have used this as a coding bible when they came up
with the idea of shoving absolutely everything in multi-dimensional arrays.

~~~
div
I love it when the output of print_r is larger than the html of a fully
rendered page, by virtue of the html being included in the array you are
printing.

~~~
FuzzyDunlop
The output of print_r on a single form on a page could probably stretch to the
moon and back if each line was laid one after the other.

Recursively, of course.

------
huhtenberg
Woah, learned something new today :) An alternative _break_ construct -

    
    
      switch (n)
      {
      case 1:
          p = "one";
          if (0)
      case 2:
          p = "two";
          if (0)
      case 3:
          p = "three";
          break;
      }

------
ghc
Most of this is true, but I hate to have people continue to give hungarian
notation a bad name when idiomatic use of it is quite a lot better than the
naïve use of it decried here.

As an aside, do any other Haskell hackers find that single letter variable
names are a lot more usable than in other languages? x:xs, y' and their ilk
seem more readable than in other languages and often more readable than long
variable names in Haskell.

~~~
ajanuary
They did qualify that this isn't an example of the original intent of
Hungarian Notation

"The following tips will help you corrupt the original intent of Hungarian
Notation"

But it's not really that clear if you've not heard what proper Hungarian
Notation is before.

------
reidbradford
While true, the article feeds an odious appetite for righteous superiority all
too common among technical people.

<http://www.youtube.com/watch?v=5TzHbcXYwI4>

~~~
rvkennedy
Agreed - and while most of this is obvious, and some insightful, some of it is
just baseless opinion: "Never underestimate how much havoc you can create by
indenting with tabs instead of spaces..."

Conversely, never underestimate how much havoc you can create by using spaces
for indentation. With tabs, the level of indentation is clear and atomic. With
spaces, it is arbitrary, and, wait for it...

 _hard to maintain_

~~~
reginaldo
As someone who, despite being 24 years old, learned to type on a (mechanical!)
typewriter, I don't like tab for indentation on the basis that, for me, tabs
have a very specific meaning:

 _Carriage (or cursor, if you prefer), go to the next tab stop_. [2]

For typewriters it means to go "literally" to where the next stop is. For text
editors (at least for emacs)[1], it means to _insert as many spaces as needed
so the next column on the current line matches with the last non-space column
on the previous line_.

So, in the same way I use the _table_ tag for tabular data in markup, I use
the tab key for _tabular text_.

[1] <http://www.jwz.org/doc/tabs-vs-spaces.html> [2]
<http://en.wikipedia.org/wiki/Tab_key#Origin>

~~~
LearnYouALisp
Was this an electro-mechanical typewriter or a purely mechanical one?

~~~
reginaldo
I started on a purely mechanical, but then, as the course progressed, changed
to an electro-mechanical one.

------
tomelders
" _Randomly capitalize the first letter of a syllable in the middle of a word.
For example ComputeRasterHistoGram()._ "

I do this by accident all the time.

And this is the funniest thing I've read on the internet all year:

" _Make sure that every method does a little bit more (or less) than its name
suggests. As a simple example, a method named isValid(x) should as a side
effect convert x to binary and store the result in a database._ "

~~~
pkteison
I wish I still thought that was funny, instead of just painful. I can't tell
you how many times I have been burned on Is or Get methods with incredible
side effects, like IsValid also automatically logs the user in, creates them
if they don't exist, and retrieves their birthday from the database to make
sure it's valid. (edit: yes, that really happened.)

------
amirdhagopal
Quidquid latine dictum sit, altum sonatur. - Whatever is said in Latin sounds
profound.

Common problem found in coding, attempting to do things in a hifi way, when
simple things server the purpose.

------
rgc4
I finally found the manual that scientists used to write their code!

~~~
LearnYouALisp
I remember a physics student ahead of me lamenting the fact that scientists
had written their own software (ROOT & Geant). He said it was hard to use.

------
dustingetz
i sorta think this is dumb. these are all true, but superficial. this piece
doesn't touch on any real, deeper reasons that well-intentioned code is
unmaintainable, like excessive and unnecessary state & implementation
inheritance.

~~~
kalid
I agree -- I hate these "negative" lists because there's an infinite number of
ways to screw something up. Enumerating them isn't helpful.

~~~
nitrogen
Enumerating some of the ways to screw things up may be helpful in that it
allows a reasonably intelligent reader to intuit the underlying connections
and apply that intuition to a broader set of coding circumstances.

~~~
dustingetz
sure, i agree. i just think things like weak names, hungarian notation, brace
preferences and lispy one-liners have no objective impact on the complexity of
a system.

------
lani
>> "People paid no attention when I harped about how to write __maintainable
code. I found people were more receptive hearing all the goofy things people
often do to muck it up."

\- when we're told to write maintainable code :: MY CODE IS GOOD !! I'm sure
Bob/Igor/Venkatachalapathy (coworkers) understand it just fine

\- when we're told - these are the tricks of unmaintainable code .. :: HOLY
COW !!! so THIS is what Bob/Igor/Venkatachalapathy has been using against me
!! no wonder my promotion's been slow

------
afhof
Most of the "tips" in this article seem to suggest choosing a bad naming
scheme or intentionally misnaming variables / functions. I can't imagine it
would be that hard to put the code into an AST and work with that. That would
make it easy to see where variables are used (despite losing their names). I
realize that would take extra time, but I don't suspect it would be quite as
bad.

I'm more afraid of the "Use threads With Abandon" tip.

------
becomevocal
You literally could build a career out of this. I'm not saying that's a good
thing. But you can't argue with the amazing job stability it provides.

Also makes me think how long it takes big teams to filter out people like
this.

------
Roboprog
This list has been around for a while (10 years or so?). Still a classic,
though.

The domain suggests something else, though: "THC dot org" :-)

(What are you people, on dope?!?)

------
rowanseymour
This is fantastic - making all my students read this. English is a third
language for most of them so I'm always trying to decipher the most cryptic
method and variable names.

~~~
LearnYouALisp
What country do you work in?

------
RikardH
"In particular, in Java, make ordinary methods masquerade as constructors."

Isn't that the first item of Effective Java? Factory methods? Which is a good
thing.

------
darklajid
You know you read too much of that article if you notice that the 'Reduce,
Reuse, Recycle' advice is given twice.

Meta-obfuscation in the obfuscation guide?

------
weinzierl
I laughed hard at this one: "Optimise" JavaScript code taking advantage of the
fact a function can access all local variables in the scope of the caller.

------
gadders
I once worked with a guy that decided to give his variables names like "Bob"
and "Fred". IRONIC LOL.

