How to Write Unmaintainable Code

Share any hilarious IRC quotes, pictures, jokes, and more here!
Forum rules
- NO nudity/pornography. NO racism. NO offensive material.
- Posting these may result in warnings and/or possible ban!
- Please abide by the rules: viewtopic.php?f=126&t=4355

How to Write Unmaintainable Code

Post by msbachman on Tue May 24, 2011 5:58 pm
([msg=57703]see How to Write Unmaintainable Code[/msg])

This had me rolling on the floor.

Some gems:

Never document the units of measure of any variable, input, output or parameter. e.g. feet, metres, cartons. This is not so important in bean counting, but it is very important in engineering work. As a corollary, never document the units of measure of any conversion constants, or how the values were derived. It is mild cheating, but very effective, to salt the code with some incorrect units of measure in the comments. If you are feeling particularly malicious, make up your own unit of measure; name it after yourself or some obscure person and never define it. If somebody challenges you, tell them you did so that you could use integer rather than floating point arithmetic.


Declare every method and variable public.[...]If God didn't want us to use global variables, he wouldn't have invented them. Rather than disappoint God, use and set as many global variables as possible. Each function should use and set at least two of them, even if there's no reason to do this. After all, any good maintenance programmer will soon figure out this is an exercise in detective work, and she'll be happy for the exercise that separates real maintenance programmers from the dabblers.


Packratting
Keep all of your unused and outdated methods and variables around in your code. After all - if you needed to use it once in 1976, who knows if you will want to use it again sometime? Sure the program's changed since then, but it might just as easily change back, you "don't want to have to reinvent the wheel" (supervisors love talk like that). If you have left the comments on those methods and variables untouched, and sufficiently cryptic, anyone maintaining the code will be too scared to touch them.


Plenty more. Linked to by /r/programming.

-- Tue May 24, 2011 6:04 pm --

Let's start off with probably the most fiendish technique ever devised: Compile the code to an executable. If it works, then just make one or two small little changes in the source code...in each module. But don't bother recompiling these. You can do that later when you have more time, and when there's time for debugging. When the hapless maintenance programmer years later makes a change and the code no longer works, she will erroneously assume it must be something she recently changed. You will send her off on a wild goose chase that will keep her busy for weeks.
"I'm going to get into your sister. I'm going to get my hands on your daughter."
~Gatito
User avatar
msbachman
Contributor
Contributor
 
Posts: 685
Joined: Mon Jan 12, 2009 10:22 pm
Location: In the sky lol
Blog: View Blog (0)


Re: How to Write Unmaintainable Code

Post by sanddbox on Tue May 24, 2011 8:22 pm
([msg=57710]see Re: How to Write Unmaintainable Code[/msg])

A classic. The last one about pre-compiling and changing the code was the best. I think it would take me hours to figure out.
Image

HTS User Composition:
95% Male
4.98% Female
.01% Monica
.01% Goat
User avatar
sanddbox
Expert
Expert
 
Posts: 2337
Joined: Sat Jul 04, 2009 5:20 pm
Blog: View Blog (0)


Re: How to Write Unmaintainable Code

Post by pretentious on Tue May 24, 2011 9:34 pm
([msg=57711]see Re: How to Write Unmaintainable Code[/msg])

That is really awesome.
Exploit Compiler Name Length Limits
If the compiler will only distinguish the first, say, 8 characters of names, then vary the endings e.g. var_unit_update() in one case and var_unit_setup() in another. The compiler will treat both as var_unit.

I liked this one. Hadn't thought about it like that
Goatboy wrote:Oh, that's simple. All you need to do is dedicate many years of your life to studying security.

IF you feel like exchanging ASCII arrays, let me know ;)
pretentious wrote:Welcome to bat country
User avatar
pretentious
Poster
Poster
 
Posts: 459
Joined: Wed Mar 03, 2010 12:48 am
Blog: View Blog (0)


Re: How to Write Unmaintainable Code

Post by fashizzlepop on Tue May 24, 2011 10:08 pm
([msg=57717]see Re: How to Write Unmaintainable Code[/msg])

Bedazzling Names

Choose variable names with irrelevant emotional connotation. e.g.:
marypoppins = (superman + starship) / god;
This confuses the reader because they have difficulty disassociating the emotional connotations of the words from the logic they're trying to think about.


Haha. YES.
The glass is neither half-full nor half-empty; it's merely twice as big as it needs to be.
User avatar
fashizzlepop
Developer
Developer
 
Posts: 2304
Joined: Sat May 24, 2008 1:20 pm
Blog: View Blog (0)



Return to LULZ

Who is online

Users browsing this forum: No registered users and 0 guests