Solo disponible en BuenasTareas
  • Páginas : 43 (10537 palabras )
  • Descarga(s) : 0
  • Publicado : 10 de diciembre de 2010
Leer documento completo
Vista previa del texto
How To Write Unmaintainable Code

Ensure a job for life ;-)

Never ascribe to malice, that which can be explained by incompetence. - Napoleon 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 tomake 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, justbe that way. Otherwise it stands the risk of being rewritten or refactored.

General Principles
Quidquid latine dictum sit, altum sonatur. - Whatever is said in Latin sounds profound. To foil the maintenance programmer, you have to understand how he thinks. He has your giant program. He has no time to read it all, much less understand it. He wants to rapidly find the place to make his change,make it and get out and have no unexpected side effects from the change. He views your code through a toilet paper tube. He can only see a tiny piece of your program at a time. You want to make sure he can never get at the big picture from doing that. You want to make it as hard as possible for him to find the code he is looking for. But even more important, you want to make it as awkward aspossible for him to safely ignore anything. Programmers are lulled into complacency by conventions. By every once in a while, by subtly violating convention, you force him to read every line of your code with a magnifying glass. You might get the idea that every language feature makes code unmaintainable -- not so, only if properly misused.

"When I use a word," Humpty Dumpty said, in arather scornful tone, "it means just what I choose it to mean - neither more nor less." - Lewis Carroll -- Through the Looking Glass, Chapter 6 Much of the skill in writing unmaintainable code is the art of naming variables and methods. They don't matter at all to the compiler. That gives you huge latitude to use them to befuddle the maintenance programmer. New Uses For Names For Baby Buy a copy of ababy naming book and you'll never be at a loss for variable names. Fred is a wonderful name, and easy to type. If you're looking for easy-to-type variable names, try or if you type with a DSK keyboard. Single Letter Variable Names If you call your variables a, b, c, then it will be impossible to search for instances of them using a simple text editor. Further, nobody will be able to guess what theyare for. If anyone even hints at breaking the tradition honoured since FØRTRAN of using i, j, and k for indexing variables, namely replacing them with ii, jj and kk, warn them about what the Spanish Inquisition did to heretics. Creative Miss-spelling If you must use descriptive variable and function names, misspell them. By misspelling in some function and variable names, and spelling itcorrectly 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. Be Abstract In naming functions and variables, make heavy use of abstract words like it, everything, data, handle, stuff, do, routine, perform and the digits e.g. , , ,and . A.C.R.O.N.Y.M.S. Use acronyms to keep the code terse. Real men never define acronyms; they understand them genetically. Thesaurus Surrogatisation To break the boredom, use a thesaurus to look up as much alternate vocabulary as possible to refer to the same action, e.g. display, show, present. Vaguely hint there is some subtle difference, where none exists. However, if there are two similar...
tracking img