2015-03-06 328 Unusual Data Types
——You can carry this technique to extremes,putting all the variables in your program into one big,juicy variable and then passingit everywhere.Careful programmers avoid bundling data any more than is logically necessary.
——Even if your language doesn‘t require you to use pointers,a good understanding of pointers will help your understanding of how your programming language works.
——Working with pointers successfully requires a two-pronged strategy.First,avoid installing pointer errors in the first place.Second,detect pointer errors as soon after they are coded as possible.
——By minimizing the number of places in which pointers are accessed,you minimize the possibility of making careless mistakes that spread throughout your program and take forever to find.
2015-03-07 333 Unusual Data Types
——If your code contains a complicated expression,assign it to a well-named variable to clarify the intent of the operation.
——One way to give your program a margin of error is to preallocate a memory parachute.
——You can minimize programming overhead and reduce chance of errors by creating cover routins for common pointer operations.In C++,you could use these two routines:SAFE_NEW and SAFE_DELETE.
问题:如何实现上文中提到的SAFE_NEW和SAFE_DELETE方法?
——If you can think of an alternative to using a pointer that works reasonably,save yourself a few headaches and use it instead.
2015-03-10 340 Unusual Data Types
问题:什么是智能指针?
——A program that requires many type casts probably has some architectural gaps that need to be revisited.
——Modularity,information hiding,and the associated use of well-designed classes might not be revealed truths,but they go a long way toward making large programs understandable and maintainable.
——The essence of creating programs that are larger than a few hundred lines of code is managing complexity.The only way you can intellectually manage a large program is to break it into pieces so that you only have to think about one part a time.
问题:什么情况下使用全局数据是合适的?语言纯化论者的观点有道理吗?
——If you start by making a variable global,you‘ll never make it local,whereas if you start by making it local,you might never need to make it global.
问题:使用访问程序(Access Routines)有什么好处?
——It‘s a small gain in readability,but consistent attention to such details makes the difference between beautifully crafted software and code that‘s just hacked together.
2015-03-11 347 Unusual Data Types
——If you throw all your global data into a big pile and write access routines for it,you eliminate the problems of global data but you miss out some of the advantages of information hiding and abstract data types.
——Build access routines at the level of the problem domain rather than at the level of the implementation details.
问题:访问函数如何体现出信息隐藏的优势?
——Don‘t pretend you‘re not using global data by putting all your data into a monster object and passing it everywhere.
问题:本章包含三种特殊数据类型,结构体,全局数据和指针,为什么说他们是特殊的?
2015-03-12 354 Organizing Straight-Line Code
——When statements have dependencies that require your to put them in a certain order,take steps to make the dependencies clear.
——By rewriting the code so that data is passed between the routines,you set up a clue that the execution order is important.
——Try first to write code without order dependencies.Try second to write code that makes dependencies obvious.If you‘re still concerned that an order dependency isn‘t explicit enough,document it.
问题:什么是无序代码的“就近原则”?
——As a general principle,make the program read from top to bottom rather than jumping around.
——Once you‘ve grouped related statements,you might find that they‘re strongly related and have no meaningful relationship to the statements that precede or follow them.In such a case,you might want to refactor the strongly related statements into their own routine.
问题:有哪些方法体现线性代码的依赖关系?
——Dependencies should be made obvious through the use of good routine names,parameter lists,comments,and-if the code is critical enough-housekeeping variables.
2015-03-13 364 Using Conditionals
——Put the case you normally expect to process first.This is in line with the general principle of putting code that results from a decision as close as possible to the decision.
问题:面对多种错误结果造成的深层嵌套If语句,有哪些方法可以优化其可读性?
——Coding null elses just to show that that case has been considered might be overkill,but at the very least,take the else case into account.
——By putting the most common cases first,you minimize the amount of exception-case handling code someone has to read to find the usual cases.You improve efficiency because you minimize the number of tests the code does to find the most common cases.
——Code a final else clause with an error message or assertion to catch cases you didn‘t plan for.
——If you have a long case statement-for example,a case statement that handles dozens of events in an event-driven program-order is significant.
问题:使用case语句时有哪些注意事项?
2015-03-16 375 Controlling Loops
——Using loops is one of the most complex aspects of programming;knowing how and when to use each kind of loop is a decisive factor in constructing high-quality software.
——In common practice,the loop-with-exit loop isn‘t widely used yet.The jury is still locked in a smoky room arguing about whether is‘s a good practice for production code.
——The for loop is for simple uses.Most complicated looping tasks are better handled by a while loop.
——Treat the inside of the loop as if it were a routine-kiip as much of the control as possible ouside the loop.
问题:关于循环入口,有哪些注意事项?
——Keep loop-initialization statements with the loop they‘re related to.If you don‘t,you‘re more likely to cause errors when you generalize the loop into a bigger loop and forget to modify the initialization code.
问题:为什么在合适的情况下,更偏好for循环?
——Reserve the for loop header for loop-control statements-statements that initialize the loop,terminate it,or move it toward termination.
2015-03-17 384 Controlling the Loop
——As a general rule,the variables you initialize before the loop are the variables you‘ll manipulate in the housekeeping part of the loop.
——Loops should be like routines in that each one should do only one thing and do it well.
——If it seems inefficient to use two loops where one would suffice,write the code as two loops,comment that they could be combined for efficiency,and then wait until benchmarks show that the section of the program poses a performance problem before changing the two loops into one.
问题:在不同情况下,如何让循环结束条件更明显?
——When you set up a for loop,the loop counter is off limits.Use a while loop to provide more control over the loop‘s exit conditions.
——A proliferation of breaks raises the possibility that the loop could be more clearly expressed as a series of loops rather than as one loop with many exits.
——Java supports use of labeled breaks to prevent the kind of problem experienced with the New York City telephone outage.
——It really is a simple proposition:if you can‘t defend a break or a continue,don‘t use it.
——Efficient programmers do the work of mental simulations and hand calculations because they know that such measures help them find errors.
问题:为什么要在大脑中真正想明白循环如何工作,而不是通过修改控制条件等来尝试?
——In general,if the body of a loop has more than a couple of lines,if it might grow,or if it‘s in a group of nested loops,avoid i,j,and k.
2015-03-18 390 Controlling Loops
——When you begin to appreciate the principle of writing simple code,however,you‘ll rarely write loops longer than 15 or 20 lines.
问题:如何把循环嵌套深度控制在3层以下?
——If the loop is well designed,the code on the inside of a loop can often be moved into one or more routines that are called from within the loop.
——The idea is to start with something concrete,worry about only one thing at a time,and build up the loop from simple components.Take small,understandable steps as you make the loop more general and complex.
——The language you use to solve a problem substantially affects your solution.
问题:为什么要由内而外地构造复杂循环,如何操作?
——Loop indexes are subjected to a great deal of abuse.Name them clearly,and use them for only one purpose.
——Loops are complicated.Keeping them simple helps readers of your code.
2015-03-19 394 Unusual Control Structures
问题:你能想到哪些特殊控制结构?
——Several control constructs exist in a hazy twilight zone somewhere between being leading-edge and being discredited and disproved-often in both places at the same time!
——Indenting the main body of the routine inside four if statements is aesthetically ugly,especially if there‘s much code inside the innermost if statement.
问题:遇到上文的情况,如何重构代码?
——Recursion is usually called into play when a small part of the problem is easy to solve and a large part is easy to decompose into smaller pieces.
——For a small group of problems,recursion can produce simple,elegant solutions.For a slightly larger group of problems,it can produce simple,elegant,hard-to-understand solutions.For most problems,it produces massively complicated solutions.
2015-03-20 400 Unusual Control Structures
问题:如何用递归实现快速排序?
——If you have cyclic recursion,you can usualy redesign the routines so that the recursion is restricted to a single routine.If you can‘t and you still think that recursion is the best approach,use safety counters as a recursive insurance policy.
问题:使用递归时如何防止栈溢出?
——Use new to create objects on the heap rather than letting the compiler create auto objects on the stack.
问题:用递归计算阶乘或斐波那契数为什么是不合适的?
——Most important,you should consider alternatives to recursion before using it.You can do anything with stacks and iteration that you can do with recursion.
——Code containing gotos is hard to format.Indentation should be used to show logical structure,and gotos have an effect on logical structure.Using indentation to show the logical structure of a goto and its target,however,is difficult or impossible.
问题:什么情况下,goto表面上增加了效率,实际上却降低了效率?
——A well-placed goto can eliminate the need for duplicate code.Duplicate code leads to problems if the two sets of code are modified differently.Duplicate code increases the size of source and executable files.
——Achieving goto-less code is not the aim but the outcome,and puting the focus on avoiding gotos isn‘t helpful.
2015-03-23 408 Unusaul Control Structures
——What‘s not usually addressed,however,is the situation in which a programmer fully aware of the goto-less alternatives chooses to use a goto to enhance readability and maintainability.
——Writing highly interactive code calls for paying a lot of attention to error processing and cleaning up resource when errors occur.
——A programmer might balance the evil of the goto against the headache of duplicate-code maintenance and decide that the goto the the lesser evil.
问题:在处理多重的错误状态时,goto和深层嵌套的if语句哪个更好?
——To rewrite using the try-finally approach,enclose the code that would otherwise need to check for errors inside a try block,and place the cleanup code inside a finally block.
——The limitation of the try-finally approach is that it must be implemented consistently throughout a code base.
问题:goto,if嵌套,状态值和异常四种方式,应该灵活选择还是一致地使用?
——If you have your rain boots on,it‘s not worth walking around the block to avoid a mud puddle.But keep your mind open to a goto-less approaches suggested by other programmers.They might see something you don‘t.
——If you‘re a manager,adopt the perspective that a battle over a single goto isn‘t worth the loss of the war.If the programmer is aware of the alternatives and is willing to argue,the goto is probably OK.
2015-03-24 416 Table-Driven Methods
——The field of software development has advances largely through restricting what programmers can do with their code.
——Fowler suggests using multiple return statements from a routine to reduce nesting in a set of if statements.(Refactoring,Replace Nested Conditional with Guard Clauses)
——"A Linguistic Contribution of GOTO-less Programming",this classic paper humorously argues for replacing the "go to" statement with the "come from" statement.
问题:什么是表驱动法?
——A table-driven method is a scheme that allows you to look up information in a table rather than using logic statements(if and case)to figure it out.Virtually anything you can select with logic statements,you can select with tables instead.
问题:为什么有些情况下适合用表驱动法替代分支语句?
——An object-oriented design isn‘t necessarily better than any other kind of design just because it‘s object-oriented.
——When you use table-driven methods,you have to address two issues.First you have to address the question of how to look up entries in the table.The second issue you have to address if you‘re using a table-driven method is what yo should store in the table.
——If you need to classify data by Social Security Number,for example,you can‘t use the Social Security Number to key into the table directly unless you can afford to store 999-99-9999 entries in your table.
问题:如何解决上面的问题?
——Direct Access:you don‘t have to jump through any complicated hoops to find the information you want in the table.You can pick out the entry you want directly.
——One advantage of a table-driven approach is that you can put the table‘s data in a file and read it at run time.That allows you to change something like an insurance rates table without changing the program itself.
2015-03-25 426 Table-Driven Methods
问题:“浮标”案例如何体现表驱动法的优势?
——Once message definitions are read into the program,instead of having all the information embedded in a program‘s logic,you have it embedded in data.Data tends to be more flexible than logic.Data is easy to change when a message format changes.
——Another approach would be to create an abstract class AbstractField and then create subclasses for each field type.You won‘t need a case statement;you can call the member routine of the appropriate type of object.
——Once the table of routine is set up,you can handle a field in the message simply by accessing the table of objects and calling one of the member routines in the table.
问题:参考上面,“浮标”案例中,直接的面向对象为什么不合适?如何将面向对象和表驱动法结合起来?
——You can use this approach in any object-oriented language.It‘s less error-prone,more maintainable,and more efficient than lengthy if statements,case statements,or copious subclasses.
问题:什么情况下表中数据难以用键直接查询?有哪几种方法解决?各有什么优劣?
——If your environment provides ready-made key transformations,use them.For example,Java provides HashMap,which can be used to associate key/value pairs.
——When you use indexes,you use the primary data to look up a key in an index table and then you use the value from the index table to look up the main data you‘re interested in.
问题:索引访问方案有哪些优势?
2015-03-26 430 Table-Driven Methods
——Put the index-access code in its own routine and call the routine when you need to get a table key from a part number.
——The access scheme will be easier to change if you don‘t spread index accesses throughout your program.
——The stair-step approach categorizes each entry by determining the level at which it hits a "staircase".The "step" it hits determines its category.
问题:什么情况下阶梯方法优于索引方法?
——The advantage of this approach over other table-driven methods is that it works well with irregular data.
——Consider using a binary search rather then a sequential search.
问题:什么情况下可以用索引方法代替阶梯方法?
——The searching required in the stair-step method can add up,and if execution speed is a concern,you might be willing to trade the space an extra index structure takes up for the time advantage you get with a more direct access method.
——The point of design is choosing one of the several good options for your case.Don‘t worry too much about choosing the best one-it‘s better to strive for a good solution and avoid disaster rather than trying to find the best solution.
问题:表驱动法是如何替代复杂逻辑或复杂继承结构的?
——One key consideration in using a table is deciding how to access the table.You can access tables by using direct access,indexed access,or stair-step access.
2015-03-27 442 General Control Issues
——Except for the simplest control structure,the one that calls for the execution of statements in sequence,all control structures depend on the evaluation of boolean expressions.
——If a test is repeated often or distracts from the main flow of the program,move the code for the test into a function and test the value of the function.
——Not a few people don‘t have not any trouble understanding a nonshort string of nonpositives-that is,most people have trouble understanding a lot of negatives.
问题:什么是狄摩根定理?如何使用?
——If you‘re smart,you won‘t depend on your own or your reader‘s in-depth memorization of evaluation precedence-expecially when you have to switch among two or more languages.
——Parentheses are cheap,and they aid readability.Fully parenthesizing logical expressions as a matter of havit is good practice.
——Better yet,since a reader of your code might not be as sharp as you are,use nested tests to clarify your intentions instead of depending on evaluation order and short-circuit evaluation.
——Organize numeric tests so that they follow the points on a number line.The idea is to order the elements left to right,from smallest to largest.
——Some C conventions aren‘t based on maximizing readability or maintainability,and this is an example of one.Fortunately,this whole issue if fading into the sunset as more code is written using C++ and STL strings.
2015-03-30 454 General Control Issues
——Turning on full compiler warnings is usually a better option than creating nonstandard macros.
——Putting a single statement after an if test is sometimes appealing aesthetically,but under maintenance such statements tend to become more complicated blocks,and single statements are error-prone when that happens.
——Most of the code that results in loops with empty bodies relies on side effects in the loop-control code.In most cases,the code is more readable when the side effects are made explicit.
问题:为什么避免深层嵌套(三或四层以上)仍是编程的关键问题之一?
——You can‘t reduce the nesting level for free;you have to put up with a more complicated test in return for the reduce level of nesting.
——If deep nesting occurs inside a loop,you can often improve the situation by putting the inside of the loop into its own routine.This is especially effective if the nesting is a result of both conditionals and iterations.
——In a system of any size,the switch statement would be converted to use a factory method that could be reused anywhere an object of Transaction type needed to be created.
问题:上面这句话针对的具体案例是什么?
——More generally,complicated code is a sign that you don‘t understand your program well enough to make it simple.Deep nesting is a warning sign that indicates a need to break out a routine or redesign the part of the code that‘s complicated.
问题:本书一共介绍了哪些减少深层嵌套的方法?
2015-04-01 461 General Control Issues
——The core of structured programming is the simple idea that a program should use only one-in,one-out control constructs.
——A one-in,one-out control construct is a block of code that has only one place it can start and only on place it can end.It has no other entries or exits.
——The core thesis of structured programming is that any control flow whatsoever can be created from these three constructs of sequence,selection,and iteration.
——Programming seems to have advanced largely by restricting what we are allowed to do with our programming languages.
——My belief is that use of any control structure other than the three standard structured programming constructs-that is,the use of break,continue,return,throw-catch,and so on-should be viewed with a critical eye.
——The competent programmer is fully aware of the strictly limited size of his own skull;therefore,he approaches the programming task in full humility.
——You can better deal with complexity in one of two ways.First,you can improve your own mental juggling abiities by doing mental exercises.Second,you can decrease the complexity of your programs and the amount of concentration required to understand them.
问题:有哪些方法衡量程序复杂度?
——The maximum of 10 decision points isn‘t an absolute limit.Use the number of decision points as a warning flag that indicates a routine might need to be redesigned.Don‘t use it as an inflexible rule.
2015-04-03 467 The Software-Quality Landscape
问题:什么是软件的外在质量特性?软件有哪些外在质量特性?
——External characteristics of quality are the only kind of software characteristics that users care about.
问题:什么是软件的内在质量特性?软件有哪些内在质量特性?
——Understandability has to do with the coherence of the system at a more general level than readability does.
——The point is that some quality characteristics are emphasized to make life easier for the user and some are emphasized to make life easier for the programmer.Try to know which is which and when and how these characteristics interact.
——The attempt to maximize certain characteristics inevitably conflicts with the attempt to maximize others.Finding an optimal solution from a set of competing objectives is one activity that makes software development a true engineering discipline.
——It‘s useful to think about your specific quality goals and whether each pair of your goals is mutually beneficial or antagonistic.
——Although it might seem that the best way to develop a high-quality product would be to focus on the product itself,in software quality assurance you also need to focus on the software-development process.
问题:为什么要设定明确的软件质量目标?如何设定此类目标?
——One common problem in assuring quality is that quality is perceived as a secondary goal.Indeed,in some organizations,quick and dirty programming is the rule rather than the exception.
——Developers on many projects rely on testing as the primary method of both quality assessment and quality improvement.This is too heavy a burden for testing to bear by itself.
——Many software developers review their work before turning it over for formal review.Informal reviews include desk-checking the design or the code or walking through the code with a few peers.
2015-04-07 473 The Software-Quality Landscape
——One part of managing a software-engineering process is catching problems at the "lowest-value" stage-that is,at the time at which the least investment has been made and at which problems cost the least to correct.
问题:什么是质量门限?可以包含哪些活动?
——The natural effect of change is to destabilize and degrade quality,so handling changes effectively is a key to achieving high quality levels.
——Prototyping can lead to better designs,better matches with user needs,and improved maintainability.
——Programmers have high achievement motivation:They will work to the objectives specified,but they must be told what the objectives are.
——The strong implication is that if project developers are striving for a higher defect-detection rate,they need to use a combination of techniques.
——A combination of unit testing,functional testing,and system testing often results in a cumulative defect detection of less than 60 percent,which is usually inadequate for production software.
问题:极限编程的缺陷移除率为什么会明显好于平均水平?
——The determination of which specific defect-removal practices to use to achieve a desired quality level is one part of effective project planning.
——Some techniques,such as inspections,detect the symptoms and causes of defects in one step;others,such as testing,find symptoms but require additional work to diagnose and fix the root cuase.
——Just as it‘s a good idea to work out the defects in the blueprints for a house before pouring the foundation in concrete,it‘s a good idea to catch requirements and architecture errors before they affect later activities.
2015-04-08 478 The Software_Quality Landscape
——The General Principle of Software Quality is that improvint quality reduces development costs.
——The single biggest activity on most projects is debugging and correcting code that doesn‘t work properly.Debugging and associated refactoring and other rework consume about 50 percent of the time on a traditional,naive software-development cycle.
——Software projects with the lowest levels of defects had the shortest development schedules and the highest development productivity...Software defect removal is actually the most expensive and time-consuming of work for software.
——Compared to the traditional code-test-debug cycle,an enlightened software-quality program saves money.It redistributes resources away from debugging and refactoring into upstream quality-assurance activities.
——Not all quality-assurance goals are simultaneously achievable.Explicitly decide which goals you want to achieve,and communicate the goals to other people on your team.
——Quality assurance in the software arena is process-oriented.Software development doesn‘t have a repetitive phase that affects the final product like manufacturing does,so the quality of the result is controlled by the process used to develop the software.
2015-04-09 484 Collaborative Construction
——In one way or another,all collaborative construction techniques are attempts to formalize the process of showing your work to someone else for the purpose of flushing out errors.
问题:什么是合作构建?包含哪些活动?
——All collaborative construction techniques,despite their differences,are based on the idea that developers are blind to some of the trouble spots in their work.
——Various studies have shown that in addition to being more effective at catching errors than testing,collaborative practices find different kinds of errors thatn testing does.
——The need for reviewing was so obvious to the best programmers that they rarely mentioned it in print,while the worst programmers believed they were so good that their work did not need reviewing.
——The code,the standards,and the reasons for making the code meet the standards are good topics for review discussions.
——Reviews create a venue for more experienced and less experienced programmers to communicate about technical issues.As such,reviews are an opportunity for cultivating quality improvements in the future as much as in the present.
问题:为什么要强调代码的集体所有权?
——Pair programming will not be effective if the two people in the pair spend their time arguing about coding style.Try to standardize the "accidental attributes" of programming so that the programmers can focus on the "essential" task at hand.
——Pairs encourage each other to keep code quality high even when there‘s pressure to write quick and dirty code.
2015-04-10 490 Collaborative Construction
——An inspection is a specific kind of review that has been shown to be extremely effective in detecting defects and to be relatively economical compared to testing.
——The inspection focuses on defect detection,not correction.
问题:代码视察中有哪些不同角色?每个角色负责什么任务?
——Under no circumstances should inspection results be used for performance appraisals.Evaluation of performance should be based on final products,not on work that isn‘t finished.
——The design or code should speak for itself;the overview shouldn‘t speak for it.
——The scribe notes the type and the severity of the error,and the inspection moves on.If you have problems keeping the discussions focuses,the moderator might ring a bell to get the group‘s attention and put the discussion back on track.
——Some inspection groups don‘t even allow discussion about whether a defect is really a defect.They assume that if someone is confused enough to think it‘s a defect,the design,code,or documentation needs to be clarified.
——As you do inspections,you‘ll notice that certain kinds of errors occur more frequently than other kinds.Create a checklist that calls attention to those kinds of errors so that reviewers will focus on them.
——The point of the inspection itself is to discover defects in the design or code.It is not to explore alternatives or to debate about who is right and who is wrong.
2015-04-13 495 Collaborative Construction
——Acknowledging a criticism doesn‘t imply that the author agrees with the content of the criticism.
——The inspection process is systematic because of its standard checklists and standard roles.It is also self-optimizing because it uses a formal feedback loop to improve the checklists and to monitor preparation and inspection rates.
——A Capability Maturity Model that measures the effectiveness of an organization‘s software-development process-the process is systematic and repeatable and uses measured feedback to improve itself.
——Other kinds of collaboration haven‘t accumulated the body of empirical support that inspections or pair programming have,so they‘re covered in less depth here.
问题:代码走查的定义是宽松的,但所有的代码走查都有的共同点有哪些?
——Used unintelligently,walk-throughs are more trouble than they‘re worth.
——A review is basically a meeting,and meetings are expensive.If you‘re going to incur the overhead of holding a meeting,it‘s worthwhile to structure the meeting as formal inspection.If the work product you‘re reviewing doesn‘t justify the overhead of a formal inspection,it doesn‘t justify the overhead of a meeting at all.
问题:既然代码视察比走查更高效,为什么要选择代码走查?
——If you‘re choosing a review standard for your organization,choose inspections first unless you have good reason not to.
——The difference between code reading on the one hand an inspections and walk-throughs on the other is that code reading focuses more on individual review of the code than on the meetings.
——Code readings are especially valuable in situations in which reviewers are geographically dispersed.
2015-04-14 503 Developer Testing
——Testing is usually broken into two broad categories:black-box testing and white-box(or glass-box) testing.
——Some programmers use the terms "testing" and "debugging" interchangeablly,but careful programmers distinguish between the two activities.
——An absence of errors could mean ineffective or incomplete test cases as easily as it could mean perfect software.
——If you want to lose weight,don‘t buy a new scale;change your diet.If you want to improve your software,don‘t just test more;develop better.
——Testing requires you to assume that you‘ll find errors in your code.If you assume you won‘t,you probably won‘t,but only because you‘ll have set up a self-fulfilling prophecy.
——Depending on the project‘s size and complexity,developer testing should probably take 8 to 25 percent of the total project time.
——During construction,you generally write a routine or class,check it mentally,and then review it or test it.Regardless of your integration or system-testing strategy,you should test each unit thoroughly before you combine it with any others.
2015-04-15 510 Developer Testing
——A systematic approach to developer testing maximizes your ability to detect errors of all kinds with a minimum of effort.
——Design the test cases along with the product.This can help avoid errors in reauirements and design,which tend to be more expensive than coding errors.Plan to test and find defects as early as possible because it‘s cheaper to fix defects early.
问题:为什么写测试用例要在写代码之前进行?
——Writing test cases first forces you to think at least a little bit about the requirements and design before writing code,which tends to produce better code.
——All in all,I think test-first programming is one of the most beneficial software practices to emerge during the past decade and is a good general approach.
问题:代码语句覆盖率和代码分支覆盖率的区别是什么?
——Since exhaustive testing is impossible,practically speaking,the art of testing is that of picking the test cases most likely to find errors.
——In spite of the hairy name,structured basis testing is a fairly simple concept.The idea is that you need to test each statement in a program at least once.
问题:结构化基础测试中,如何计算最小用例数?
——Shorter routines tend to have fewer paths to test.Boolean expressions without a lot of ands and ors have fewer variations to test.Ease of testing is another good reason to keep your routines short and your boolean expressions simple.
——Data-flow testing is based on the idea that data usage is at least as error-prone as control flow.