6 Computer Science Monitor set
Programmers often have to convert time units; e.g. a program can process 100 records per second, how long does it take to process 100w? With division, you know it takes 100,000 seconds, 3,600 seconds per hour, almost 3 hours, and how many seconds a year? If I tell you directly 3.155x10^7 seconds, you may soon forget; In fact, it is easy to remember this, under the constraint that the error does not exceed 0.5%: πThe second is a nano-century--tom Duff laboratory [Nano1xTen
? 9 ]Therefore, if the program to run 10^7 seconds, it is necessary to wait for 4 months;
1985Feb "ACM Communication" to the reader to collect relevant proverbs for calculation; Some of the readers ' contributions are uncontroversial, e.g. the Duff law is a very convenient method of memory constants; And the following is not the absolute number in the law of the Program test method (regression test method to save the old version of the input/output data to ensure that the new version of the program can produce the same output); Regression test can halve the test interval--larry Bernstein Institute of CommunicationsBernstein's point of view is that the number may be 30% or 70%, but it is certain that these tests save development time;
there are problems with less quantitative advice, and I believe everyone will agree;Heart Grow fonder wins the wedding; --Anonymousbut also saidthe eyes are gone, the heart is not bored; --AnonymousThe last sentence applies to everyone, but not to the words themselves; There are similar contradictions in many proverbs in this chapter. Although every word has its truth, it should be treated with some reservations; About the source of proverbs, have to declare; The name of Proverbs is basically the first person to send this sentence to me; In some places I have listed earlier references and the author's units; I know that I am sorry for those who first uttered this sentence, can only use the following sentence to express regret: plagiarism is the most sincere compliment--Anonymous
6.1 EncodingIf you haven't figured it out yet, use brute force arithmetic.--ken Thompson, Bell Labs
Do not use the inverse sine and inverse cosine functions--Always use graceful identities, or calculate vector dot product to better solve these problems--jim Conyngham, Arvin/calspan Advanced Technology Center
When storing the year in the date, use the four-digit number: The millennium is almost there.--david Martin, Norristown, Pennsylvania
Avoid asymmetric structures--andy Huber, Data General Corp.
The faster the code writes, the slower the program runs.--roy Carlson, University of Wisconsin
If you can't write anything in English, you don't expect to write it in code.--peter Halpern, New York State Brooklyn
Attention to detail--peter Weinberger, Bell Labs
If the code and comments are inconsistent, it's probably both wrong.--norm Schryer, Bell Labs
If you find that there are too many special cases, you must be using the wrong method.--craig Zerouni, Computer FX Company (London, UK)
Figure out the data structure first, the rest of the program is self-existing--david Jones, al-Holland
6.2 User InterfaceThe "least surprising principle" to make the user interface style consistent and predictable as much as possible--Several readers put forward
Computer-generated input often overwhelmed a program that was originally designed to accept manual input--dennis Ritchie, Bell Labs
20% of the manually filled forms contain bad data--vic Vyssotsky, Bell Labs
80% of the form will ask you to answer questions that are not necessary--mike Garey, Bell Labs
Do not let users provide information that the system already knows--rick Lemons, Cardinal Data Systems Ltd.
80% of all datasets, 95% of the amount of information can be expressed in a clear graph--william S. Cleveland, Bell Labs
6.3 CommissioningOf all my program errors, 80% is a syntax error; The remaining 20% miles, 80% is a simple logic error; In the remaining 4%, 80% is a pointer error; Only the remaining 0.8% is the difficult question.--marc Donner, IBM Watson Research Center
Finding and correcting errors during the system testing phase is twice times more than the developer's own effort to complete the work; And when the system has been delivered to find and fix an error, more than the system testing phase 9 times times the effort; So, keep the developers in the unit test.--larry Bernstein, Bell Communications Research Institute
Do not stand the debugging program; That will cut your patience in half, and all you need is concentration.--dave Storer, Iowa State Cedar Rapids
Don't get too deep in the notes--the comments are likely to mislead you, and all you have to debug is code.--dave Storer, Iowa State Cedar Rapids
The test can only prove that the program has errors and cannot prove that the program is not error--edsger W. Dijkstra, University of Texas
Every new user of the new system may find a new type of error--brian Kernighan, Bell Labs
If it's not bad, don't fix it.-Ronald Reagan, Santa Barbara, California
"Maintainer's motto" If we don't have the ability to fix it, we'll tell you it's not bad at all.--walt Wei, U.S. Army Lieutenant Colonel
The first step in correcting a program error is to reproduce the error first--tom Duff, Bell Labs
6.4 Performance"The first rule of program optimization" Do not optimize the second law of Program optimization-for experts only "or not to optimize--michael Jackson, Michael Jackson Systems Ltd.
For fast algorithms, we can always replace them with some algorithms that are similar in speed but easier to understand.--douglas W. Jones, Iowa University
On some machines, the indirection is slower than the base address, so put the most common members of the struct or record in front--mike Morton, Boston, Massachusetts
In a non-I/O intensive program, more than half of the running time is spent on less than 4% of the code--don Knuth, Stanford University
Before you optimize a program, use the Performance monitoring tool to find the program's "Hot Spot"--mike Morton, Boston, Massachusetts
"Law of Code Conservation" When you turn a page of code into a few simple instructions to speed up, do not forget to add comments so that the line number of the source code remains a constant--mike Morton, Boston, Massachusetts
If the programmer himself simulates implementing a construct faster than the compiler itself implements that construct, the compiler's author is too unsuccessful.--guy L. Steele, Jr., Tartan Laboratory
To speed up an I/O intensive program, consider all I/O first; Eliminate unnecessary or redundant I/O and make the remaining parts as fast as possible;--david Martin, Norristown, Pennsylvania
The fastest I/O is not I/O--nils-peter Nelson, Bell Labs
The cheapest, fastest, and most reliable computer components don't exist at all.--gordon Bell,encore Computer Co., Ltd.
Most of the assembly language has a cyclic operation, with a machine instruction for a comparison and branch; Although this directive is designed for loops, it can often be useful when doing a common comparison, and it is very effective--guy L. Steele, Jr.,tartan laboratory
Compiler author's motto-Optimization steps It's not your fault that a program that is wrong is getting worse.--bill McKeeman, Wang company
Electricity travels one foot per nanosecond.--grace Murray Hopper, Brigadier General, United States Admiral
Lisp programmers know the value of everything, but they don't know the cost of computing that stuff.--alan Perlis, Yale University
6.5 Documentation"Negative test" if a sentence in turn is inevitable, then there is no need to put this sentence into the document--bob Martin, t company
When you're trying to explain a command, a language feature, or a piece of hardware, let's start by explaining what it's going to solve.--david Martin, Norristown, Pennsylvania
"One page principle" One {specification, design, process, test plan} If you can't write on a page of 8.5 inch x11 inch paper < 1 216mm x 279mm Letter paper > read it, then there's no way anyone can understand that.--mark Ardis, Wang company
The work on paper is not over, and the whole job is not over yet.--Anonymous
6.6 Software ManagementThe structure of the system reflects the structure of the organization that constructs the system.--richard E. Fairley, Wang company
Don't insist on doing the useless things.--Anonymous
The first 90% of the "90-90 rule" code takes up 90% of the scheduled development time, and the remaining 10% code costs 90% of the scheduled development time < 2 because programmers have difficulty anticipating difficulties beforehand, so development time is often extended almost twice (90%+90%=180%), Many software companies make development plans accordingly, doubling the reasonable estimated development time >--tom Cargill, Bell Labs
Only less than 10% of the code is used to complete the surface of the program, the rest of the work in the processing of input and output, data validation, structure maintenance and other housework--mary Shaw, Carnegie Mellon University
The right judgment comes from experience, but experience comes from wrong judgment.--fred Brooks, University of North Carolina
If someone basically does what you want to do, you don't need to write a new program yourself; If you can't write, use as much of your existing code as you can.--richard Hill, Hewlett-Packard Corporation (Geneva, Switzerland)
The code can be borrowed to borrow--tom Duff, Bell Labs
Maintaining a good relationship with the customer can double the productivity--larry Bernstein, Bell Communications Research Institute
The transfer of an existing mature program to a new language or platform requires only one-tenth of the original development time, manpower, cost--douglas W. Jones, Iowa University
Those things that have been done quickly by hand, do not use the computer to do--richard Hill, Hewlett-Packard Corporation (Geneva, Switzerland)
Those problems that can be solved quickly with a computer, don't do it by hand.--tom Duff, Bell Labs
I want to write a program that is not just a program, but a program that can write programs--dick Sites, Dec company
The "Brooks prototype law" plans to abandon a prototype, which is a matter of sooner or later.--fred Brooks, University of North Carolina
If you're going to abandon a prototype at the beginning, I'm afraid you'll have to abandon two--craig Zerouni, Computer FX Company (London, UK)
Prototype method can reduce system development workload by 40%--larry Bernstein. Bell Communications Research Institute
"The law of the Thompson Telescope Apprentice" first makes a 4-foot Lens (telescope) and then a 6-foot lens, which is more time-saving than just making 6-foot lenses.--bill McKeeman, Wang company
Working hard doesn't replace understanding.--h. H. Williams, Oakland, California
Do the hardest part of doing things first; If the hardest part can't be done, why waste time on a simple part? Once the difficult place is settled, then you are in the sight of victory; Doing things should be the simplest part first; The simple part you start with may be difficult to do; Once you have done the simple part, you can conquer the hardest part. --al Schapira, Bell Labs
6.7 Other"Sturgeon law-equally applicable in science fiction and computer science" there is no doubt that 90% of the software is useless; This is because for anything, 90% of them are useless;--mary Shaw, Carnes-Mellon University
To lie to a computer is to be punished.--perry Farrar, Maryland
If the system does not require reliable, it may do anything--h. H. Williams, Oakland, California
A person's constant is another person's variable--susan Gerhart, Microelectronics and Computer Technology Corp.
One person's data is another person's program.--guy L. Steele, Jr., Tartan Laboratory
The Kiss law works in the simplest and most stupid way.--Anonymous
6.8 PrincipleSee here, you will certainly accept the following this good motto: Don't trust those seemingly clever laws--joe Condon, Bell Labs
6.9 ExercisesAlthough each maxim uses only a few words, most of them can be extended to a large extent (e.g. can be extended to an undergraduate thesis); The following questions tell us how to extend these proverbs;Let the program run, and then consider how to get the program to run fast.--bruce Whiteside, Illinois State, Woody Ridge.Expand Other proverbs in a similar way;1.) Re-articulate proverbs in a more precise language; The above example can be expanded to read:Before determining the correctness of the program, please ignore the efficiency of the program, or if the program does not work, then it is useless to run faster; After all, an empty program that always gives false conclusions does not take time at all;2) Give a small and specific example to support your presentation; Kernighan and Plauger in the "Elements of programming Style" in the 7th chapter of the code from a program to cut out 10 lines of tangled and difficult to understand codes; This piece of code around people saves a comparison, but introduces a small error; By "wasting" time to save the comparison, they put 10 lines of obscure code into two lines of code at a glance; From this practical lesson, they summed up this truth:Desire fast, first seek right;3) Find these proverbs for large-scale programming "combat stories"A) I am glad that this motto is helpful for project practice; E.g. 1.2 describes several examples, performance monitoring of the system points to the key points of the program execution, and then can be easily adjusted to improve the performance of these key points; b) Ignoring these proverbs can lead to disastrous results; The 1960s, Vic Vyssotsky modified a FORTRAN compiler source code, want to make an original correct program faster, but thus introduced a program error; Two years in the past, this program error has not been found, because in 100 000 times the compilation has not even called this program; Vyssotsky spent more time on this immature optimization than just wasting time, because he made an error in an otherwise good program; (however, the story educates Vyssotsky and Bell Labs generation programmers) 4) please evaluate these proverbs; What are "unchanging truths" and which, in some cases, are misleading?once I said to Bill Wulf of the Tartan Lab, "If the program doesn't work, it's not working any faster"; He gave us an example of a document formatter that we all use; Although the program is significantly faster than its predecessor, it is sometimes too slow to tolerate, Compiling a book, for example, takes several hours; Wulf won the debate with the following argument "As with all other large systems, this program has 10 minor procedural errors on record, and next month it will have 10 new minor bugs that we find out, and if giving you the opportunity to choose, to solve the 10 minor errors now known, or make the program 10 times times faster? "--< programming Zhu Ji Nanxiong cont. >
---YCR---
Computer Science Monitor set--< programming Zhu Ji Nanxiong cont. >