Sometimes, it is necessary to write code that is completely unmaintainable to ensure job security or to get on another's nerves as vengeance. Whatever the reason, this article will show you how to write unmaintainable code.
1Do not use comments. Comments exist solely to help developers navigate through their code. Remove all comments.
- If needed, write all comments in a note document or on a sheet of paper so that you are the only one able to view your comments.
2Use variables as little as possible. Never use constants. Numbers should be valued directly in code. This will make your code very hard to modify and follow.
3Use obscure variable and method names. If you have to use a variable, no one will be able to figure out what the variable actually exists for without digging into the code if it has a very non-descriptive name. Try names such as single letters of the alphabet, or, if you are feeling particularly silly, completely unrelated nouns (such as "dog" or "cat").
4Use overly complicated solutions for simple tasks. A good way to do this is to use methods where they are unnecessary. Try to use the most complex features that the language has to offer. For example, C offers a goto command which can be used to jump around code in a very confusing manner.
5Write useless code. Create classes, methods, and files that have nothing to do with the overall function of your code.
- Use global variables as much as possible.
- You can try adding trivial comments that do not inform to annoy those who are trying to maintain your code.
- Many software obfuscators use several of these methods to deter being disassembled. If these steps can be used to deter hackers, they can be used to make code unmaintainable as well.
- Bitwise operations and bitmasks can easily throw a wrench into a coder's plans for the day. If anyone questions your use of bitwise operations, just tell them it makes the code run faster.