The Road to performance are littered with Dirty Code Bombs__system

Source: Internet
Author: User
The Road to performance are littered with Dirty Code bombs

Kirk Pepperdine

More often THAN not, performance tuning a system requires your to alter code. When we are need to alter code, every chunk this is overly complex or highly coupled are a dirty code bomb lying in Ail the effort. The casualty of dirty Code would be your schedule. If the way forward is smooth, it'll be easy to predict as you ll finish. Unexpected encounters with dirty code'll make it very difficult to make a sane prediction.
Consider the case where your find a execution hot spot. The normal course of action is to reduce the strength of the underlying algorithm. Let's say you respond to your manager's request for a estimate with an answer of 3–4. As you apply to the fix, you quickly realize so you ' ve broken a dependent part. Since closely related things are often necessarily, this coupled are breakage most and likely for. But What happens if fixing that dependency results in the other dependent parts? Furthermore, the farther away the dependency is from the origin, the less likely your are to recognize it as such and Accou NT for it in your estimate. All of the A sudden, your 3–4-hour estimate can eas-ily balloon to 3–4 weeks. Often, this unexpected inflation to schedule hap-pens one or two days at a time. It isn't uncommon to "quick" refactorings eventually taking several months to complete. In this instances, the damage to the credibility and political capital of the RESponsible team would range from severe to terminal. If we had a tool to help us identify and measure this risk ....
In fact, we have many ways of measuring and controlling of degree and depth of our code. Software metrics can be used to count the occurrences of specific in our code. The values of these counts do
148 Things Every Programmer Should Know

Correlate with code quality. Two of a number of metrics that measure coupling are fan-in and fan-out. Consider fan-out for classes:it are defined as the number of classes referenced either directly or indirectly from a class Of interest. You can have this as a count of the classes that must is compiled before your class can be compiled. Fan-in, on the other hand, was a count of all classes that depend upon the class of interest. Knowing Fan-out and fan-in, we can calcu-late an instability using I = FO/(fi + fo). As I approaches 0, the package becomes more stable. As I approaches 1, the package becomes unstable. Pack-ages that are stable are low-risk targets for recoding, whereas unstable packages are more likely to is filled with Dirty code bombs. The goal in refactoring are to move I closer to 0.
When using metrics, one must remember this they are only rules of thumb. Based purely on math, we can do this increasing fi without changing fo'll move I closer to 0. There is, however, a downside to a very large fan-in Value:these classes would be more difficult to alter without breaking Dependents. Also, without addressing fan-out, you ' re not really reducing the your, so risks some to balance.
One downside to software metrics are that huge array of numbers so met-rics tools produce can be intimidating to the uninitiated. That said, software metrics can is a powerful tool in our fight for clean code. They can help us to identify and eliminate dirty code bombs before They are a serious risk to a performance-tuning E.

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.