[Turn] Why do programmers always write bad code? These 3 reasons

Source: Internet
Author: User

Read the original: Why do programmers always write bad code? These 3 reasons

I've been thinking lately about why we're always producing bad code as an industry.

1. Obvious reasons ...

I suddenly think of the most obvious reason is that there are good programmers, there are not so good programmers, some people have high technical level, some people are low level, someone is interested in this skill, but also some people do not want to work outside the study of other.

Well, I won't go into it.

So are there still more problems under the surface? Is there a fundamental cause of bad code? I think it's necessary to delve into it.


2. Low expectations ...

For this, it is acknowledged that what we learn in college, through self-study or books, does not match the real needs of the real world.

Therefore, it can be imagined that beginners always need to learn how to produce good code at work. We also believe that real programming knowledge can only be gained by accumulating experience. As a result, beginners even think they can write bad code!

The academics expected them to produce poor quality code, which is usually the result you will get!

Although some of the above reasoning is true, this hypothesis I am reluctant to accept, for many reasons, but mainly the following three:

Expect a low standard career starting point, which means that quality becomes an unimportant factor. The direct result of the low entry threshold is a massive influx of low-quality developers and leads to the 2nd below.

By forcing them to work with a lot of low-quality developers, we make it miserable for those who care about craftsmanship and are proud of the quality of their work.

The combination of these two factors has led us to the current situation where everyone thinks they can write code, but we trust professional developers like branded products.

We have to have a higher expectation of beginners. Which hospital would hire a doctor who had not had an operation before, or which airline would hire a pilot who would not have an emergency landing? We simply cannot accept such doctors and pilots. So why should the software industry accept low-quality programmers?

So what is the root cause of low-quality developers?

3. Programming Books

A few days ago, when I was looking for some old books I had seen before, I happened to find a few books about Java-a beginner for learning Java and another for SCJP certification. For the next topic, I will not say the specific title.

Unfortunately, the books that beginners refer to often inadvertently depict exactly what the bad code should be like.

Beginners books in any programming language are mostly full of bad code. This is true of clean Code and pragmatic programming, but these books are widely used to teach most beginners.

Some examples of bad code ...

3.1 Poorly named classes, variables, and methods

I, II, J, K for circulation; SampleChapter1 for class names; etc.

3.2 Do not separate the point of concern

The three-page-long main () method encompasses everything and is not divided into different methods according to the responsibilities.

3.3 Bad coding practices

There is no such good coding practice as including validation or exception handling. Instead, they typically use a large generic try () that contains all the code within the class: catch (Exception e) block.

Use a lot of if-else,switch,goto statements and so on.

3.4 Take a shortcut

These books also need to get rid of the "quick fix" programming style. For example, there are 10 parameters in a method that are not uncommon.

Need to do two kinds of calculations? No problem, pass a Boolean parameter, and add a if-else structure. Need to add new features? Haha, then add more code to that already up to two-page Method! Here are just a few examples of taking shortcuts.

A good way to learn programming is to master the grammar of the language, the tools needed for efficient development, and the design of the components and modules that make up the code-in this order.

Unfortunately, most books stay on the syntax without touching on the topic of tools and design improvements. Although the intent and purpose of these books is to teach the grammar of programming languages, people who read also learn coding styles and methods.

When beginners learn the code, it is important to teach them to understand that the code is written for other people to read and understand, not for the encoder.

I hope some of you will read this article, if you write a programming book in the future, please remember to write the code in the book! Learning to produce high-quality code should not be confined to expert-level books, but should be an important part of every book about programming!

How can we expect people who learn from these books to produce high-quality code when the books that scholars use to learn contain low-quality code?

Link: http://www.codeceo.com/article/3-reason-why-write-bad-code.html

English Original: 3 reasons why people Write insanely bad Code

Translation Code Agricultural Network-Xiao Feng

That's right----------------------------------the Groove-----------------------------------

Good programming habits from a bit to form, good example from the self-start

[Turn] Why do programmers always write bad code? These 3 reasons

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.