In fact, there is no such thing as the "worst code in history". If there is, it is only "worse than ever". I want to talk about this topic casually, which also originated from a discussion on Douban. In fact, it is common to be criticized for bad code when the system is complex. Of course, there are also some short code snippets that are enough to show that the author of the code is not a good person. The use of Boolean types can easily become the worst code:
There are some meaningless comments:
Even more meaningless is variable naming like this:
Some people also say that the worst code snippet should be like this:
There is also 12306.cn, which was once criticized to the point of pus flowing all over its body. The code excerpt is:
There are also bad JavaScript codes, which are too many to post. The more flexible the language, the more difficult it is to control, and the more likely you will see super bad code. Tiago Fernandez did a poll to elect the worst Java API:
Java has many frameworks and strict syntax, which is helpful in limiting programmers who want to cause damage. But if they really want to cause damage, it is impossible to limit them. I once worked on a portlet extension class with several thousand lines in total. At that time, I thought the code was bad enough. But later, I saw a stored procedure with more than 5,000 lines and a jsp page with more than 7,000 lines. I used to think that Java programmers were much less destructive than C/C++ programmers. It seems that this is not entirely true. The most common types of bad code I have encountered include the following: Some naming habits, such as the abbreviation "cptct" for method names that are almost cipher-like, are probably due to the poison of Basic. Even early versions of Visual Basic enforced some constraints on the code (such as the length of variable names, the number of variables allowed in a module, and the size of the module). Today, a colleague said that the reason why code becomes bad code is that the person who wrote the code will encounter many more problems than the person who reads the code later. Although the person who wrote the code solved most of the problems, the remaining problems are enough to make the code infamous. But I don't think so. I have seen VB code and Delphi code from a relatively old year. Although they are all used for interface development and many of the concepts are far less than today, the code is still clear and easy to understand. Some programmers say that the deadline is tight, the project is heavy, and the leader is pushing me to the point of vomiting blood every day, so I have no choice but to write bad code. There are thousands of objective reasons, and I really have nothing to say. After all, when material civilization is still very weak, it is better not to talk about spiritual civilization. However, excellent programmers have pursuits, but people are numb and always talk about project pressure. Giving a loose deadline may not make a difference. Some programmers also said that dialectical materialism tells us that everything has two sides, so we should learn the good design from bad code and take the bad design as a warning... I said, come on. Bad is bad, even shit in an ice cream cone is still shit, so why be so pretentious? Many programmers always have the urge to start over, especially when they see bad code. I used to do that too. In fact, this is dangerous. Moreover, in many cases, your rewrite may not be better than the original bad code. Maybe you can solve 30 problems, but introduce 50 new problems. Refactoring should start with small changes and modules when the business model and process are clear. It is always dangerous to make big changes. I don't admire programmers who always say they suffered so much fifteen years ago. I admire excellent programmers who can still write code that makes people feel comfortable now under the conditions and concepts fifteen years ago. Not writing bad code is to cherish life, save resources, and protect the earth. Writing good code is the quality of a programmer. There are no so many reasons to explain. |
<<: Things about the bad code you wrote
>>: Code practice of background positioning upload
On the one hand, competition for traffic is inten...
Review | Li Nannan is the vice president of Hunan...
Recently, Qionghai, Hainan A grass fire After rec...
The era of TVs selling for money solely through h...
There are many website statistics tools, such as ...
WeChat mini programs are business opportunities i...
Recently, Google suddenly released the Android 12...
According to recent news, although the United Sta...
【Software Description】 All grades can watch onlin...
Course Catalog ├──Day01 | ├──Day1 Course Concept:...
We all know that "targeting" is the bas...
MVP The disadvantage of MVC is that it does not d...
Users' following, comments, unfollowing, etc....
No matter it is an emerging industry like bike-sh...
Recently, Japan's Fukushima Daiichi Nuclear P...