PUBLIC ANSWERS TO EXERCISES PA6 E2. 25 No public answer E2.26 No public answer E2. 27 No public answer E2.28 No public answer E2. 29 No public answer E2.30 No public answer E2.31 No public THESE ANSWERS SUPPORT THE BOOK OBJECT ORIENTED SOFTWARE ENGINEERING
PUBLI C A NSW ERS T O EX E RCISE S PA6 T HE SEAN SW E RS SU PPORTT HEBO OK O BJ ECT O RI E NTEDSO FTW AR E E NG INE ER ING : E 2.25 No public answe r E 2.26 No public answe r E 2.27 No public answe r E 2.28 No public answe r E 2.29 No public answe r. E 2.30 No public answe r E 2.31 No public answe r
PA7 PUBLIC ANSWERS TO EXERCISES Chapter 3. Basing software development on reusable technology E3. 1 p. 63 Researching resources on the Internet that discuss aspects of reuse The answer to this question will vary since web pages are continually being added, deleted and changed E3. 2 p 63 Analysing information about reuse. For discussion only 3.3 pp. 69-70 Determining the services that should be present in a framework a)"Reservation framework Add an instance of whatever that can be reserved(e. g. a book, a place on a flight, a seat in a theatre) Add an instance of whatever the reservation is made on behalf of(e.g. a library patron, a passenger,a theatre-goer) Make a reservation · Delete a reservation E3.4 P. 70 Determining differentiating features of framework-based applications, as well as its hooks and slots a)*Reservation framework Differentiating features The classes of objects that can be reserved and their attributes, associations and other operations The attributes of the reservation itself, and perhaps subclasses representing different types of reservation The classes of objects that a reservation can be made on behalf of The user interface Rules regarding the reservation such as who can make one whether the item can be reserved eto · Hooks A function that would be called when a reservation is complete(e.g. to send an email) An function to call when reservations are full that could be used, for example, to add a waiting list, or to give some form of notification to the user A function called to load a reservation from a database a function called to save a reservation There may be no slots in this system E3.5 p. 70 Determining the range of applications that might benefit from a framework. a)*Reservation framework A library system, where you can reserve items that are already checked out Reservation of seats on any kind of transportation system Reservation of entertainment tickets E3.6 p. 70 Evaluating alternative approaches to designing a framework. a) *If you started with a vertical framework for a frequent flier program, you would have a lot of facilities already developed, some of which would be quite specific to the frequent flier domain. The following gives some ideas of the services, slots and hooks that might be provided; many variations on this answer are possible 1. Services Maintenance of frequent flier accounts to which points(miles) can be added and redeemed (i.e adding new accounts; deleting accounts) Keeping of basic personal information(name, address, points)about each frequent flier, with methods to update this information(which would call the first hook below to allow managing of additional information) Keeping of a log of flights to be used when producing reports(would also be capable of recording other transactions, e.g. points awarded for renting a car) Methods to add, delete and query the number of points in the account C 2002 TIMOTHY C. LETHBRIDGE AND ROBERT LAGANIERE
PA7 PUBLI C A NSW ERS T O EX E RCISE S © 2002 T IMO TH Y C. LE T HBRI D GEA N D RO BERT L AG AN I ÈRE Chapt er 3. Basi ng sof tw ar e developm enton r eusable technol ogy E 3.1 p. 63 Re se arc hing re sourc e s on the I nternet that disc uss aspe cts of re use . T hea nsw erto this question will va r y sincew e b pa ges a r e continua lly being adde d, de leted and c ha nge d. E 3.2 p. 63 Analy sing information about re use. Fordisc ussion only. E 3.3 pp. 69-70 D eterm ining these rv ice s that should be pre se nt in a frame work. a )*R eser vat ion f ram ew or k. • A dd a n instanc e ofwhate ve r tha t c an ber ese rved (e .g. abook, apla c e on a flight, a se a t in a the atre ) • A dd a n instance of w hateve r the r ese rvation is made on behalf of ( e.g. a libra ry pa tr on, a pa sse nger , a the atr e- goe r) . • Make ar ese rvation • D eleteare se r va tion E 3.4 p. 70 De te rmining diffe re ntiating fe ature s of fram ework -base d applications, as well as its hook s and slots. a )*R eser vat ion f ram ew or k. • D if fe r entia ting fe ature s: - T hec lasse s of objec ts tha t ca n be r eser ved a nd the ira ttr ibute s, assoc ia tions a nd otheroper ations - T he a ttr ibute s of the r ese rvation itse lf , a nd pe rha ps subc la sse s r epre senting dif fe re nt types of r eser vation - T hec lasse s of objec ts tha t a r eser vation c an bema deon beha lfof - T heuserinte rf a ce - Rules re ga r ding the r eser vation, suc h as who c an ma keone, w hethe rtheitem ca n be re ser ve d, etc . • H ooks: - Af unc tion that would be c alle d w he n ar e se rva tion is c omple te (e .g. to send a n e ma il) - A n function to c all w he n r eser vations ar e‘ full’that c ould be use d, f or exa mple , to a dd awa iting list, or to givesomeform ofnotific ation to theuser . - Af unc tion ca lle d to load a re ser va tion f rom adata ba se . - Af unc tion ca lle d to sa veare se r va tion. • Slots: - T he rema y be no slots in this syste m. E 3.5 p. 70 De te rmining therange of applications that m ight benefit from a frame work. a )*R eser vat ion f ram ew or k. • Alibr ar y syste m, whe reyou ca n r ese rve ite ms that ar e a lr ea dy che cked out • Reser vation of sea ts on a ny kind oftr ansporta tion syste m • Reser vation of e nter tainme nt tickets E 3.6 p. 70 Ev aluating alte rnativeapproac he s to de signing a frame work. a )*I f you sta r te d w ith a ver tic al fr ame work for a f re que nt flie r progra m, you w ould ha ve a lot of f ac ilities a lr ea dy de velope d, some of w hic h would be quite spe cific to the f r eque nt flier doma in. T he following gives some idea s of the se rvic e s, slots a nd hooks tha t might be pr ovide d; ma ny va riations on this answe r a repossible. i. Ser vic es: • Mainte na nc e of f re que nt f lie r a cc ounts to w hic h points (mile s) c a n be adde d a nd re de e me d ( i.e. a dding new ac counts; de le ting a cc ounts) • K ee ping of ba sic per sonal infor ma tion (na me , a ddre ss, points) a bout ea c h fr e quent f lie r, w ith methods to upda te this inf or ma tion ( whic h w ould ca ll the f ir st hook be low to a llow ma naging of a dditional infor ma tion) • K ee ping of a log of f lights to be used w hen pr oduc ing r e ports ( would a lso be c apa ble of re c or ding othertr ansac tions, e .g. points a wa r de d f orr e nting ac a r) . • Methods to add, de le te and que r y thenumberofpoints in theac count
PUBLIC ANSWERS TO EXERCISES Generic mechanism, given two cities, that would calculate how many points would be required to fly between them for free for a given user. This would be called when customers are doing queries and also when a person actually books a free flight to determine how many points to deduct This would call the first slot below to do detailed calculations Generic mechanism, given two cities, that would calculate how many points to credit to a particular frequent flier who pays for a ticket. It would be called when the user is making queries, and also when a person actually takes a flight, in order to credit points. This would call the second slot below for detailed calculations Generic mechanism that runs every month, calling the slot(below) for producing reports, and the hooks(below) for deleting inactive accounts, and perhaps promoting users to different classes i1. Slots(code that must be provided) a method to evaluate rules regarding how many points are required to fly certain routes for free A method to evaluate rules regarding how many points are obtained from flying certain routes (might be specific to certain classes of frequent flier, certain times, etc. A method to produce a formatted printout of a frequent fliers account(each airline may want to make these appear stylistically different from other airlines). Note that instead of creating a slot, this functionality could be left out of the framework entirely Note that the user interface would have to be provided but would probably not actually appear as slots in the basic system; the user interface would be a separate subsystem that would simply call the iii. Hooks(places where optional add-ons can easily be plugged in) Ability to manage additional types of information about frequent fliers(e. g. work address, email, ) beyond the basic minimum information. Different airlines might want to keep different kinds of information for use in marketing etc ability to have different classes of users (e.g. prestige users who have accumulated large numbers of Mechanism to delete accounts after a certain time period with no activity(this might be activated by the monthly run that prnts reports) ability to add different kinds of points to be used for different purposes(e.g. some airlines, in addition to miles, also keep track of a separate count of miles flown in first class; such points might have different rules, such as expiring after the end of a year) E3.7 P. 70 Eraluating whether or not one should first develop a framework when designing an application a)* Arguments in favourof developing a full frequent flier framework Developing the framework improves your overall design. Since you would have to build flexibility into the framework to allow it to be used by others, you would benefit from that flexibility when you have to make changes yourself As a consequence of the above, you would expect maintenance costs to be reduced; you would also expect to be able to respond faster to market-driven requirements changes You might be able to sell your framework to others, or to provide frequent-flier services to other smaller airlines Should two airlines using the same framework decide to work together in an alliance(or to merge)their systems would be more compatible with each other, reducing costs E3.8 P 74 Evaluating whether an application should be designed as a client-server system or not a ) *Word processors are not normally designed using a client-server architecture. The following are some of the reasons why not People typically use word processors on laptop computers or other machines that may not be connected to any network Although people do share word-processed data, most people work on their own local copy and then share it when they are finished It might be beneficial to allow a word processor to optionally connect to a server to do such things as load and save data, or to enable two people to edit the same document concurrently. However it would still be necessary to ensure that the user could operate the program while not connected THESE ANSWERS SUPPORT THE BOOK OBJECT ORIENTED SOFTWARE ENGINEERING
PUBLI C A NSW ERS T O EX E RCISE S PA8 T HE SEAN SW E RS SU PPORTT HEBO OK O BJ ECT O RI E NTEDSO FTW AR E E NG INE ER ING : • G ener ic me c ha nism, give n two c ities, tha t w ould ca lcula te how many points w ould be re quire d to f ly be tw ee n the m f or fr ee for agive n use r. T his w ould be ca lle d w he n c ustomer s a re doing que rie s, a nd a lso w hen a pe rson ac tua lly books a f re e f light to deter mine how ma ny points to de duct. T his w ould ca ll the f ir st slot be lowto do de taile d c alc ulations. • G ener ic me c ha nism, give n two c ities, tha t w ould ca lcula te howmany points to c re dit to apa rtic ula r f re que nt f lie r w ho pa ys f or a tic ke t. It would be c alle d w he n the user is ma king quer ies, a nd a lso w he n aper son a c tually ta kes aflight, in orde r to cr edit points. This would c all these cond slot be low f orde ta ile d ca lcula tions. • G ener ic me c ha nism tha t runs eve ry month, c alling the slot ( be low ) f or pr oduc ing r e ports, and the hooks (below)f or de leting ina c tiveac counts, and per ha ps pr omoting use rs to dif f er ent c la sse s. ii. Slots (c odetha t must be provided) • Amethod to e va lua terule s r ega rding how ma ny points ar ere quire d to fly c er tain r oute s f orfr ee . • A method to e va lua te rule s r ega rding how ma ny points ar e obta ined fr om flying ce r ta in route s ( might be spe cif icto c er tain c la sse s offr equent f lier , c er tain times, e tc .) • A method to produc e a f or matte d pr intout of a fr e quent f lie r’ s a cc ount (e a ch a irline may wa nt to make the seappe a r stylistica lly dif f er ent f rom othe r air line s). N otethat instea d of c re ating a slot, this f unctionality c ould be le f t out of thef r amew ork e ntire ly. • N ote tha t the user inter fa c e would ha ve to be provided, but w ould proba bly not ac tua lly a ppe ar a s slots in the ba sicsystem; theuserinte r fa cewould be asepa ra tesubsystem that would simply c a ll the ser vic es. iii. Hooks (pla c es w her e optional a dd- ons c an ea sily be plugged in) • A bility to ma na ge additional type s of inf or ma tion a bout fr equent f lier s ( e.g. wor k addre ss, e ma il,), beyond the ba sic minimum inf or mation. Dif fe re nt air line s might wa nt to ke ep diff e re nt kinds of inf or mation f oruse in ma r ke ting etc . • A bility to ha vediff er e nt c lasse s of use rs (e .g. pre stigeuser s w ho ha veac cumulate d la r genumber s of points) • Mec ha nism to de lete a cc ounts a f te r ac er tain time per iod w ith no a ctivity ( this might bea c tiva ted by themonthly r un that pr ints re por ts) • A bility to a dd diff e re nt kinds of points to be use d for dif f er ent pur poses (e .g. some a ir lines, in a ddition to mile s, a lso ke ep tr ac k of a separ a tec ount of miles f low n in fir st c lass; such points might have dif fe r ent r ules, suc h a s e xpir ing a f te r thee nd ofa ye a r) . E 3.7 p. 70 Ev aluating whe the r or not oneshould first de ve lop a fram eworkwhen de signing an applic ation. a )* A r gume nts in favour ofde ve loping af ull f re que nt flie rf ra mew or k: • D e ve loping thef r amew ork impr ove s your ove ra ll de sign. Sinc e you w ould have to build f lexibility into the f ra me w or k to allowit to be use d by othe r s, you would be ne fit f rom tha t f le xibility w hen you ha ve to ma ke c ha nge s yourself . • A s a c onse que nc eof thea bove , you would e xpe ct ma inte nance costs to be re duc ed; you would a lso e xpe ct to beableto r e spond f asterto mar ket-dr iven re quire me nts c hange s. • Y ou might be able to se ll your fr ame work to othe rs, or to pr ovide fr equent- f lier se rvice s to other smalle r a ir lines. • Should two airline s using the same f ra me w or k dec ide to w or k together in a n a llia nce ( or to me rge ) the ir syste ms would bemor ec ompatible with ea c h other , r educ ing c osts. E 3.8 p.74 E valuating whether an applic ation should bede signe d as a client- serve r systemor not. a )*Wor d proce ssors ar e not normally de signe d using a c lient-ser vera r chite ctur e . Thef ollow ing a re some of ther e asons w hy not: • Peopletypica lly use word pr oc essor s on la ptop compute r s orothe rmac hines that ma y not bec onnec te d to any netw or k. • A lthough pe ople do shar e w or d- proce sse d data, most pe ople wor k on their own loca l c opy a nd then sha reit w hen they a r e finishe d. I t might bebene ficia l to allowaw or d proc essorto optionally conne ct to ase rver to do suc h things a s loa d a nd sa ve da ta , or to enable tw o people to e dit the sa me document c oncur re ntly. H owe ve r it w ould still be nec essar y to ensur e tha t theuserc ould ope ra te theprogra m w hilenot c onne c te d
PUBLIC ANSWERS TO EXERCISES E3. 9 p 74 Determining the services to be provided by a server. a)*An airline reservation server would be expected to do some of the following activities Maintain the list of flights along with basic details of each flight(and allow changes) Maintain the pnces(and allow changes, special offers etc. Maintain the bookings(allow bookings to be made, changed and deleted) Allow people to query all of the above E3.10 P. 79 Evaluating the balance of work on the client and server side of a system a)* For an airline reservation system 1. Server work: See exercise E3.9 ii. Client work. Enter queries about available flights and display the results Display and print itineraries iii Information transmitted from server to client Results of queries(relatively simple text) iv: Information transmitted from client to server: Simple commands and their arguments v: How the client's work could be minimized or maximized The client might be interacting with several different reservation systems, producing overall itineraries that would combine the results from several servers. A server could be developed to provide this function -interacting with other servers and managing itineraries The client could, on the other hand, be given a lot of intelligence to work out itineraries and good deals. It could find the best prices, and even run a bidding mechanism that would try to get airline servers to give better deals The client could simply be a web browser with no intelligence at all about the frequent flier domain vi: Network effects of changing the client's workload Putting more intelligence into the server(such as having the server interact with other servers) would have only a moderate effect on the quantity of information transmitted in the network as a whole Adding extra intelligence to the client might result in large numbers of queries being transmitted, and large numbers of replies returned. The client would need to perform these queries in order to marshal the information it needs to make decisions laving the client become nothing more than a web browser, would probably increase netw traffic from the server to the client, since now the server would have to transmit images and all other information that will make the ui of the client look nice E3. 11 p. 80 Writing protocols for a client-server system There are clearly many possible protocols for these systems, the level of complexity could become substantial the following shows some basic sets of messages that could be exchanged a)*Airline reservation system. Note that a real system can be extremely complex; the following represents a simplified view of the kinds of messages that such a system would need to exchange Messages to server Possible replies to client addRegularFlight number plane Type effective Date confirmFlightAdded number flightNumberAlready Exists addFlightLeg flightNumber origin leave Time destination arrive Time confirmLegAdded flightTimeConflictsWithAnotherLeg deleteRegularFlight number effective date confirmDeletion flightNumberDoesNotExist C 2002 TIMOTHY C. LETHBRIDGE AND ROBERT LAGANIERE
PA9 PUBLI C A NSW ERS T O EX E RCISE S © 2002 T IMO TH Y C. LE T HBRI D GEA N D RO BERT L AG AN I ÈRE E 3.9 p.74 D eterm ining these rv ice s to beprov ide d by a serve r. a )*A n air line re ser vat ion ser ve r would be e xpec ted to do some of thef ollow ing a ctivitie s: • Mainta in the list off lights along w ith ba sic details ofea ch flight (a nd allowc hange s) • Mainta in the pr ice s ( and a llowchanges, spe cia l of f er s e tc .) • Mainta in the bookings ( allowbookings to bema de , c ha nge d and dele te d) • A llowpe ople to quer y a ll ofthe above E 3.10 p. 79 Ev aluating thebalanceof work on thec lie nt and serve r sideof a system . a )*F oran air line r eser vat ion syst em : i. Ser ve rw or k: Se ee xe r ciseE3.9. ii. Client w or k: • E nterque rie s about a vaila blef lights a nd display the re sults. • E nterbookings • D ispla y and print itine ra r ie s iii. I nf or mation tra nsmitted f r om se rverto c lie nt: • Results ofquer ies ( r elative ly simple te xt) iv: I nf or mation tra nsmitted f r om c lie nt to se rve r: • Simplec ommands and the irar guments. v: H owthe client’ s w or k c ould beminimiz ed orma ximiz ed: • T he c lie nt might be inter a cting w ith seve ra l dif fe r ent r eser vation systems, pr oducing over a ll itine r ar ie s tha t w ould combine the r esults fr om se ver al se rve rs. A ser ver c ould be de velope d to provide this function – inte ra c ting with othe rser ver s a nd ma na ging itine ra r ie s. • T hec lie nt could, on the other ha nd, be given a lot of ‘ inte llige nce ’ to wor k out itiner ar ies a nd ‘good dea ls’ . It could f ind the be st pr ic e s, a nd eve n run a bidding mec hanism tha t w ould tr y to get a irline ser ve r s to givebe tte r de a ls. • T hec lie nt could simply beaw e b br owserwith no inte llige nc ea t a ll a bout thef r eque nt flierdoma in. vi: N etwor k ef f ec ts ofc hanging the c lie nt’s workloa d: • Putting mor e intelligence into the ser ve r ( suc h as ha ving the ser ver inte ra c t with other se rver s) w ould ha ve only a moder ate e ff e ct on the quantity of inf or ma tion tra nsmitte d in the ne tw or k a s a w hole . • A dding e xtr a intelligenc e to the c lient might re sult in la r ge number s of que rie s be ing tr ansmitted, a nd la rge numbe r s of re plies r e turne d. T he client w ould ne ed to pe rf or m the se que ries in or de r to mar sha l theinf ormation it nee ds to ma kede cisions. • H aving the clie nt be come nothing more than a we b browse r, w ould proba bly incr ea se ne twork tra ff ic fr om theser ver to the clie nt, sinc e now the se r ve r w ould ha ve to tr ansmit ima ge s a nd a ll the otherinfor ma tion tha t will ma ke theU I of thec lie nt look nice . E 3.11 p. 80 Writing protoc ols for a c lient-serv er sy stem . T he rear e c le ar ly ma ny possibleprotoc ols f orthesesystems; the level ofc omple xity c ould be come substantia l. thef ollow ing show s some basicse ts ofme ssage s tha t could be e xc hange d. a )*A ir line re ser vat ion syste m . N otetha t ar e al system ca n be extre me ly complex; the following re pr e se nts a simplified viewofthe kinds ofmessages that such a syste m w ould ne ed to e xchange. M essages t o ser ver P ossibler e plie s t o c lient • addRegularFlight num be r planeType e ffe ctiv e Date confirmFlightAdded numbe r flightNumberAlreadyExists • addFlightLeg flightNumbe r origin leave Tim e destination arrive Tim e confirmLegAdded flightTimeConflictsWithAnotherLeg • deleteRegularFlight num be r e ffe ctiv e Date confirmDeletion flightNumberDoesNotExist
PUBLIC ANSWERS TO EXERCISES addFareclass fare Code confirmfareclass fareClassAlready present setFare origin destination class Code start Date enddate firmA addBooking name date flight originCity destination City fareClass confirmBooking confirmation Number seat bookingcannotBeMade reason deleteBooking confirmation Number f bookingNotcancelled reason confirmationNumber Invalid queryFlightAvailability date origin destination fare Class earliestDeplime latestArrTime availableFlight date flightNumber fareClass noMatchingAvailableFlight queryBookings name date confirmBooking confirmationNumber seat query BookingsByNumber confirmationNumber booking Info flightNumber date name origin destination fare Class seat queryPassengers flightNumber date bookingInfo flightNumber date name origin destination fare Class seat THESE ANSWERS SUPPORT THE BOOK OBJECT ORIENTED SOFTWARE ENGINEERING
PUBLI C A NSW ERS T O EX E RCISE S PA10 T HE SEAN SW E RS SU PPORTT HEBO OK O BJ ECT O RI E NTEDSO FTW AR E E NG INE ER ING : • addFareClass fareCode confirmFareClass fareClassAlreadyPresent • setFare origin destination c lassCode startD atee ndD ate confirmFare • addBooking nam e date flight originCity de stinationCityfare Class confirmBooking c onfirmationNum ber se at bookingCannotBeMade reason • deleteBooking c onfirmationNum ber confirmBookingDeletion bookingNotCancelled reason confirmationNumberInvalid • queryFlightAvailability date origin destination fare Class e arlie stD epTim e latestArrTime availableFlight da teflightN umberf a re Cla ss noMatchingAvailableFlight • queryBookings nam e date confirmBooking c onfirmationNum ber se at • queryBookingsByNumber c onfirmationNum ber bookingInfo flightNumbe r date nam e origin destination fare Class seat • queryPassengers flightNumbe r date bookingInfo flightNumbe r date nam e origin destination fare Class seat