5 Replies Latest reply on Sep 6, 2002 6:14 AM by phykell

    How to Write Unmaintainable Code

      Long, long time ago I found this essay by Roedy Green on how to write unmaintainable code. Today I stumbled upon it again on the net: it is still as funny as ever.

      http://mindprod.com/unmain.html

      In the interests of creating employment opportunities in the Java programming field, I am passing on these tips from the masters on how to write code that is so difficult to maintain, that the people who come after you will take years to make even the simplest changes. Further, if you follow all these rules religiously, you will even guarantee yourself a lifetime of employment, since no one but you has a hope in hell of maintaining the code. Then again, if you followed all these rules religiously, even you wouldn't be able to maintain the code!

      You don't want to overdo this. Your code should not look hopelessly unmaintainable, just be that way. Otherwise it stands the risk of being rewritten or refactored.

        • 1. Re: How to Write Unmaintainable Code

          Ahh, reminds me of the infamous Catalogue entity in J2EE training.

          Creative Miss-spelling
          If you must use descriptive variable and function names, misspell them. By misspelling in some function and variable names, and spelling it correctly in others (such as SetPintleOpening SetPintalClosing) we effectively negate the use of grep or IDE search techniques. It works amazingly well. Add an international flavor by spelling tory or tori in different theatres/theaters.

          • 2. Re: How to Write Unmaintainable Code

            My favorite:

            Mix Languages
            Randomly intersperse two languages (human or computer). If your boss insists you use his language, tell him you can organise your thoughts better in your own language, or, if that does not work, allege linguistic discrimination and threaten to sue your employers for a vast sum.

            • 3. Re: How to Write Unmaintainable Code
              joelvogt

              I like this one

              Dummy Interfaces: Write an empty interface called something like "WrittenByMe", and make all of your classes implement it. Then, write wrapper classes for any of Java's built-in classes that you use. The idea is to make sure that every single object in your program implements this interface. Finally, write all methods so that both their arguments and return types are WrittenByMe. This makes it nearly impossible to figure out what some methods do, and introduces all sorts of entertaining casting requirements. For a further extension, have each team member have his/her own personal interface (e.g., WrittenByJoe); any class worked on by a programmer gets to implement his/her interface. You can then arbitrary refer to objects by any one of a large number of meaningless interfaces!

              • 4. Re: How to Write Unmaintainable Code
                hbaxmann

                ... and you are able this way to _really_use_ cvs versioning and logging features in conjunction with xdoclet to dive deeper and deeper ...

                • 5. Re: How to Write Unmaintainable Code
                  phykell

                  My favourite is never to use your own name on your code. Always use the name of the last programmer that left the company. That way, they can never find who actually wrote the code! :)