There are two types of Legacy programs

Source: Internet
Author: User

In the definition of programmers, Ling Hu replied, and his later article, "[essay] Testing, debugging, and software improvement (talk with hunters) all talked about a very important issue, that is: LegacyCode.

Ling Hu believes that the legacy code"ToSufficient respect". To a certain extent, this is true, especially when you are new to these codes, no matter how abuse they are, but they are gradually formed after a long time, making a big change to it is likely to go back.

Of course, respect is not absolute, but it should be changed. I think there are at least two types of legacy code:

I
But gradually improved as the demand changes or the understanding of the demand goes deeper. Or not very good at the beginning, but with the step-by-step optimization and improvement, it gradually gets better. Although such code does not match at first glance
But after careful analysis, it is actually a last resort-for example, to reduce the impact of changes, or to consider performance (sometimes for performance reasons, you have to sacrifice a lot of Clarity ).

The other is that it is not good at the beginning, and in order to adapt to the changes in demand or understanding of the demand, it is achieved with a variety of options. Or it may be better at the beginning, but the code is getting worse and worse as the demand changes without eliminating the bad taste in time.

Of course, the two legacy codes have at least one thing in common:Can meet existing needs. You don't need to discuss the spam code that cannot be implemented even with existing requirements.

We have nothing to say about the previous code, so we must respect it. We recommend that you add this lesson to it if it does not have a unit test. For the latter type of code, there is a need for improvement.

However, changes are highly risky, so I emphasize TDD. But"No silver bulletThe teachings should always be kept in mind, not just TDD, but agile methods and heavy methodologies. People are always the most important factor in software development. Ling Hu's reply in "test-first agile method" is correct. For new users, TDD may not even be more advantageous than direct coding.

But I still want to encourage TDD, because it is inevitable to modify code, whether it is others' or their own. Start TDD, need to haveCourageWithout TDD, you can change the code.Reckless.

Ling Hu said:

In fact, the so-called "Modern Theory" may not be much better than the old theory. For a person, it is important for him to consider a theory (either modern or ancient) become an effective weapon. A person who has mastered an effective weapon is much more useful than a person who has mastered countless new theories but cannot use them effectively.

Effective use is the most important thing.

Well, we must clarify one thing to avoid misunderstanding: "Modern Theory" is much better than "ancient theory. It is developed based on the shortcomings of Ancient theories. But what I want to say is, "Modern
Theory is not a pie falling from the sky. It is not mysterious in itself, because modern theory also analyzes, criticizes, summarizes, and develops Ancient theories. So it's not that we have mastered modern theories.
What an amazing thing, you can look down on those who are not mastered. The key is to make good use of it.
2005 12 14-by link )--

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.