A year ago, I have been maintaining a program that has been on and off for nearly 5 years, with an intuitive impression of the worst, never reading such bad code. There is no design, it is completely think of where to write. The code is very detailed, most obviously there are a lot of temporary use of intermediate variables, never define their own objects, the need for data structures, it is easy to define a list or a map to make use of. And never use generics, ignoring the warnings for IDE tools. Large sections of repeated code, never extract the method, requires similar functionality to directly copy the code snippet past, and then modify a few variables. Never use a foreach loop, preferring a while+ iterator. Most of the classes are more than 3000 rows, and most of the methods are above 150 rows. And there are no documents, or doc comments. Although there are some comments in the program, it is basically like a dream raving, unintelligible. There are large sections of commented out code, in short, very poor readability.
This project also has a significant feature, is to make every effort to increase the number of lines of code, and as far as possible to write the obscure, using a large number of typos to mislead you, so that you do not read it 200 lines of logic do not understand its meaning. Temporary variables are not only many and the name is also particularly strange, are some symbols, neither Hanyu Pinyin nor English, the case is also very casual, want to capitalize on capital, want to lowercase on lowercase, there is no rule, like being confused. The most outrageous is that there are a large segment of completely useless code, the execution of the method has no effect on the results of the methods, the program is completely normal after deletion. WTF?
This project also has an interesting place, it seems that completely do not know the Java naming convention, the class name and interface name want to capitalize on the upper case, want to lowercase in lowercase, neither camel naming law, nor underline. Spelling is odd, using English words, a few letters, or more than a few letters, in short, is deliberately disgusting you. I have no idea that Java is an object, especially a bunch of string or strhig arrays in the method. Especially like with SB (StringBuilder) of the append to himself splicing JSON string, how to spell how to spell, obviously is a string, or to split into several append splicing. Sometimes this stitching process spans hundreds of lines of code. Especially like to play with the SQL, and the points are very open, there is no relationship between the first to spell a few conditions, and then do something else, in the sudden spell a table name, and then spell a few conditions, the process pulled very open very atmosphere, in short, all the stitching should be at least across hundreds of lines.
In fact, I think it's useless to do any patching work on this code basis. Just as let Lu Xun to modify the composition of elementary school students, let Wang Xizhi to modify Mao Xinyu calligraphy, let food god to make a bubble of dog excrement made delicious. The best thing to do is to redo it. Note that redo is not refactoring. Refactoring also has to have a foundation, not what kind of code can be reconstructed, at least to the basic correct.
This project has made me more aware of the role of the framework, and I have been thinking, what if the project uses sping? Because spring has a good JDBC package, good MVC encapsulation, probably won't let the program become this way. The framework can limit the damage of the horizontal poor programmer. I don't think my boss is aware of the problem. Because he is too high, he always feels that the function of our project is very simple. And he attaches great importance to the design of the data model, that the data model is the core of the system. He cannot be said to be wrong in this understanding. But in my opinion, a project, his aspects are actually very important, and the most need to care about is the quality of the code. Your data model design is good, no good application, can not be reflected. The application layer is actually the most valuable place in the system. Because the data is only raw materials, no good data can not be used to support the use of the role.
Not paying attention to code quality is a common problem in many software companies. We all like the design with the hype, and the flashy features, but never care how the implementation is done. It is also never thought that the implementation is a very technical content of the work. This mistaken understanding destroys countless fancy designs, ending countless companies and dreams of entrepreneurship. In fact, success is always from down to Earth, must pay attention to every detail.
The role of the procedural framework