1. Trang chủ
  2. » Công Nghệ Thông Tin

Software Engineering (phần 11) docx

40 299 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 40
Dung lượng 2,56 MB

Nội dung

Ei ' j . ! I ' ( ; *1* t u A p T : R Aa * Design Pbose ' ( 1 . () t ; Ia.l@ TKSTIN/ PURIN/ TH: DESI*N PHA:K ' : f ! l The goal of testing in the design phase is to verify that the speciscations have been . j I accurately and completely incorporated into the design as well as to ensure the cor- ! . i rectness of the design itself. For example, the design must have no logic faults and l al1 interfaces must be correctly defined. It is im portant that any faults in the design I . be detected before eoding commences. otherwise the cost of fixing the faults will .! . t be considerably higher. as retlected in Figure l .5. Design faults can be detected by 1 means of design inspections as well as design walkthroughs . Design inspections are1 : j discussed in the remainder of this section, but the remarks apply equally to design l walkthroughs .! t W hen the product is transaction oriented (Section l 3.4), the design inspection i should reiect this IBeizer, 19901. Inspections that include a1l possible transaction ! types should be scheduled. The reviewer should relate each transaction in the de-1 j sign to the specification, showing how the transaction arises from the specitieation j j' document. For example, if the application is an automated teller machine, a transac- ' ! tion corresponds to each operation the customer can pedbrm, such as deposit to or )! l withdraw from a credit card account. In other instances, the correspondence between@ i . l specifications and transactions will not necessarily be one to one . ln a traffic-light .f ' E $ trol system . for example, if an automobile driving over a sensor pad results in thecon 1 i ! i system deciding to change a particular light from red to green in l 5 seconds, then , t further impulses from that sensor pad may be ignored . Conversely, to speed trafhc i I t ! flow, a single impulse may cause a whole series of lights to be changed from red to . i ! reen . g- ; 1 . k Restricting reviews to transaction-driven inspections will not detect cases where ' '1 the designers have overlooked instances of transactions required by the specifications . I To take an extreme example, the specilications for the traffic-light controller may i stipulate that , between l 1:00 P.M. and 6:00 A.M., all lights are to llash yellow in one . ! direction and red in the other direction. lf the designers overlooked this stipulation ,l h en clock-generated transactions at l 1 :00 P.M. and 6:00 A.M . would not be includedl t ( j ' in the design', and if these transactions w ere overlooked, they could not be tested in j a design inspection based on transactions. Therefore. it is not adequate to schedule ' ' i inspections that are just transaction driven', specihcation-driven inspectionsdes gn 1 . ( also are essential to ensure that no statement in the speciscation document has been l ither overlooked or misinterpreted . e ! !' ( '1! ï 1( : j l ( . 1 ' ' ' laal QASE Tooks F@R TH: PKSI/N PHAS: f1 - ' i As stat ed in the previous section, a critical aspect of the design phase is testing that the1 l design document accurately incorporates aII aspects of the specifcation document . ' ! W hat therefore is needed is a CASE tool that can be used both for the specihcation Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. f . : i E : . l ' Iaaa M ETRIKS FoR THE DESIGN PHM E *%@ I 13 1 è ' q .' he design document, a so-called front-end or uppercAsE tool (as : I )document and t l ( opposed to a back-end or 1owerCASE tool, which assists with the implementation, ) j integration, and maintenance phases). ! y ' A number of uppercAsE tools are on the market . Some of the more popular # : 1 i ones include Analyst/D esigner, Software through Pictures, and System Architect. ; ' UppercAsE tools generally are built around a data dictionary. The CASE tool can 1 check that every held ofevery record in the dictionary is mentioned som ewhere in the idesign docum ent or that every item in the design document is reqected in the data llow , ion, many uppercAsE tools incorporate a consistency checker that ' 1 : 1diagram . ln addit i uses the data dictionary to determine that every item in the design has been declared i : Iin the specifications and conversely that every item in the specifications appears in g ë ' I lthe design . j ) Furthermore, many uppercAsE tools incorporate screen and report generators. y l 1 ; 1 I That is, the client can specify what items are to appear in a report or on an input i ! : J . ! . screen and where and how each item is to appear. Because full details regardinx E I ' . -' ' ' *' -''-' -'''' i . every item are in the data dictionary, the CASE tool easily can generate the code for . j inting the report or displaying the input screen according to the client's wishes. y ) lpr . lS ome uppercAsE products also incorporate managem ent tools for estim ating and I : . I planning. J ( ! With regard to object-oriented design, Together. Rose, and Software through ! l . ë iPictures provide support for this phase within the context of the complete object - : tJ ' l oriented Iife cycle. 1 1 , i l i l f' ' j' i 1 ir7 iI ! . 1 ' 3 ( (la . lo KTRIt: FoR THE P ESI/N PHASK i r,1 ! IE ? 1 . . A variety of metrics can be used to describe aspects of the design. For example. 1; I ' lthe number of modules is a crude measure of the size of the target product . M odule : 4 ' . i cohesion and coupling are measures ot the quality of the design, as are fault statistics. ; t As with all other types of inspection, it is vital to keep a record of the number and type 1C - 1:of design faults detected during a design inspection . This information is used during j code inspections of the product and in design inspections of subsequent products. lj! 1 The cyclomatic complexity M of a detailed design is the number of binary deci- ' sions (predicates) plus l EMccabe, 1 9761 or, equivalently, the number of branches in the module. It has been suggested that cyclom atic complexity is a m etric ot design j i quality: the lower the value of M , the better. An advantage of this metric is that it ' ' !i s easy to compute. However, it has an inherent problem . Cyclomatic com plexity is ; ! y p ' ' a measure purely of the control complexity', the data complexity is ignored. That iss l i M does not measure the com plexity of a m odule that is data driven. such as by the : j , values in a table. For example. suppose a designer is unaware ot the C++ library 1 l '( function toascii and designs a module from scratch that reads a character input by '; 1 '. lthe user and returns the corresponding ASCII code (an integer between 0 and l 27) . ! r : 7 .One way of designing this is using a l28-way branch implemented by means of a j , 1 . 1 ;1. : f' '!ù ' ' ' ; I ) Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. 1 i i k ' #Q@ t H A p T E R la @ Design Phose ,i ( :' , j swikh statement. A second way is to have an array containing the l28 characters in ! ASCII code order and utilize a loop to com pare the character input by the user with I 6 each element of the an-ay of charaeters'. the loop is exited when a match is obtained . ' 1 I x . j j The current value of the loop variable then is the corresponding ASCII code. The twe 1 ! designs are equivalent in functionality but have cyclomatic complexities of 128 andI , . 6 l , respectively. . I t ( W hen the structured paradigm is used, a related class of metrics for the design ' I phase is based on representing the architectural design as a directed graph with the . 1 t modules represented by nodes and the flows between modules (procedure and function ' I l calls) represented by arcs. The fèln-in of a module can be dehned as the number of 1 ''' ' ''' '' . ; 1 flows into the module plus the number of global data structures accessed by the : ' j' j module. The fan-out similarly is the number of llows out of the module plus the! , 'k number of global data structures updated by the module. A measure of complexity ' j ! 2! of the module then is given by Iength x ( ,/?zz?-/z? x fan-out) jldenry and Kafura, . I I 98 l1, where Iength is a measure of the size ot the module (Section 9.2.1 ). Because : ù l the deunitions of jttn-in and Iàn-out ineorporate global data , this m etric has a data- ' i 1 dependent component . Neve'rtheless , experiments have shown that this m etric is no ' p . r better a measure ol complexity than simpler metrics, such as cyclomatic complexity l . yKitchenham, Pickard , and Linkman, 1990., Shepperd, 19901.' ! I ! 'j The issue of design metrics is even more complicated when the object-orientedt l paradigm is used . For example, the cyclomatic complexity of a class usually is low,i ! j because many classes typically include a large number ofsmall, straightforward meth- 1 h i ods. Furtherm ore, as previously pointed out, cyclomatic complexity ignores data : complexity. Because data and actions are equal partners within the object-oriented . j : i paradigm, cyclomatic complexity overlooks a major component that could contribute : l j j to the complexity of an objeet. Therefore, metries for elasses that incomorate cyclo- i matic complexity generally are ot little use. i A number of objeet-oriented design metrics have been put forward , for example,! ) in tchidamber and Kemerer, l 9941. These and other metrics have been questioned on q both theoretical and experimental grounds gBinkley and Schach, 1996., 1997., 19981. 1 . ! . - ) ( . I l .t Iaaa A IR G O URM ET CAS: sTupyr ' ! @ BJK<T-@ RIKNTZP p zsloxt I ' l As described in section 13.6, object-oriented design consists offour steps.!E . I ' ê ! s:ep 1. tons:eue In:eyot:ll. plogyom s Ioy Koth n enael. The se- ' ' . l quence diagram for the extended scenario for making a reservation (Figure 12.12) ' $ is shown in Figure l 3. l 8. The sequence diagram was constructed by taking each statement in the scenario and drawing an arrow between the instances of the relevanti lasses. In more detail, first the actors of the scenario were determined: Possenger,: c1 l t I . 1 . ' Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. - E ' . ! . I I Aaaa AIR GOURMG CM E STUDY: O BJKT-ORIENTED DESIGN *QX ' ' l! p : l Phone XiT i ; Passenger Gourmet .l oxrator i database . !) j , request i l reservation j ! . t 2 quel'y name 7 : 1 ' q . ' and address : i ! l 3. give name i 'I l g and address 1! jt 1 ! ! ' . 4 quew flight l'i l t ) information I : ' I ! ( ' , , s. give flight 1 i 5 i ' information ( ! !) - ' 6. query special l l . I )) meal I . I l 17 . give meal i .h ' yinformation , !j . I ' li ! ', 8. query seating ; > j 1 - information E t i 9 iVO Seating ! . g . j information j 5 ( , 10. query payment l - ;information 1 1 r l ! - :. 1 1 . give payment . p r : a information ! , q . ' 12. commit flight t reservation i ) ; : '13 . issue Q reservation ID ' 7 - j' 14. finalize ! I ; reservation l! ; ' i l I I ' Flgvre Aa.1e Sequence diagram for scenario for making a reservation (Figure 1 2. 1 2). ') l ' 1! 1 t .,; Phone Operoer, and Air Gourmet dolobose. Boxes containing the names of these , l ' ) j j ,l z three actors are placed at the top of Figure l 3. 1 8 and vertical double lines drawn y j kt in. Now each event of the scenario is exam ined and entered in the sequence dia- !, i ! 'j . xram . For example, in the first event, the passenger calls a phone operator to make a ' ï ' . ' ! i ' . : 'j ) E ' 1 i - ! Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. l 'j: ! 1 i ,; i I . I ' *QQ t H A p T E R 'a @ Design Phose : p 1 1 . Send postcard + 1 - I * 2. return postcard i 1 passenger j Air Gourmet Staff MemberI . i 1 ! I ' i , ' ; 3. record meal quality l: . j : l t ( ! ë Air Gourme - t database ' ; ' ' j . $ ' l I Aaa. c olloboraùion diogram for scenario for returning and scanning postcordI F 9MKe ' l (Figure 1 2. 1 .4). II 1 1 ion This is modeled by the horizontal arrow from the Possenger vertical , , reservat . ! ; double lines to the vertical double lines of the Phone Opercfor bearing the label 1 . l request reservation. The remainder of the sequence diagram is equally straightfor- . i I . ( ward, as are sequence diagrams for the other classes. ' 1 1 The collaboration diagram for the scenario for returning and scanning a postcard ) ') (Figure 12.14) is shown in Figure 13.19. As with the sequence diagram of Figure . 1 l l 3 . l 8, the first step in constructing the collaboration diagram is to examine the ex- '1 i tended scenario (Figure l 2 . l4) and determine the actors. In this case. they are found .i t l to be Air Gourme, SKff Member. Possenger, and Air Gourmet dclobcse . These! . ) actors are drawn in Figure 1 3. l 9. Next. each event is examined and entered in the I diagram. ln event l , a member of the Air Gourmet staff mails a postcard to each i passenger w ho received a special m eal . First, a line is drawn between Air Gourmei; . 1 Sloff Member and Pqssenger. Then, a labeled arrow is inserted to denote that the ! ' j staff member sends a postcard to the passenger. j The second event is the passengerreceiving the postcard, filling it in, and returning I it to the staff mem ber . This is denoted by the arrow in the reverse direction with theI h label 2. return postcard. 1 The third event is the staff member receiving the postcard and updating the I l relevant flight record to refleet the passenger's opinion of the special meal he or she l ) received. A vertical line is drawn between the icon representing the Air Gourmet . i staff member and the box representing the Air Gourmet database . Finallys an arrow is! ' j added bearing the label 3. record meal quality. The remaining interaction diagramsl j are constructed in the same way. ; I( ' 1 1 s.ep Q. toss,rve. ee p-olled tloss plogrom The detailed class dia- 1 I ram for the c++ implementation is shown in Figure 13.20 and for the Java imple-g . 1 jl mentation in Figure 13 . 21 . One difference between the two figures is that Java has I built-in classes for handling dates, pvq.textwDcieformct and pvcoutil.culendor, . 1 ' , j . ! ( ' 1 ' j . ! Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. ' h ' . ' . i ' ) :Date Flight Record Passenger . i month : short passenger ID : string passenger ID : string ! ! ' month name : string reservotion ID : string first name : s'ring k day : short ffight number : string middfe initial : char '' ' ! year : short flighi date : string Iast name : string I 1 ber : string 1 * suffix : string 1stc date : string seat num meal type : m-type address 1 : string . et month () meol Ioaded : boolean address 2 : string j i i9 . set month () on board : boolean city : string I j t month name () perc meal quolity : int state/province : sùring ' ''9e J jt sef monfh nome () posàal code : sàring t day () 9et passenger ID () jry : strino j!, :,ge coun ' et day () 5et Possenger ID ()s I et year () 9et reservation ID () get jassenger ID () 1: . 9 I set year () set reservation ID () get flrst name () I : et str. dute () get flight number () set middle initial () 1 . ' 9 set str. date () set flight numLer () get last name () 1 . . is Ieap year () :et flight date () get suffix () ' '' da s in month () set flisht daie () get address 1 () ' :t' t number () get address 2 () !r ' :valld date () :et sea breok up date () set seat number () get city () k . set meal type () get state () E set meal type () get postal code () ' E get meal Ioaded () et country () j ;@ iset meal loaded () lnsert () . E . jgef on board () write () '. I ! I set on board () read () : i . ' . get perc meal quality () get passenger () ' . l t erc meal quality () get descripfon () ' , : l 1se p l ! k ' insert () . i write () . : .' reud () : ( ' ' g ' J gef reservofion () l ;: ' ! check in possenser () ; ' , scan speciol meals () ! E scan postcard () .1 check reservation id () ! 4check flight number () . ! 5 h k seat number () i 1: :C ec I . 1 Ialready exists () . ! . j '* . I 1 'C ) !t ' Report 1 from date : string 2 ' date : string i 'to ) I l get from date () 'I l get to date () !l set from date () I' ! set to date () . Ii ! Iprint () ' ) ' ) ' 1 * ' ' ' virtuol I l ' ge# juolificofions () . i J '' I quullfies for report () ' rint record () ; 'P 1! , I Flgvre 1a.Q@ Detailed class diagram for C++ implementction of the Air Gourmet product. j '. Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. ) ' . i i 1 *Q* t H A p T E R 'a * Design Phose5 1 Report ! l from date : oate . 1 to dafe : Date 1 . . oet from dote () . ' t gej to dote () . 1 set from date () . 1 1 set to date () 1. print () .I virduol . 1 et qualijicagions () : 9I ualifies for report ()q . 1 print record ()l ! l l I l ! ; Percentage Report Low-sodium Report Poor-ouality Report i 1 ' l Iouded as specified ,i 1 Iifies for report () quolifies for report () pussenger on board, qua: l int record () . . totol encountered, pr' . j j tj tj : ; nt j g a jnot oa e I , ! print ()i ' Iifies for report () . ) : l qUa . ! print record () '! . ' j i N ot-Loaded Report Onboard Report Caterer Report : j flight number : string fligh@ number : string j print () special meal tally : . 1 qualifies for report () i nt () kntl 1 a)l Pr print record () jjgcotions ()l get qtla au , already encountered () q jifjes jor report () print ()l no9 Ioaded > once () ' ef qualifications ()9 1 qualifles for report ()l Flgure 13.2* Detailed class diagram for C++ implementation of the Air Gourmet product (continued).) 1 E ) ' whereas a user-defined class Do1 is needed in the C++ implementation. Another : ' I difference is that Java is a pure object-oriented language, that is, a Java program l consists of a set of classes , whereas C+ + supports functions. W ith regard to this ! I difference, the class Air Gourme' Applkadion corresponds to C++ function mcin, ' i and class Air Gourmel Uiilities corresponds to C++ utility functions. l The methods for the product appear in the various interaction diagrams . The task of the designer is to decide to which class each method should be assigned. ln the . j ' Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. i ' IAi r Gourmet Application Flight Record Passenger passenser ID : string pussenser ID : string . . ' ID tring first name : s'ring E .reservation : s flight number : string middle initial : char C , flight date : Date Iast name : string I i 1 * suffix : string ! 1seat number : strinn . ''''' 1 meal type : m-type address 1 : string j meal Ioaded : boolean address 2 : string iAir Gourmet Utilities . on board : Eoolean city : string i . perc meal qualiiy : int state/province : string ! , ! get character () ostol code : string E IP read string () get passenger ID () country : string 1; ' clear screen () set passenger ID () lE . ' press enter () get reservation ID () get passenger ID () 1.1 E . . display main menu () set reservation ID () get first name () 1. ' display report menu () get flight number () get middle inifal () '!: . set flight number () get Iast name () li y ' get flight date () get suffix () 1'; set flisht date () get address 1 () ( ' get seat number () get address 2 () I ' set seat number () qet cify () 1 ' j '' ê' ' .get mea type () get state () ! set meol type () get postal code () ! . et meal Ioaded () get country () t9 set meol Ioaded () insert () j . i board () write () ! : lget on l set on boord () read () ! . IE : get perc meal quality () get passenger () ! . l ' I Ii () et description () ! ' 'set perc mea qua ty g l! ' insert () ' i . - I write ( ) . ! , J read () : i I get reservation () . ' . check in possenger () g ' scan special meals () ' scan postcard () check reservation id () '' , . ) ' check flight number () I . i check seat numlxr () .1 1:1 ' already exists () , . l 1 * j 1' 1 1. neport Ii Ii . 11f rom date : Date ! to date : Date ! , . !i get from date () j ! d te () iget to a j I set from date () . 1 , ' ' t to dote () ! ' 1se j . int () ' ! i 1pr ! obsirod i j j get qualifications () ! 1 :lquclifies for report () ' : ' print record () Flgvee la.Ql Detailed closs diogram for Java implementaiion of the Air Gourmet product. j: 1- Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. I i I 1 , ! I . ' ' 21 t u A p T : m Ia * Deslgn Phose*! . ! ! ? ReportIi Il 1 from dote : Dote l ' to date : Date1 I l f m da. ()i 9Of UOl : E ! get to date () ! set from date () ( ! ' . ! Set tO date () . j prjnj ()l obstrotjl j ualifications (); e; 9 qi j ualifies for report ()q . , j prknt record () ' rï j . 1 ' 1 1 2 . jl ti ; . l Percentage Report Low-sodium Report Poor-ouality Report , l .1 : i l Ioaded as specified, ' f passenser on boord , qualifies for report () quolifies for reporf () : . I i d ( ) .t otal encountered, Print recor' ' ; ' 11 I not loaded : intg 1 31 1 ' '' ' ''' . 1 1 . i print ()1 : t y j qukaoltifies for report (), pr record () . q à! ! Not-Loaded Report Onboard Report Caterer Report flight number : string flight number : string . ' . print () iaI meal tally : .spec r qualifies for report () i nj () jnfjla) 'l i nt record () PVpr ej qualifications ()1 already encountered () 9 ' 1 aualifies for report () print () not Ioaded > once () ' t uolificafions ()i l ge q : i i Iifies for report ()i i 9t11 . ' ! j 'i 2! ! Flgur. 1a . 24 Detailed closs diagrom for Javo implementation of the Air Gourmet product (continued), . j ô - l 1 i I ! l 1 ! , i ! case of the Air Gourmet product, the assignments of methods to classes is straight-I k q forward. For example, method get passenger ID clearly belongs in class Pcssenger. . i . 'i ! s'ep a. peslgn :lxe produe In Tey-s ol oblees d Th@lr tII@nI, 1 The third step of OOD is to design the product in terms of objects and their clients , ' j 1 as described in Section l 3 . 7. The client-object relations are shown in Figure 13.22! 1 . j l ) . I! Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. I : I ! . laaa AIR GOURMET CAS: STUDY: OBJKT-ORIENTED DKSIGN #2T i ; . ( main I : . L 2' j . . . j . ' j display main menu j ! ! ' j l l. I .: 1 ! display report menu : é f . j . * 1 . ( ' 1 i! ' . ; j . 1! percentage Not-Loaded onboard ; 1 Report Report Report 1! ; i : - lC aterer Poor-ouality Low-sodium : Report Report Report i ë E ' j- t j I q l: , ! - 1t - i r I . g ; lR eport ' i ' ' ; : t .l . i i ' .' ' ) ' j : . 'i j 'i è , Flight Record Passenger l . 1 l : : ' 1! t . I j j IDate 12 j 1 ' l jj d - ' ' 'Igure 'a.2Q Client-obiect relations for C++ implementation of the Air Gourmet product. . r i l i1 i (for implementation in C++) or Figure l 3.23 (for implementation in Java). These 1 il : -' are not UML diagram s. They are included in this book because my experience is that , ! ' jdiagrams of this kind can assist in gaining an understanding of how the various pieces ' i h 4 j 1 . of the product fit together and, in particular, can make the detailed design easier to ) r I 1 I 7 j ! construct. j The client-objeet relation diagrams were construeted by taking each CRC card ! and determ ining which methods of other classes are invoked by methods of that class. ' II Ii . I . 11; ' i ; Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. . your c p lrepresentation is superior? Give reasons for your answer . 4 ! 1.13 (Readings in Software Engineering) Your instructor will distribute copies of (Stolper, 1 ! . ' t l 9991. What. BElzER, Software Testing Techniques, 2nd ed., Van Nostrand Reinhold, : New York, I 990. 1 t Bias, I 99 l 1 R. BIAs, ''Walkthroughs: Efficient Collaborative Testing.'' IEEE Software. products for over 25 years. The entire zoo-member software ' 1 j staff of QQQ. from the mostjunior programmer to the vice-president for software, hasi 1 COBOL expertise. W hy on earth should

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

TỪ KHÓA LIÊN QUAN