标签:
2015-05-26 628 Code-Tuning Techniques
——Even though a particular technique generally represents poor coding practice, specific circumstances might make it the best one to use.
——One key to writing effective loops is to minimize the work done inside a loop. If you can evaluate a statement or part of a statement outside a loop so that only the result is used inside the loop, do so.
——The sentinel technique can be applied to virtually any situation in which you use a linear search—to linked lists as well as arrays. The only caveats are that you must choose the sentinel value carefully and that you must be careful about how you put the sentinel value into the data structure.
——When you have nested loops, think about which loop you want on the outside and which you want on the inside.
——Changes in data types can be a powerful aid in reducing program size and improving execution speed.
——One example of using a supplementary index can be found in the different string-storage strategies. Visual Basic length byte is an example of augmenting a data type with an index to make certain operations—like computing the length of a string—faster.
2015-05-27 634 Code-Tuning Techniques
——Sometimes it‘s more efficient to manipulate an index to a data than it is to manipulate the data type itself. If the items in the data type are big or hard to move, sorting and searching index reference is faster than working with the data directly.
——Caching means saving a few values in such a way that you can retrieve the most commonly used values more easily than the less commonly used values.
——If you‘re using a named constant or a magic number in a routine call and it‘s the only argument, that‘s a clue that you could precompute the number, put it into a constant, and avoid the routine call.
——System routines are expensive and provide accuracy that‘s often wasted. Typical system math routines, for example, are designed to put an astronaut on the moon within 2 feet of the target.
2015-05-28 643 Code-Tuning Techniques
——Most of the so-called "transcendental" functions are designed for the worst case—that is, they convert to double-precision floating point internally even if you give them an integer argument. If you find one in a tight section of code and don‘t need that much accuracy, give it your immediate attention.
——Use named constants and literals that are the same type as the variables they‘re assigned to. When a constant and its related variable are different types, the compiler has to do a type conversion to assign the constant to the variable.
——If you find an expression that‘s repeated several times, assign it to a variable and refer to the variable rather than recomputing the expression in several places.
——Small, well-defined routines save space because they take the place of doing jobs separately in multiple places. They make a program easy to optimize because you can refactor code in one routine and thus improve every routine that calls it.
——Modern machines—and "modern" means any machine you‘re ever likely to work on—impose virtually no penalty for calling a routine. You‘re as likely to degrade performance by keeping code inline as to optimize it.
——One long-standing piece of conventional wisdom that shouldn‘t be left unmentioned is the advice that when you run into a performance bottleneck, you should recode in a low-level language.
2015-05-29 649 Code-Tuning Techniques
——The effect of each code tuning is affected by the programming language, compiler, compiler version, code libraries, library versions, and compiler settings, among other things.
——I have found that insisting on measurable improvement is a good way to resist the temptation to optimize prematurely and a good way to enforce a bias toward clear, straight forward code.
——The impact of unmeasured code tuning on performance is speculative at best, whereas the impact on readability is as certain as it is detrimental.
——Code tuning is a little like nuclear energy. It‘s a controversial, emotional topic. Some people think it‘s so detrimental to reliability and maintainability that they won‘t do it at all. Others think that with proper safeguards, it‘s beneficial. If you decide to use the techniques, apply them with care.
2015-06-01 655 How Program Size Affects Construction
——If you‘ve been accustomed to working on small projects, your first medium-to-large project can rage riotously out of control, becoming an uncontrollable beast instead of the pleasant success you had envisioned.
——The more communication paths you have, the more time you spend communicating and the more opportunities are created for communication mistakes. Larger-size projects demand organizational techniques that streamline communications or limit it in a sensible way.
问题:为什么说文档化是提高交流效率的典型方法?
——The number of errors increases dramatically as project size increases, with very large projects having up to four times as many errors per thousand lines of code as small projects.
——Productivity on small projects can be 2-3 times as high as productivity on large projects, and productivity can vary by a factor of 5-10 from the smallest projects to the largest.
——Construction becomes less predominant because as project size increases, the construction activities—detailed design, coding, debugging, and unit testing—scale up proportionately but many other activities scale up faster.
2015-06-03 657 How Program Size Affects Construction
问题:哪些活动在项目规模增长时有非线性的增长率?
——Regardless of the size of a project, a few techniques are always valuable: disciplined coding practices, design and code inspections by other developers, good tool support, and use of high-level languages.
——Lines of code and team size aren‘t the only influences on a project‘s size. A more subtle influence is the quality and the complexity of the final software.
——Development of a system is more complicated than development of a simple program because of the complexity of developing interfaces among the pieces and the care needed to integrate the pieces.
——Programmers who use their experience in building a program to estimate the schedule for building a system product can underestimate by a factor of almost 10.
——Methodologies are used on project of all sizes. On small projects, methodologies tend to be casual and instinctive. On large projects, they tend to be rigorous and carefully planned.
——While it may be true that a programmer hasn‘t selected a methodology consciously, any approach to programming constitutes a methodology, no matter how unconscious or primitive the approach is.
标签:
原文地址:http://www.cnblogs.com/yuanchongjie/p/4549651.html