How to write unoperable code
翻 w u uTAINABLE CODE
General principle
In order to protect the programmer, you must understand how he thinks. He got your genius (original: lengthy. I don't like), he didn't have time to read all the code, don't want to understand it, he only hopes to quickly find the place he wants to modify, modify your code There will be no other unexpected side effects.
Let him look at your code through the toilet cartridge, let him only see some small part, you must guarantee that he can never get a panoramic map when he is doing this kind of work. You have to make it difficult to find what he is looking for. The most important thing is that you have to make him know that it is unsafe to ignore anything in ignore.
Programmers are often kidding peace of mind. You have to pass the smart violation of the specification at all times, forcing him to read your code with a magnifying glass.
You can get inspirations from each of the language (Feature), resulting in unmatched code, of course just proper abuse.
I will introduce some tips and tell you how to program. Let your successor admire these codes so hard to maintain, so that it takes a few years to make the easiest modifications. Further, if you follow these rules, you will make sure your rice bowl, because no one you can withstand your code, you can withstand your code. Well, then said, if you follow these rules, you may not maintain these code yourself.
You don't want to do fire, your code should not look for no maintenance, otherwise they may fall into rewriting or restructuring (
Refactoring
In the dangers.
Naming
A large number of techniques are in art in the art of variables and methods when you write unmatched codes. The compiler ignores this kind of thing, which gives you a huge free creative space to confuse the programmer.
1. "Baby's 20001 name" new usage
Buy a baby named book, you will never find the variable name. Fred is a good name and is easy to enter. If you like the variable name that is easy to enter, try ADSF or AOEU.
2. Single-character variable name
If you are named A, B, C, it is impossible to search them with a simple text editor. Moreover, no one can guess what they represent. If someone wants to break from the FørTran language, we defend us using i, J and K as the traditional habit of variables, that is, use II, JJ and KK, telling them how Spanish religious referees have deal with pagans.
3. Creative error spelling
If you have to use the descriptive variable and method name, Misspell them. By misunderstanding some variables and method names, there is a correct spelling (such as setPintleOpening, setPintalClosing), and we effectively block attempts to use the GREP (Regex tool) or IDE search technology. It has a surprising effect. At the same time, we can also add some international style, such as the spelling of Tory or Tori, for example, in different situations.
4. To abstract
In variables and method names, a large number of abstract vocabulary, such as IT, Everything, Data, Handle, Stuff, Do, Routine, Perform and numbers, such as Routinex48, PerformDataFunction, DOIT, Handlestuff, and do_args_method. 5. a.c.r.o.n.y.m.s.
Acronyms
It is abbreviation. Use them to keep your code's simpleness. The real programmer does not define abbreviations, they understand them very natural.
【】Add to【】【】
6. Synonym Dafa
In order to enrich colorful avoidance, please use the dictionary, you can find as many alternative vocabulary as possible, such as: Display, Show, Present, and more. Here the model is vaguely implied that they have subtle differences, but in fact, there is no such difference. However, if there are two similar functions truly different, you should always use the same word to describe these two functions (for example, PRINT is used to indicate "write files", "putting ink on paper" And "Print to Screen"). No matter what circumstances, someone asked you to write the vocabulary of this special project to clearly write into a vocabulary, don't kneel, because of that practice, violating the important principles of structured design - Information is hidden, it will be insufficient enough.
7. Using non-English plural
There is a VMS script [OpenVMS, is an operating system] can return Statii from various Vaxen. 【do not understand the meaning】. There is also the language of this qualification and Esperanto, Klingon and Hobbitese [to understand these lovely languages]. For PLURAL, you can use -OJ to learn from the complex form of Chinese language, PLURALOJ. You do this, which is also aimed at the world's peace.
8. Capitalisation (uppercase)
The first letter of a syllable in a word, using a random uppercase. [Capitalization is a good example], for example: ComputeraSterHistogram ().
[Computerasterhistogram calculated grating histogram]
9. Reuse of the name
As long as the usage is allowed, give the class, constructor, method, member variable, parameters, local variables to take the same name. [I specially dedicate a compilament program as an example:
Class yqj {
Yqj Yqj (YQJ Yqj) {
YQJ:
For (;;) {
IF (yqj.yqj (yqj) == yqj)
Break yqj;
}
Return Yqj;
}
}
】
Special note, in the {} block we can multiplex local variable name [Java local variables are not hidden, but in different {} blocks, in particular initialization, use multiplexing technology, is reasonable and smart -yqj2065 special Recommended] The goal is to force the maintenance programmer to check the scope of each variable carefully. It is particularly pointed out that the normal method is made with a conventional method in Java.
10. Letters with tone
The use of a tone as a variable name. For example: ... [I specially dedicate a runable program as an example:
Public class test {
Public static void main (string args []) {
INT ε = 5;
INT E = 5;
System.out.println (ε E);
}
}
The methods in the original text are very outdated, and we have to make full use of the opportunities and challenges of Unicode. Be sure to let him buy a magnifying glass. 】
......