Software Engineering (phần 5) pdf

40 479 0
Software Engineering (phần 5) pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

. j 1: ************************************************************************************************** ' j . , .Ji t ' . ' ' l i! 1 'j g E., . p ' ' ' Ilo t u A p T : p l . TeskingE ( j l ; ; peer at the screen and say, <ûI guess that looks right.'' Equally futile is for the tester toI : ' t à ; plan test cases with great care, execute each test case in turn, look at the output, and1 i ! ! EEàres that certainly looks right .'' It is far too easy to be fooled by plausible results.l j say, ,; ' !I : i E If programmers are allowed to test their own code , then there always is the danger .1 .l l ! l : tlaat the programmer will see what he or she wants to see. The same danger can occur 'j ; ! j j ' 2 1 1 : 1 even when the testing is done by someone else . The solution is for m anagement to k i i '! ! j ' ' . j : ( : insist that, before a test is performed, both the test data and the expected results of '( @ l l j : j that test be recorded. After the test has been performed, the actual results should be l i : 1 recorded and compared with the expected results . I I l ! , ! ! ' , Even in sm all organizations and with small products, it is important that thisl l I l : - . .j 1 ! ' . j recording be done in machine-readable form , because test cases should never be ! : @ 1 . ! j thrown away. The reason for this is maintenance. W hile the product is being main- .I 1 I ,I j . tained, regression testing must be performed. stored test cases that the product hasj ( j , i : 1 previously executed correetly must be rerun to ensure that the moditications made : : ! ; I ' y ' j r . . to add new functionality to the product have not destroyed the product s existing 1 ) functionality . This is discussed further in Chapter l6.i ; ll j . i ( .i i I i ! . I E - . ; . ( ; , ' li '-, ' , ' !jj r ' :. , ' . ' . ' l i l y u,x n sylxo svops j ' , *'j : : . g . 1 1 l After a product has been successfully maintained for many years , it eventually mayl . . !I . ! 1 l 4 I lose its usefulness and be superseded by a totally different product, in much the same ! t : E i , ; ! . ë j w ay that electronic valves were replaced by transistors. Alternatively, a product still l l l ) 1 j 1 may be useful, but the cost of porting it to new hardware or running it under a new ii j i :! i operating system may be larger than the cost of constnlcting a new product, using! ' l 1 ' . 1 1 the old one as a prototype . so, tinally, the software product is decommissioned andI ( . . ! - l( I removed from service . Only at that point, when the software has been irrevocably: i ! I l ! discarded, is it time to stop testing.i ! l . 2 @ i .j j j I Now that a1l the necessary background material has been covered , objects can be. 1 . .l k E I examined in greater detail. This is the subject of the next chapter. , , 1 : i i ( ' i ! I I ' . l 1 ' i ;! ' ) : .qj' ! ë .T : ' ! '1 ë : I - i ' . 1 tHA- ER Rzvlzw 1 . ' .( ' - ( ' i ; 1 A key them e of this chapter is that testing must be carried out in parallel with all ' k j ' . : t .! ' activities of the software process . The chapter begins with a description of quality j: .li : f . l ( r ; issues (Section 6. 1). Next, nonexecution-based testing is described (Section 6.2), with j' : a careful discussion of walkthroughs and inspections. This is followed by a defini- j1 1 - . ! . j tion of execution-based testing (Sections 6.3 and 6.4) and a discussion of behavioral ' ' roperties of a product that must be tested, including utility, reliability, robustness, ëj P E ! rform ance , and correctness (sections 6.4.1 through 6.4.5). In section 6.5, correct- I. pej i 7 y ' !l l l , I ! j ' lI I i ' !i i i 2 Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. ! . l F 2 FoR FURTHER READING X@1 ', E) ness proving is introduced and an example of such a proof is given in Section 6.5.1. :1 The role of correctness proofs in software engineering then is analyzed (Sections 6.5.2 : I ;. and 6.5.3). Another important issue is that systematic execution-based testing must T be performed by the independent SQA group and not by the programmer (Section I Lr 6.6). Finally, the issue of when testing can linally stop is discussed in Section 6.7. o k f e S FoR FURTHZR REAPINI e : i- The attitude of software producers to the testing process has changed over the years, ' S from viewing testing as a means of showing that a product runs correctly to the modern l e . attitude that testing should be used to prevent requirem ent, specilication, design, and ' # ' implementation faults. This progression is described in gGelperin and Hetzel, 19881. ' The nature of software testing and the reasons why it is so hard are discussed in C ) lgWhitt aker, 20001. : j The Januarv 1996 issue of IEEE Software contains a number of articles on soft- ' *'' ' '' 1 warequality, including (Tevonen, 19961. The November l 996 issue of IEEE Computer ! - also has articles on software quality. Yet another series of articles on software quality l ! is in the June 1997 issue of the Communications ofthe ACM. Of particular interest are ' (Herbsleb et al., l 9971, which describes the effect on software quality of improving y the software process, and gArthur, 19971, a description of how total quality manage- ; e ment was used to improve software quality within M cDonnell-Douglas. A different 11 approach to achieving quality is described in gonoma and Yamaura , 19951. A way : & of assessing the overall quality of a software product is described in gBoloix and g Robillard, 19951. M yths regarding software quality are discussed in gvoas, 19991. d Reliability is discussed in a set of articles in the May 1995 issue of IEEE Software. y ' B ber 19871 is a good introduction to proving programs correct. One of the stan- ig a , j! . i dard techniques of correctness proving is using so-called Hoare logic, as described in : ! ' e gl-loare, 1969J. An alternative approach to ensuring that products satisfy their speci- hcations is to construct the product stepwise, checking that each step preserves cor- rectness. This is described in gDijkstra, 1968a, and Wirth, 1 97 l 1. An important article regarding acceptance of correctness proofs by the software engineering comm unity is gDeMillo, Lipton, and Perlis, 19791 . : . - The IEEE 4sstandard for Software Reviews'' (IEEE 1028, 19971 is an excellent E ë source of information on nonexecution-based testing. A paper on how to conduct 1 linspections as well as theireffectiveness is (Ackerman , Buchwald, and Lewski, 19891. 2 11 Inspection of a very large software product (2.5 million lines of code) is described jl in gRussell, 19911. Other sources of information on experience with inspections are '!y h gDoolan, 1992, and Weller, 19931. Cost issues, such as reducing the size of a team and . l ! !: - minimizing the time lost while waiting for reviewers to meet, are described in gvolta, 2 tl 19931. An experiment evaluating the costs and benefits of inspecting a large-scale ;( ' . ;, software product is described in (Porter, Siy, Toman, and Votta, l 9971. A variety of I 2- useful papers on inspections appears in gW heeler, Brykczynski, and M eeson, 19961. 1 ' j( . l 1 z : 1 Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. ' I 1 ( j 1 ' .l ' l ; : j j ' ' ) ' . 1 1. - ' : ' ' ' i 1l2 t u A p . : w l . Tesding I I : ' : I l 1 Possible future developments in the area of inspections are put forward in (Johnson, bl! . ;1 ë . 19984. s.1 . j é , r j jI ; ; The classic work on execution-based testing is (Myers, 19791, a work that has pl1 j . I ! ; ' had a signihcant impaet on the seld of testing . kDeMillo, Lipton, and Sayward, 19781 l g AI i ' . t ' 1 : remains an excellent source of information on selection of test data . (Beizer, 19901 is ntjll !! . 11. * i ' 1 ,j j : ; a compendium on testing, a true handbook on the subject. A similar work is gHetzel, ctl . . î 1 1988j . , l , t l pt ' I ' @ : Turning specihcally to the object-oriented paradigm, the September 1994 issue of '' ! ! 1 1 ! 1 *.@ YtI j j Communications ofthe ACM contains a number of articles on testing object-oriented ' : t i i I 21 :7 software. (Kung, Hsia, and Gao, 19981 is a book on object-oriented testing, and so is , 01:1 $ j so1 : (Sykes and McGregor, 20001. ' . I i I , i so j l ! . The May 1989 issue of IEEE Software has a wide variety of papers on testing 1 ; issues . Both execution-based and nonexecution-based testing are covered. The pro- **1P %i ' ; 1 i( j E ' à ceedings of the lnternational Symposium on Software Testing and Analysis cover a . T i ' . ) : ! similar broad spectrum of testing issues . The April 1997 issue of Communications of .j ! . j j ', the ACM is devoted to debugging. . ! js! ' It , j 5 @. j j AjI i . r :i ; ' : in,' j 1 ) sjli . J .( ' ' i ; i pposkgm s *.12 C(! : .i . ' ! : g ' . : ' p ' I : ) 'j 6.1 How are the terms correctnessproving, ver/cation, and validation used in this book?11 l . ' l 6 Q A software development organization currently employs 83 software professionals , I1 ! . è *' l ' ' including 17 managers , a1l of whom do development as well as verihcation andI - 1 ! 1 -! ' lidation of software . Latest figures show that 28 percent of their time is spent on; I : va i 1 l 1 verification and validation . The average annual cost to the company of a manager is ! I ! 1 1 l ! j : $140,000, whereas nonmanagerial professionals cost $104,000 ayearon average; both' ' 1 ! i j . I ; figures include overhead. Use cost-benefit analysis to determine whethcr a separate , ' t ï! i i SQA group should be set up within the organization .pl : . I pr il i l 'r l.a Repeat the cost-benefit analysis of Problem 6 .2 for a firm with only seven soft- l . 1a clI j j l .1 ,1 ; 7 ware professionals , including two managers. Assume that the other figures remain m ; . 1l 1 unchanged. ,l i . 1 .1* I!4' ! l 1 : p -l : ' f .4 You have been testing a module for 1 1 days and found two faults. W hat does this tell pr.i ;1 . j ! ; ! you about the existence of other faults? l ! s D(t ; : * ! ') ô .s w hat are the similarities between a walkthrough and an inspection? W hat are the US! : '' ! differences? . th1 , faIt $ , I . ô.l You are a member of the SQA group at Ye Olde Fashioned Software. You suggest to . sul I i ! your manager that inspections be introduced. He responds that he sees no reason why or1 ; - i' j four people should waste their time looking for faults when one person can run test ti . yl! ! 1 cases on the same piece of cod e. How do you respond?! 4 ' , . h w., 6 (-rt i ' r + y You are the sQA manager at Tex's Taxes, a tax preparation franchise with 154 fuj j * l 1 i . l ; , branches, all in Texas and Tennessee. The owners of the franchise are considering AI' j ; r ' I ; 1 . ! . j 2 J Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. ( ' i ! I ' PROBLEM: %*a ' è . r ' : ' i 3n, ' buying a new type of tax preparation package for use throughout the organization. g ' ' Before authorizing the purchase of the package, you decide to test it thoroughly. W hat : 7 ' roperties of the package do you investigate? Izas p i '781 . ô.g All 154 branches of Tex's Taxes are now to be connected by a communications i ' 1 is network. A sales representative offers you a 4-week free trial to experiment with the ': rel, communications package he is trying to sell . W hat sort of software tests would you . perform and why? . , of .: . 9 You are a vice-admiral of the Navy of the Republic of Claremont in charge of devel- ted i the software for controlling the new ship - to-ship missile (Problem l .3). The. op ng 7 iS has been delivered to you for acceptance testing . W hat properties of thesoftware software do you test? . ing &1Q Wh at happens to the correctness proof of Section 6.5. l if loop invariant ro- i s = y!O) + yl 1 ) + . . . + y(k - 1 ) !r of 1i s used instead of (6.4)? 2 é.1 1 Assume that you have some experience with loop invariants and that you know that ' ; ' invariant (6.4) is the correct invariant for the loop of Figure 6.6. Show that output specification (6.3) is a natural consequence of the Ioop invariant. ; :.12 Consider the following code fragment: ' ' Ik = Q,. I )k? ' ! g = 1 ; : àls, while (k < n) tll (1 ( ii on , k = k + 1 ; ! r is = g + k. : '9 ' I h !Ot I l ! l 'ate Ii I I t prove that this code fragment correctly computes g = n! if n is a positive integer. aft- é 1a can correctness proving solve the problem that the product as delivered to the client* ain : ' t be what the client really needs? Give reasons for your answer . . may no :.14 How should Dijkstra's statement (Section 6.3) be changed to apply to correctness tell proofs rather than testing? Bear in mind the case study of Section 6.5.2. é.15 Design and implement a solution to the Naur text-processing problem (Section 6.5.2) è ) using the language specihed by your instructor. Execute it against test data and recordthe ! the number of faults you tind and the cause of each fault (e.g., logic fault, loop counter 11 fault). Do notcorrect any of the faults you detect. Now exchange products with a fellow : t to : student and see how many faults each of you finds in the other's product and whether I /hy ' he are new faults . Again record the cause of each fault and compare the fault 'or not t y Eest found by each of you . Tabulate the results for the class as a whole. ). types . ;é . 1é (Term Project) Explain how you would test the utility, reliability, robustness, per- : L54 formance, and correctness of the Broadlands Area Children's Hospital product in i 1' i !i ng Appendix A. ! iI . ' k : I J 1 i ! Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. ; ë I ;i : . : I ' i 1, : . 1 .' : t 1 E l ( .' l I t ' . j .' . 1l* t u A p T . R l . Tesging1 ) ' ' ! .2 ' i ' ! ! i y . j ! ' ' f.1 7 (Readings in Software Engineering) Your instructor will distribute copies of gWhit- 1 ! ) taker, 20001. Brooks (Section 2.9) considers four difficulties of software to be essen- ,I . . . I I tially hard. Do you consider testing to be essentially hard or accidentally hard? I1 I ; : i ( k j 1 . t , ( k j 1 l '! l ; I - , é 1) T ; I :i q i i ; ' t 9 I ' : t! l l Ruyzu xtzs , : l l . . l II : I 1 2 ' 1 j (Ackerman, Buchwalds and Lewski, 19891 A. F. ACKERMAN, L. S. BucHwALo. ANn ,l 1 I i F . H. LEwsltls t'Software Inspections: An Effective Verification Process,'' IEEE Sojtware j. I ' I I 1 . q 6 (May 1989), pp. 31-36. t ( i j ' j (Arthur, 19971 L. J. ARTHUR. çtouantum lmprovements in Software System Quality,''E ! j i F Communications of the ACM 40 (June 1997), pp. 46-52.l ; ; : ) ' ! r j ! gBaber, l 9871 R. L. BABER. The Spine ofsohware: Designing Provably Correct Software: ( 1 l . j Theoty and Practice, John Wiley and Sons, New York, l 987. (: é 1 1 gBeizer , 1 9901 B. BEIZER, Software Testing Techniques, 2nd ed., Van Nostrand Reinhold, (1, :l 41 : 1 New York, 1990. ' ; ' y <i l ! ! . gBel'ry and W ing . l 9851 D. M. BERRY AND J. M. WING, Specifying and Prototyping: Some , lik j ' . (.I J i ' . ! Thoughts on Why They Are Successful,'' in: Formal Methods and Software 1 l h Developmentb Proceedings ofthe lnternational Joint Conference on W/lcory and Practice E1: . ' j . k ' ofsoftware Development, Volume 2, Springer-verlag, Berlin, 1 985. pp. 1 l 7-28. ; E ' i ' ' ; B hm l 984a1 B . W. BOBHM, çtverifying and Validating Software Requirements and Design (1. , r oe .è ' ' 1 '' ' ' r 1 : 1 ' i specificationss'' IEEE Sopware 1 (January 1 984), pp. 75-88. 'I l , ( ' - qqlj I , r , i (Boloix and Robillard. 19951 G. Bot-olx Axo R N. Rosll-l-xRo, A software system . (Jl l . 1 Evaluation Framework , '' IEEE computer 28 (December 1995), pp. 17-26.l l I : 1 j j l 1 j (Bush, l 990j M. BUSHS ttlmproving Software Quality: The Use of Formal lnspections at the ' (2l 1 i .,l ; j I i Jet Propulsion Laboratory, Proceedings ofthe 12th International Conference on i 1 l Software Engineering, Nice, France, March I 990, pp. 1 9* 99. 11I j ' ' ! r (DeMillo, Lipton, and Perlis. 19791 R. A. DEMII-LO, R. J. LlpvroN, ANI) A. J. PERLIS , 'tsocial l i t l ! prooesses and Proofs of Theor ems and Programs,'' Communications of llle ACM 22'; I 1 1 t l i j 1 : i j (May l 979), pp. 27 1-80. (1i ! I (DeMillo, Lipton, and Sayward, l 9781 R. A. DEM ILLO, R. J. LlpTox, AND F. G. SAYwARD,' ! ? ' : l çKl-lints on Test Data Selection: Help for the Practicing Programmer,'' IEEE Computer 11 El;1 1 ' , t j t 1 s (April 19,78)- pp. 34 43.1 , ' jt p 2 p goijkstra , 19681 E. W. DIJKSTRA. G'A Constructive Approach to the Problem of Program (1 ' p p ! ' colvectness . '' B11- 8 (No. 3. 1968), pp. 174-86. )l ; . 1 ; ( ' 1 ê ' g tDijkstra, 19721 E. W. DIJKSTRA. ''The Humble Programmer,'' Communications of the ACM (1l ! : 1 15 (October l 972), pp. 859-66.1 ' : l , ,,j j r , fDoolan, 19921 E. P. DooLAx. Experience with Fagan s Inspection Method, ! ! ' ; Sopware- practice and Experience 22 (Febrtlary l 992). pp. l 73-82. (hq ' ' ij ! . gFagan, 19761 M. E. FAGAN, 'resign and Code Inspections to Reduce Errors in Program ! 5 ,, I ! ' 1 . Development, IBM Systems Journal 15 (No. 3, l 976), pp. 182-21 1. . IA E , ; ,, ; ( ; (Fagan, 1 9861 M. E. FAGAN, Advances in Software Inspections, IEEE Transactions on h t i ' - ' I I i Software Engineering SE-12 (JuIy 1986). pp. 744-51 . (h I I ' ' ! gFowler. 1 9861 P. J. FOwLER, Açln-process lnspections of Workproducts at AT&T,'' AT&T t Eh ' ! ' 7 i Teclmical Journal 65 (March/April 1986) , pp. l 02-1 2. .F l l t ; l 8 (Garman, l98 1) J. R. GxRMxx, 'The 'Bug' Heard 'Round the World,'' ACM SIGSOFT (h ' 2 1 i sohkvare Engineering Notex 6 (october I 98 1), pp. 3-10. IhI ! ! . ! ! , t ' : . ; ll ! : I i 1 I ' ) 1 ' Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. . l ' r ' j . j I . ë . e *- > * e < 2 . ( ! 1 t ' E kES T JKZT: i , ' ! . - ) ) : ,: ' ' . j l ' j ' ( . j. ' j ' Some of the more lurid computer magazines seem to suggest that the object-oriented paradigm was a sudden 'pi I' , and dramatic new discovery of the mid-lgsos, a revolutionary alternative to the then popular structured . : : paradigm. That is not the case. Instead, the theory of modularity underwent steady progress during the 1970: j and the 1980s, and obiects were simply a logical development within the theory of modularity (but see the g Just in Case You Wanted to Know box on page 168). This chapter describes objects within the context of : $ modularity. 1 . !This approach is taken because it is extremely difficult to use objects correctly without understanding r ' wby the object-oriented paradigm is superior to the structured paradigm. And to do that, it is necessary to l appreciate that an object is merely the next step in the body of knowledge that begins with the concept of $ a module. L . I y.I HAT Is A M opukz*. 1* : W hen a large product consists of a single monolithic block of code, maintenance is a nightmare. Even for the author of such a m onstrosity. attem pting to debug the code is l ; extremely difécult; for another programmer to understand it is virtually impossible. I ' The solution is to break the product into smaller pieces, called modules. W hat is i a module? ls the way a product is broken into modules important in itself or is it I important only to break a large product into sm aller pieces of code? @ i j 'An early attempt to dcscribe modules is by Stevens , Myers, and Constantine, i ( . (k d; ' ;who defined a module as A set of one or more contiguous program statem ents hav- I Ii ng a name by which other parts of the system can invoke it, and preferably having j . its own distinct set of variable names'' Istevens, M yers, and Constantine, l 9741. In : ! ' . l . other words, a module consists of a single block of code that can be invoked in the lr way that a procedure, function, or m ethod is invoked. This definition seems to be . extremely broad. It includes procedures and functions of all kinds. whether inter- , nal or separately com piled. lt includes CO BO L paragraphs and sections, even though 1ô7 ) . : I I Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. ; ; '! 1 : : : ' : ' I , . ' . ' jj: ' I . j' : ' 1 . j (' ' , @ Ile t a A p 4 z R y . From Modules 'o obiedsi ( i @ . 1i ' ! $ : ! , g ' . ! ' ' i ! . 2 q I JusT lN ZAS: You W ANTKP To Kxow1 ' : ' q j ' :2 . I j jj I . r ' jj object-oriented concepts were introdueed as early as luding (section 7.6) was first proposed within the soft-1 i ' ) i j 1966 in the simulation language simula 67 loahl and ware context by Parnas in 1971 (Parnas , 1971 1, but the tI 'l ! @ j l , ' Nycaard . 19661. However, at that time, the technoloMy technology was not widely adopted until about l 0 vears> i ! ! E 1 ' - '''-' -'- - - - tlj l ! was too radical for practical use , so it lay dormant un- later, when encapsulation and abstract data types had 1 l I tiI the early l980s, when it essentially was reinvented become part of software engineering.l , . ! jj'j ' j ' 1 i within the context of the theory of modularity. It seems that we human beings adopt new ideas I I j 7 j There are other examples in this chapter of only when we are ready to use them, not necessarily 2:l t ;; th e way that leading-edge technology lies donnant when they are lirst presented.! j 4 .: ( I i until the world is ready for it. For example, information . ! .i ' j 1è l j .; ! j I I : 1) * ik . ' ' - ' 1. , * ' ' ! l , . I . 1 .ë .E ; i l they cannot have their own variables, because the detinition states that the property ; ' q 1 ( of possessing a distinct set of variable names is merely ççpreferable . '' It also includesi j C.t , : modules nested inside other modules. But, broad as it is, the detinition does not go1 ! ' ' 1 far enough . For example, an assembler macro is not invoked and therefore, by thel ) . ! ' , ' . preceding detinition, is not a module. In C and C++, a header file of declarations1 : , I , , that is #included in a product similarly is not invoked', neither is an Ada package '. ' ! ' , ( ; ' (implementation of an abstract data type) nor an Ada generic (macro). In short. this1 gi p : ! definition is too restrictive. . 1 ' I l 1 Yourdon and Constantine give a broader detinition: 'çA module is a lexically 'l : @ .i. i! ; 1 ! contiguous sequence of program statements, bounded by boundary elements, having . 1 ' '' Yourdon and Constantine , 19791. Examples of boundaryi an aggregate identitier (! j ; i 1 j' elements are begin aend pairs in a block-structured Ianguage Iike Pascal or Ada or: ' t -: i in C++ or Java . This detinition not only includes all the cases excluded1 l l 1 1. ' .1 Pa rsf 1 ! ' . -j l I j by the previous detinition but is broad enough to be used throughout this book. ln j E ' ' j r ' ' l '; q particular, procedures and funetions of the dassical paradigm are modules. In the! ' l ) 1 'l ; j . j object-oriented paradigm, an object is a module and so is a method within an object.: f , i ! To understand the importance of modularization, consider the following some- 'il ) . i :i 1 hat fanciful example. John Fence is a highly incompetent computer architect. He' j 1 ; I I w , 1 ; h k still has not discovered that both NAND gates and NOR gates are complete', that ' ' t 1 ' is every circuit can be built with only NAND gates or with only NO R gates. John '2 ,l : ; , : ' i k k , . tr therefore decides to build an ALU, shifter, and 16 registers using AND, O R, and ' 1 ' 'i NOT gates. The resulting computer is shown in Figure 7.1. The three components g ! ! ' !' T 1 ' are conneeted together in a simple fashion. Now, our architect friend decides that the ! J ircuit should be fabricated on three silicon chips , so he designs the three chips shown: 2 ci . 7 ' : . in Figure 7.2. One chip has all the gates of the ALU, a second contains the shifter, ' thill 1 - ' ,I ! j j and the third is for the registers. At this point John vaguely recalls that someone in cor i ! it is best to build chips so that they have only one kind of gate , ed!l ' i i l a bar told him that) . . : j i ! so he redesigns his chips. On chip l he puts all the AND gates, on chip 2 all the OR AL l l l l . t gates , and a1l the NOT gates go onto chip 3. The resulting tiwork of art'' is shown ha& i : 2 q ! j j schematically in Figure 7.3. Fig ! , 1 - : l i ' p; j ., . . j j ' i .! : l ë !l ( , Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. ; w HA: Is A Mopuu? 1l* 1 , x, i lChi p 1 Chip 2 ' i i ! l t- ' le ' Registers Registers rs td . ALU ALU zs : I)r : t shifter Shifter :' Chip 3 Flgvre KI Design of a FIgue* Ya Computer of Figure 7, 1 i computer. fabricated on three chips. jAe11y : l udes r . ! lt go . the ' Chip 1 Chip 2f tions ; I Ek age this) AND uates OR gates cally - h tving ; dary ja Of I uded k. ln chip 3 ' : R the lject. Jm e- NOT gates t. He .I that j' ( ' John i . Flgvee Ka Computer of Figure 7.1 fabricated on 1 , and . three other chips . 1 . 1Aents 1tt the , lown Figures 7.2 and 7.3 are tknctionally equivalent', that is, they do exactly the sam e : ifter, thing. But the two designs have markedly different properties. First, Figure 7.3 is I ne in considerably harder to understand than Figure 7.2. Almost anyone with a knowl- t 1gate , edge of digital Iogic imm ediately will know that the chips in Figure 7.2 form an ë O R ALU a shifter, and a set of registers. However, even a leading hardware expert will @D , lown have trouble understanding the function of the various AND. O R, and NOT gates in ' Figure 7.3. 1 1 i i , ' ' j ' 1 ' j Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. . ! j ' ' ' . ! . k i . ' . : 1 '! fi 1 ' ' 7 1 : : 1y@ t u A p T K * y * From Modules 'o Obiees i j : ! ù $ ii 5! 1. ! : second, corrective maintenance of the circuits shown in Figure 7.3 is difficult. ! ' : ' . should there be a design fault in the computer and anyone capable of coming up , 1 . I I ' 11 E p @ with Figure 7.3 is undoubtedly going to make lots and lots of mistakes it will be . ! ! ; j : :j j i g : difhcult to determine where the fault is located. On the other hand, if there is a fault l l ' ! i in the design of the computer in Figure 7 . 2, the fault can be localized by determining l ( l ! k I j j whether it appears to be in the way the ALU works, the way the shifter works, or ' t i ' the way the registers work. Similarly, if the computer of Figure 7.2 breaks down, itj ë . i l l ë is relatively easy to determine which chip to replace; if the computer in Figure 7 .3 , I l 1 i ! h ! 1 breaks down, it is probably best to replace all three chips. '1 l 1 1 Third , the computer of Figure 7.3 is difficult to extend or enhance. If a new type ' : l l 11 l i i of ALU is needed or if faster registers are required , it is back to the drawing board. But C . 1 I 1 l ': ' : ! ; 4 ' the design of the computer of Figure 7.2 makes it easy to replace the appropriate chip. . : j .1 : .Perhaps worst of all , the chips of Figure 7.3 cannot be reused in any new product.l l l . . t i ' ' There is no way that those three specihc combinations of AND, OR, and NOT gates! E ' I .i , ! ' can be utilized for any product other than the one for which they were designed. In a1l 1 l ; bability the three chips of Figure 7 . 2 can be reused in other products that requirepro ,l ! ' r ; ! ; an ALU. a shifter. or reeisters. i : '' '' ''''''''' .1 ' The point here is that software products have to be designed to look like Figurei : E - . i i : ! 7.2, where there is a maximal relationship within each chip and a minimal relationship ! ! ' between chips . A m odule can be likened to a chip, in that it performs an action or ' î ' ) . . ' : 4 î ' series of actions and is connected to other modules. The functionality of the prod- : ! ( '' . ë : ( uct as a whole is hxed; what has to be detennined is how to break the product into! : ' yi ! ' : 1 modules. Composite/structured design (Stevens, M yers. and Constantine, l 9741 pro- j i i 1 vides a rationale for breaking a product into modules as a way to reduce the costl 1 . .'! $ ; i of maintenance, the major component of the total software budget, as pointed out in l ' ! 1 l Chapter 1 . The maintenance effort, whether corrective, perfective, or adaptive, is re- :' i h - 1 i I p j ' duced when there is maximal interaction within each module and minimal interaction1 1 1 1 between modules. ln other words, the aim of composite/structured design (C/SD) is : 1' I! ! 1 y ' . l $ to ensure that the module decomposition of the product resembles Figure 7 .2 ratherl ' , 1 ( l E I than Figure 7 .3. ; ) : ! ( 1 l ! M yers quantilied the ideas of module cohesion , the degree of interaction within aèl l ' ! E q é! module, and module coupling, the degree of interaction between two modules gMyers, jài 2 1 i '' i ' E I 1978b1. To be more precise, Myers used the term strength rather than cohesion . , tl ; i l ' . li l ; i ;1 However, cohesion is preferable because modules can have high strength or low t ' i ' ' I :l q 1 ; strength, and something is inherently contradictory in the expression Iow strength-t i ' ' : I if something is not strong, it is weak. To prevent terminological inexactitude, C/SDt ' ' ! i 1 h ion . some authors have used the term binding in place of! i now uses the term co esj ' . ' . l ë ! coupling . Unfortunately, binding also is used in other contexts in com puter science, ! '; 1 such as the binding of values to variables . But coupling does not have these overtonesi . : .' and therefore is preferable.i - . I i I i It is necessary at this point to distinguish between the action of a module, the ! l ' ' l ic of a module , and the context of a module. The action of a module is what it does,, ; . og! l - . : : : ; ; that is, its behavior. For example. the action of m odule m is to compute the square ! i I .root of its argument. The Ionic of a module is how the module performs its aetion,t ! . j iI i : ! 'j in the case of module m, the specilic way of computing the square root is Newton's! . i 1 ! ' 1 method (Gerald and Wheatley, l 9991. The context of a module is the specific usage of ' , : : I .1 j ' !j l 1 I : ; 1 : ( ' . Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. . : u COHESION In : lt. . that module. For example, module m is used to com pute the square root of a double : lp . precision integer. A key point in C/SD is that the nam e assigned to a module is its le action and not its logic or its context. Therefore, in C/SDS module m should be named i lt compute square roof; its logic and its context are irrelevant from the viewpoint of !L lg its name. . nr , it . 3 'e 72 touzslox@ ut P' Myers delined seven categories or levels of cohesion (Myers, 1978b1. In the light of 't. dern theoretical computer science , Myers's irst two levels are considered equallymo CS 11 be shown functional cohesion is optimal for the struc- Igood . M ore precisely, as wi . tl1 tured paradigm , whereas informational cohesion is optimal for the object-oriented re g paradigm. The resulting ranking is shown in Figure 7.4. This is not a linear scale of . )any sort . It is merely a relative ranking, a way of determining which types of cohesion ; re ï are high (good) and which are low (bad). : , ip ' To understand what constitutes a module with high cohesion . it is necessary to l ' tar start at the other end and consider the lower cohesion levels. i d- . I 1 'ttl !0 - xQa tolxelpzxvat touzslox ë ' pst in A m odule has coincidental cohesion if it performs multiple , completely unrelated : e- actions. An example of a module with coincidental cohesion is a m odule named m print next Iine, reverse ihe string of characters comprising the second crgument, is add 7 to the fihh argument, convert the fourth orgument fo floating point. An : j ! er bvious question is , How can such modules possibly arise in practice? The most '(lO ( common cause is as a consequence of rigidly enforcing rules such as tçevery module 11I ! E a shall consist of between 35 and 50 executable statements.'' lf a software organization 1 'S, insists that modules must be neither too big nor too small, then two undesirable things . n. will happen. First, two or more otherwise ideal smaller modules have to be lum ped . W together to create a larger module with coincidental cohesion. Second, pieces hacked j - j D ' af . .I nformational cohesion o ood) ' :e , 7. ( Functional cohesion t j zs . 5. communicationol cohesion I zt Frocedural cohesion ; le . 3, Temporal cohesion I . S, 2. Logical cohesion 1 1re n; 1 . Coincidentol cohesion (Bad) l l 's : I i lnf Fl gvee x* Levels of cohesion. :: j I , I , E l' j Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. [...]... iey a t o s ! t ! v leo gl al arabe au f ob v i l ; ! ' d mo i e p l d h r ub k j ' j j Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you : ' ' I j , ' ya coupuNo l y* 2 ca c - cb c whi ( obol arabl == 0) l gl v i e e j ' : i ( gumen x > 25) f or t yz modUe3 (; l ) es le mo ez (; dul ) go l ar l lba v i e ab j z : ' 11 l l V T Fl e %* Commo c pl... orap t t : ia c j 1 : 3 Cod f k y oar ip t 7 e or e b d n u r ; ( ' j j $ p ; n er- ij b F@we 75 Mod etat eror aIipu cn oup t I * k ul h p f ms In t d tu ' Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you t j * ' :! ' : lk ; ; j :' ! ' - ' 11i i I 1 ' !à , l I4: î ji l! k i : ' , - 1* y txAp&KR y * Fo Mo lsf obe ' r m due o its Thea tonsoft... tn st nltoh e m m e r dc o ac do e o e gr a a et rq ie tea to st b e o me i sr sTh y eaj c n i c mmu iain l e u s ein e r r d n ei e a ;1:; !r !( g 1 1 !; ! 1 Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you A o e ' 7 CQHE I a SON yt o l F5 : ' : r c s on be us i addii t bei g pe f r e i s i s t a i a e pe f m ed ohe i ca e, n ton o n r o m d n ele... ode s xa l nty nt e ip itA mao di ee c b t e lgc l o eina dif r to a c h so xt on jr f rn e ewe n o ia c h so n n omain l o ein f J ' ! 1 1 t i j I jI 1 k ! 1 ' Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you i j ' :1 j ' l':, i iI l 1 i:i t l : 1 i 4l y tu A p4:R y Fom Moduls' obi r e o ees i i: l11t i I ' : i(1r i l1 I 1 i.l ( i 1) r ! : oefnii... ep o o etsn lc sse t e d c o nh o rp ne e t i sbe l t ye rbn ie el ohgin.fa h ah r n o c d e l o a o ic e f m c mpeeyu rl e t n h nte ic f n be t o d t eo i ! Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you ' ' : xa Coup uNG 1 yF :' c nci al oi dent f i unctonal i tal sums nii i ze an d open fl ies f i unctonal cr e new eat t mp at e e er ur r d... conrl ou ig to c pl n j s ( ' j' ! 2 c mmo c u lg o n o pi n 1 Cone tc upig (ad tn o l n B ) ; !I i l s : Fl K* Lv so c upig gve e el f o l n ' i l Il Ii 2I i Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you ' 'ë , :(I (' I ) , :I r ! j 1@ F tHA pT:R 7 @ Fom Modul t Obi r es o eds ' i t l 1 i ! q Kaa toxn x: toupux 2 !E : ' I;: ! ' t q Two modul... lgcl e ena na icy es no esVS7pr a d e ; o tr ch in s al f a h o / e f me 1 fee ci s t nefc o t n lpee o d t My r 9 o d 3 f ' !Eé l ' q :! ) i i r ' ' :! !; I Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you i t),! ; 1 : lli'' : ë! Ii j : , ' ! i z r l ( ' 1 n Ld, e ger f od4t o no no t t he 2 i : , ' ;s o Lg, n 4 COHE QN SI Two or ems oc w he a... upul pr am mer a c s he r l a e n pdat h n cr ous ogr a tn aonec n ma una horze c est a r cor i t datbas cig l a ke ut i d hang o ny e d n he a e ' ' a z ' I ! , Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you ii !1 i1 j! ! i; i ' ' ' ii:-: hl I I I ' !I! 1 : i !: : ' ' :$ 11, iIi l : 5 1l , jj i-I'l ! ë ! :1 I !; t : ! 5i I t 1t : ( -I i l':' 1... ' j '1: j g ,I !1 ; Co sd rf re a e tec l c c at wi h dig (mply e rc d)I i n ie, o x mpl,h al alul e t ol n e o e e or t s h , : ;)I1 j: g - I! ( l' l i j - Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you ' ( 1 f j xa CoupuNG l m , ' n n c n lt c n e Ls a i s ! ob o l i es entalf c putng t e w ihhol n buti i dihcul t s e ho t vi us y s s i... ton s u d b nd f t l os i e t s ptmia i ho l e do by a e e i n e s t r e gi e ne n xp re c d ofwa e n ne r ; ' l 1 : g ' i r ! ( ; ! I I 2 l I iE I I! 1' Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you * ' t') ( :j ' I l! 2 ) 'i i : 1 l @@ k ' : 1 j 1j j l1! l - 1 aâ tu A pT.w y @ F om Modul ' Obies r es o e : 2 il l f - !q i1 I ! i K a . ln . . Lts. good software engineering practice? other words, first complete the entire product using ap- l s ln my experience, this question frequently turns propriate software engineering techniques describes the effect on software quality of improving y the software process, and gArthur, 19971, a description of how total quality manage- ; e ment was used to improve software quality within. article regarding acceptance of correctness proofs by the software engineering comm unity is gDeMillo, Lipton, and Perlis, 19791 . : . - The IEEE 4sstandard for Software Reviews'' (IEEE 1028, 19971

Ngày đăng: 07/07/2014, 06:20

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan