How good programmers deal with bad code

Source: Internet
Author: User

How good programmers deal with bad code

Perhaps your bad line of code has never been written. This is possible, but in reality it is not possible.

The reality is that, like all the other programmers on the planet, you'll produce code for security breaches, UI element offsets, and so on. This does not mean that you are a bad developer. Just because you are human--a creature that inevitably makes mistakes.

It is this "human" flaw that every developer has that drives good developers to take on the weaknesses of their code and underlying infrastructure and be prepared to act in a planned manner. Here's what they're going to do.

650) this.width=650; "class=" AlignCenter size-full wp-image-25140 "title=" Good-programmer-deal-bad-code "src=" http:/ /www.dexcoder.com/images/201536/dqpbb7j8wbbc9ipb.jpg "height=" 411 "width=" 660 "/>

Assume

A few years ago, Netflix open up other parts of Chaos Monkey and simian Army (Simian Army is a set of tools for managing cloud-based software). Essentially, the Chaos monkey is scoped to the Amazon Web Services infrastructure and is able to terminate instances at will. Fundamentally, it's a way to prepare for the worst by creating the worst possible scenario.

As Netflix's Cory Bennett and Ariel Tseitlin wrote on the blog at the time of issue, "The code will fail, and the less you want to fail or not be prepared, the more unavoidable it will be." If your application doesn't tolerate instance failures, would you like to be summoned 3 o'clock in the morning or in the office all night? ”

Using unpredictable methods to simulate failures, Netflix forces a focus on infrastructure resilience. Instead of assuming the best scenario, you might as well make a worst-case plan. So that we can happily move on to the next process.

Test

We've talked about a great way to improve infrastructure, so what about code?

Jeff Atwood, a programmer's answer is: "You need to toss your code." "he wrote:

I believe that a key turning point in every professional programmer's career is when you realize that you are your greatest enemy and that the only way to mitigate this threat is to accept it. Treat yourself as the biggest enemy. Break your user interface. Break your code. Toss your software.

In practice, this means that "programmers need at least some understanding of common mistakes, but many programmers tend not to do so, or even to reverse." "This means that your responsibility as a" God of programming "also includes being the" God of testing "and actively eliminating errors through" tossing "the code.

Andre Medeiros added that we should "keep improving" the debugs because developers need to do more with their code.

"To prevent bugs, the code you write makes it easy for any programmer to find." In order to fix the bug, you have to understand your code. To understand the code in a sophisticated way, you need to enumerate and validate your assumptions, and if necessary, you need to build debugging tools. ”

Skyscrapers on the slums

Of course, one of the biggest problems with our code is that it inherits so many other code. Especially in established enterprises, we often build on the old code, resulting in a variety of subsequent extension issues.

Here is a wonderful description of Zeynep Tufekci:

Compare it to building a house-and say you're going to build the second floor on the ground floor you've built. But when the house was first built, it did not build well, and you did not know which side was the load-bearing wall. You can only guess as much as possible and then build a floor-with your fingers. And then you do it. Many of the old software systems that control the critical parts of infrastructure are running like this. It does work for a certain period of time, but the construction of each new floor means that more loopholes are added. We're building the slums in the code--and still in the quake zone.

Obviously, we are helpless to improve this situation unless we are committed to the removal of technical debt.

But maybe, just maybe, in the process of willingly tossing code, you will find that eliminating technical debt is so important.


Article source "It Blue Panther"

More Boutique Articles: http://www.itlanbao.com/preview.aspx#1,0

How good programmers deal with bad code

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.