An abstract data type Section 7.5 is a data type, together with the.. ; a class, an abstract data type that supports inheri tance Secti on 7.7.. Now suppose that the product j I develope
Trang 1! ; met hod open method open method open
k I ' for a sk file for a tape file for a diskette fil
J ! , now det er mi nes whet her myFi l e i s a di sk f i e, a t ape f i e, or a di s ket t e f i e and i n- '
j l i l t vokes t he appropr i at e vers i on of open That i s t he syst em det er mi nes at r un t i me '
hether object myFi s e is an i nstanee of class Di skFil ecloss, class TopeFil ecloss, or '
in many different shapess i ncluding hard diamonds and soft graphit e so the
1 t l
I @ E l m ethod open comes in three different versions ln Java, these versions are denoted
' @ ! I kFi l ecl oss.open, TcpeFi l ecl ass.open, and Di sket teFi l ecl oss. open. (In C++, the
I r, i I Di s
1 j i period is replaced by two colons
,and the hl es are denot ed Di skFi l ecl ass:: open, l
k
: i
l
j : TapeFi l ecl ass: :open, and Di skett eFil ecl ass:: open ) However, because of dynamic
I !. I binding, it is not necessary to determine whi ch met hod to invoke to open a
1 ! ; Bcse but also of any subclass of class Bose
,that is, any class derived from Base A ll '
Trang 2I !
'
j
Ir.r
;1(
r j ' ) I
I !1
t hat i s needed is to i nvoke thetkorder and everyt hing will be taken care of at run j
time.This technique is extremely powerful, in that the software professional need not !
be concerned about the precise type of an argument at the ti me t hat a message s sen
lH
owever, pol ymorphi sm and dynami c binding also have major disadvantages I :
j
First
,it generally is not possible to determ ine at compilation time which version of a
. specific polym orphic method will be invoked at run tim e Accordingly, the cause of j
' Second, polymorphism and dynam ic binding can have anegative im pacton m ain- : $
- tenance The first task of a m aintenance programm er usually is to try to understand j
e t he product ( as expl ai ned i n Chapt er 16, t he mai nt ai ner ar el y it he per son who de- t
S for a speci fic method The programmer has t o consider all the possi ble methods that l 1 : j
C could be invoked dynam ically at a specific place in the code
, a t
ic binding add both strengths and weaknesses to the 1 l
j '
e reasons for the superi ority of t he object-ori ent ed paradigm given in Sec- t ) :
e tion l6 included conceptual and physical independence To measure this indepen- l I
; l I
7 dence.t he concepts of cohesion and coupling must be reexami ned within the cont ext j k i
j
I j 1
h ther special types of cohesion and coupling occur within i
3 The question arises as to w e
i i
S Fi rst consider cohesion (Recall t hat, as explained i n Secti on 7 2, t he cohesi on of 1 : i
l a modul e is the extent to which the actions performed by t hat module are functional ly ( 1 ' j
I : !
'
j
j
I ' ' '
I
Trang 3j ' related) A cl ass can include actions of two kinds, inheri ted methods and met hods
k 1 specif ic to that class The cohesion of a cl ass is determined from its functionalit y,
yi , of cohesion In other words, no types of cohesion are specific to classes', cohesion
1 appl ies equal ly t o a1l types of modul es
,i ncluding cl asses ( Schach, 19961.
; I coupling betw een two classes clearly can be determ ined as in the classical paradigm
l ' i ! y' or examp le i f an at tri bute of a class i s del ined to be publk (accessible t o all ot her
,
1 t i l : uni t wi t hi n t he pr od uc t , he n t hi s c n i nduc e c ommon coupl i ng wha t s ome wha t
l ising however, is that inheritance does not induce new forms of coupling That
k ? paradigm does not induce new forms of ei ther cohesion or coupl ing 4
l However, a number of metrics specil ic to t he object-oriented paradi gm have J
k : be shown that there is a need for speciticall
y object-ori ent ed metrics, as opposed to I (
r action is perform ed on it, and actions without associated data are equally m eaningless a)'j i Therefore, techniques that give equal weight to data and actions are needed. It should t)
Trang 4,instance variables, ji elds, or data members The acti ons are call ed j
ts methods or memberfunctions But irrespective of t he terminol ogy used for data and I l
q ,
, bot h are present i n objects as equal part ners Si milarl y, in all the object- !
l orand neii nt edther takes precedence over e hni ques , dat a an d a t onsthe other.r cons i der ed o b of he a me mpor t an ce, j1i !j
I
n techni ques of t he object-ori ented paradigm From the mat erial on st epwise refi nement ' I j
e, ( Secti on 5 ), it is clear that there are times when data have to be stressed and times ' : ;
I
at when actions are m ore critical Overall, however, data and actions are given equal i I
l I
at i mportance during the phases of the object-ori ent ed paradi gm. I j!
ur Many reasons are given i n Chapter 1 and t his chapter as to why t he object-oriented I
ing al1 these reasons is that i 1
,!
or paradigm is superior to the structured paradigm Underly
l d a well -desi gned object, that is, an object wi th hi gh cohesi on and 1 ow coupling, mod- :
els al1 the aspects of one physical entity The details of how this is implemented are I
ze ' hi dden' , the only communicat ion wi th an object is via messages sent to that object : l
1
ld
I As a resul t, objects essentiall y are independent units wit h a well-dehned interface ; 1
l d ' ' Consequent ly, they are easil y and safely maint ainable' , the chance of a regression ) l.
to : fault is reduced Furtherm ore, as will be explained in Chapter 8, obiects are reusable, , I
to
and t hi s r eusabi l y i enhanced by t he pr oper t y of i nher i ance Turni ng now t o de- j
r t- vel opment using objects, it i s safer to construct a large-scal e product by combi ning j ' r
t hes e f undament al bui l di ng bl ocks of sof t war e t han t o use t he st ruct ur ed paradi gm I
Because object s ess ent i al l y ar e i ndependent component s of a pr oduct, devel opment j
of he pr oduct, as wel l as management of t hat devel opment , s easi er , and hence l ess r
$ t A1l th
ese aspects of the superiority of the object-ori ent ed paradigm raise a ques- j f
- ti on: If the structured paradigm is so i nf eri or to the object-oriented paradi gm, why has ' j
the structured paradigm had so m any successes? This can be explained by realizing j
' hat the stnlctured paradigm was adopted at a tim e w hen software engineering was l
t ll ' typi cal of the t echniques of t he l970s.Therefore, use of the structured paradigm
ex-posed t he majori ty of software devel opers to methodical techni ques for t he first time l
jl
l
'S Small wonder, then, that the structured t echni ques led to major improvements i n the 1
ZS software industry worl dwi de However as software products grew in size i nadequa- t
Rf C ies of the stnlctured techniques started to becom e apparent, and the object-oriented i ;
t n obj ect - ori ent ed par adi gm i s s uper i or t o al l ot her pr esent - day t echni ques? No dat a t J
S are avail abl e that prove beyond a1l doubt that object-oriented technology is bett er I ' j I
Ed ' than anything else currently available, and it is hard to im agine how such data could : ; : !
1 ! j ' 2t ê be obtained.The best we can do is to rely on the experiences of organizations that :
t ,
j
l 'Ii
1 l i
Trang 5' j 1 : have adopted the object -oriented paradi gm Although not all reports are favorabl e,
i l L ( the majority (if not the overwhelming majori ty) attest that using the object-oriented
.IBM has report ed on three totally di fferent projects that were
, 1 ( t j detect ed, far fewer change request s duri ng both devel opment and maintenance that ;
l ! i 1 were not the result of unforeseeable business changes, and signihcant increases in $
i S p st ill use the classical paradigm to develop software.Bot h groups fel t that the object- g
i , group was signihcantly stronger Both groups essentially discounted the various dis- '
'1 ' I : ,j ' ' advantages of t he object-ori ented paradigm. '
! Notwi thstanding t he many advantages of t he object-ori ented paradigm, some
t ' i , difhculties and problems indeed have been reported A frequently reported problem
j
! ! concerns development effort and size
.The fi rst time anything new i s done it takes i
! !' '
ions; this initialperiod is som etimes referred to as the
1 j) : Iongerthan on subsequentoccas
-j j i1l : i ! l an ar or ni gani ng cur za t v on c., Butit often takes lwhen he obonger j c -than anticipated,or i nt e d pa r adi gm even allow ii us e d f orng for the fhe ls tearning me by !,
j
) l g 1 ( GUI ) (s ee Secti on l 0 3) Ther eaf t er , hi ngs mpr ove gr eat l y Fi r st , mai nt enance cos t C
are lower, reducing the overall lifetim e cost of the product Second, the next time l
1 ( s
l
l
1 I that a new product is developed, some of the cl asses from the previous proiect can be
1 '1 : reused, furt'her reducing software costs.' n is has been especially si' gnihcant when a'' ''
-l I GU I has been used for the first time; much of the effort that went into the G Ul can l
t : r ' i t hat a new subcl ass hat di f ers sl i ght l y f rom i par ent cl ass can be cr eat ed wi t hout l
I C i ' ffecting the parent cl ass or any other ancestor class in the inheritance hierarchy.
' j re erre f d to as t hefragile base cl assprobl em Atthe very least, t he affected units have to :. l i
I
t
; 1
Trang 6I 'i , '.j jI l
!
l n
-, , in the inheritance hierarchy quickly can get large, with resulting storage problem s j
L ed !' ( Bruegge, Blythe, Jackson, and Shufelt, 19921 One way to prevent this is t o change I
'
t he di ct um < use i nheri t ance wher ever possi bl e' ' t o d use k nhel it ance wherever appr o- j L
Fel- priat e '' In addi tion, if a descendent class does not need an attri bute of an ancestor, I j
) 41 then t hat attri bute shoul d be expli citl y excluded ! 1 , i
hat ' One fi nal questi on: Someday mi ght there be something better t han the object- I
us- paradigm is the ultim ate answer to all software engineering problem s Furtherm ore, ; I !
i ' ftware engineers are looking beyond objects to the next majorbreakthrough
ter- j to anything being put forward today The object-ori ent ed paradigm is sure to be , j
le superseded by t he methodologi es of the future The i mportant l esson is that, based i l
the The chapter begins wi th a descri ption of a modul e (Sect ion 7 1) The next two sec- j 1
by tions analyze w hat constitutes a well-designed module in term s of module cohesion l k
ime that data structure An abstract data type (Section 7.5) is a data type, together with the ;
a class, an abstract data type that supports inheri tance (Secti on 7.7) An object is an ! I i '
! j nce instance of a class Polymorphism and dynami c binding are the subject of Section (
; t
k out 7.8, and cohesion and coupling of objects are described in Secti on 7 9 The chapter I I i !
z hy concl udes wi t h a di scussi on of t he ob ject - ori ent ed par adi gm ( Sect i on 7 10) ' l
Is Objects were fi rst described in ëDahl and Nygaard, l 9661 M any of the ideas in t his l
li c- chapter originally were put forward by Parnas (Parnas, l 97 1, 972a, 1972b1 The use j
t
Llly, of abstract data types in software development was put forward i n (Liskov and Zil les, ' ' 1 i
k ver 19741, another i mportant early paper is ë Gut tag, 19771 l
I 1
ë ' ( ;
4
2
-! ii
Trang 7t k:' Introductory material on objects ean be found in kMeyer, 19971 Ways in which ê
i,$ object-ori ented programmi ng promotes reuse are put forward in (M eyer, 1987, 19901.
-! I ti ces) contains informal reports descri bi ng successful obi ect-ori ented proi ects The j:
j j successful use of the object-oriented paradi = ' - gm i n t hree IBM projects is descl H - v ibed in *
1 i Tsai , and Ful ghum, 19961 des cr i be how t o make t he t ansi t on t o object -or i ent ed t
ech-I ( ' ' nology: a number of recommendations for managers are i ncluded A detailed account
! ! art icl es on objects, including (Meyer, 1992a1, which describes design by contract.
) ti 1 ' ' ' A vari et y of art i clyes on object s ean be f ound i n t he Januar y 1993 i ss ue of I EEE
,: ! i ; Software; Snyder s paper carefully defi ning key terms in t he fi eld ( Snyder, 19931 is
p : i !
iq ï part icul arly useful Possible drawbacks of pol ymorphism are descri bed in (Ponder and 14
j ! 1 ' j Bush, 19941 The October 1995 i ssue of t he Communications of the ACM contains
t j 1 art i cl es on object echnol ogy, as does Iss ue No 2, 996, of t he 1 BM Syst ems Journal d
. I 1 jr j you to investigate ways of ensuring that m odules designed by your group will be as
1 1 reusable as possible.W hat do you tell her?
Trang 8I !
l
I REFERENtES ao@ l
l
tn- ;.4 Your m anager now asks you to determ ine how existing modules can be reused Your j2tS first suggestion is to break each m odule with coincidental cohesion into separate l
modul es wi t h f unct i onal cohesi on Your managercor r ect
Ch mo dules have not been tested nor have they been docum ented.W hat do you say now? 1
j
;
01 z s w hat is the innuence of cohesi on on mai ntenance? 2,
ol ' T.6 W hat is the insuence of coupling on maintenance? ! j , 51
'he ' z 1: convert the com m ents in Figure 7.23 to C+ + orlava, as specified by your instructor ( I
.1Q As pointed out in the Just n
2
h-of thi s chapter, object s first were put forward in 1966 Only aft er essentiall y being
r ei nvented nearl y 20 years l at er did objects begin to receive wi despread acceptance j
k rl d 7.14 Your instructor wi ll dist ribute an object-oriented software product Analyze t he mod- : q
ins ules from the viewpoints of inform ation hiding, levels of abstraction, coupling, and l;
fal cohesion Compare your answer with that of Problem 7.13
7.15 (Term Project) Suppose that the Broadlands Area Chil dren' s Hospi tal product of
ing the structured paradigm Give examples of modules (,Appendix A was developed us
I ;
' of functional cohesion that you would expect to lind Now suppose that the product j I
developed using t he object -oriented paradi gm Gi ve examples of classes that you ' l t
t i7.1: (Readings in SoftwareEngineering) Yourinst ructorwill dist ribute copies of r lohnson, j !
wo 20001 W hy do you think that t he respondents vi ewed the drawbacks to the object - ' )
I RZFKRKNtKS
,' j
I
(Berry, 19781 D M BERRY, personal communication 1978 l
' A Compari son of Si xt een ' 1
g Bi nkl ey and Schach
Quality Metrics for Object-oriented Design,''Information J'mccy-îïrw Letters 57 (No 6 l'
;kS (Binkley and Schach 1 9971 A B BI NKLEY AND S R SCHACH, t ' Toward a Unif ied Approach l '
; ' y
RS to Object-oriented Coupli ng ' Proceedings oft he 35th Annual ACM Southeast i 1 ;
Conference, Murtreesboro, TN.April 2 4, 1997, pp 9 1-97 r t
l
.'
: )
l ,
Trang 9I , a1 l doing essentiall y the same thi ng Surely, a1l that the world needs isjust one payroll program that can nln on
' 1 ! ! a variety of hardware and be tailored, if necessary, to cater to the specihc needs of an individual organization. .
j
j ; j
h j. J ' However, instead of utili zing previously developed payroll programs, myl iad organizations all over the worl d
) ! ' have built their own payroll program from scratch
f : l j A product ksportable if it is signifkantly easier to modi fy the product as a whole to run
l ? i t on another compiler-hardware-operat ing system confi guration than recode it from
j : ! r' devel opment of a different product wi th di fferent functionality A reusable component
t g i need not necessarily be a m odule or a code fragment it could be a design, a pal' of
I ' ( : velopers of a new product realize that a component of a previ ously developed
prod-1 ' f uct can be reused in the new product
,then this is accidental reuse or opportunisticl
j
i reuse O n the other hand, utilization of software components constructed
specih-l k i 11 for possible future reuse is deliberate reus
e or syst emati c reuse One potent ial
Trang 10st ructed for use in future product s are more li kel y to be easy and safe t o reuse' , such 'l ;
i, com ponents generally are robust well documented, and thoroughly tested In addi- 1
i
ti on, they usually display a uniformity of styl e that makes mai ntenance easi er The I
: :other side of the coin is that im plementing deliberate reuse within a company can be p :ive lt takes time to specify, desi gn, impl ement, t est, and document a software 1
com ponent However, there can be no guarantee that such a component will ever be !
r preused and thereby recoup the m oney invested in developing the potentially reusable 1
i
1
W hen computers were first constructed
,nothi ng was reused Every time a prod- 1 )
-uct was developed, items such as mul tipli cation routines, input-output routines, or 1 i ,
j )
routines for computi ng si nes and cosines were constructed from scratch Qui te soon, I l 1
1 ' ! l however,i was realized that t his was a consi derabl e waste of effort, and subroutine i I j
lmore sophisticated and developed into run-tim e support routines Therefore when a j
I
programmer calls a C++ or Java method, there i s no need to wri te code to manage 1
t he stack or pass the arguments expli ci tly; i t is handl ed automati cal ly by calling the ' i jail
appropriate run-time support routi nes The concept of subroutine li brari es has been i j ams
, ext ended t o large-scale statisti cal li brari es such as SPSS (Norusis, 20001 and to nu- iI
l n on meri cal analysis li brari es li ke NAG ( Phill ips j I
l 9861 Class l ibraries also play a major T tion.
library, is of enormous assistance W ith regard to C+ + , a large num ber of different
libraries are available, many in the public domain One example is the C+ + Standard j
!
Template Library (STL) LM usser and Sai ni , 19961 ! ! l
An appli cation programming interface (APl) generally is a set of operating sys- jtem calls that facilitate program ming For exam ple, W in32 is an API for M icrosoft ; l
'
E ! operating system s such as W indow s 2000 and W indow s NT', and the M acintosh Tool- ;
box is an APl for M ac OS
,the M acintosh operating system Although an A Pl usua y
is im plemented as a set ot operating system calls, to the program mer the routines 1
constitut ing t he API can be viewed as a subroutine li brary For example, the Java j j from
Appl i cat i on Pr ogr ammi ng l nt er f ace cons i st s of a number of packages ( l brar i es) j
e t he No matter how high the quality of a softw are product m ay be, it will not sell iit ,
'ZCFX
takes 4 years to get it onto the m arket when a com petitive product can be delivered in 'l l
trt of
only 2 years The length of the developm ent process is critical in a m arket econom y
AlI other criteria as to what constitutes a 'tgood'' product are irrelevant if the product
software product serves a truly ori ginal purpose ( Jones 19841 The other 85 percent j l.
of the product in theory could be standardized and reused in future products ' 1 !
l -!
1 @
- )i è' i
Trang 11, J ë , : than reuse a routine writ ten by someone else, the implicati on bei ng t hat a rout ine
' i S g ï cannot be any good unless they w rote it them selves, otherwise known as the not
$ 1
!
I : '
!
j 1 : i nvented here (NlH) syndrome gGriss, 19931 NlH is a management issue and,
, i can be sol ved, usual l y by of f eri ng '
j I ,
!. 1 ; finaneial incentives to promote reuse.
j : :
t I ! : 2 M any developers would be willing to reuse a routine provided they could be
. lt l l ip ' sure t hat he r out i ne i n quest i on woul d not nt r oduce f aul t i nt o t he product.This
'l t k ' atti tude toward software qual ity i s perfeetl y easy to understand After all, every
' 1 k ' i ftware professional has seen faulty software written by others
.The solutionI
7
@ ' ( i here is t o subject pot entially reusable routines to exhausti ve testing before making ,
l l ' tjjem available for reuse
-y , j ( I ponents How should these components be st ored for effective later retrieval? For
' lh 1 : i4 example,a reusable com ponents database might eonsist of 20,000 item s, 125 of
l ë j which are sort routi nes The dat abase must be organized so that t he designer of
. i k ! com ponent reusable increases its cost by at least 60 percent Som e organizations
' 1 ! i have reported cost increases of 200 percent and even up to 480 percent
,whereas , i f .J
'
t h 1 1 : the cost of making a component reusable was only 1 1 percent in one
Hewlett-' Packard reuse project, as reported in Section 8 3.5 ( Lim, 19941.
: : $ tifth im pedim ent is m ore problem atic, legal issues that arise with contract software
l : ! In terms of the type of cont ract usually drawn up between a client and a software
Trang 12t I I
I :E
l ;t
* & IMPEDIMENTS To REusE 215 q j
s organization,this problem does not arise.A sixth im pedim entarises when comm ercial ;
j
i 'Off-t he-shelf component s are reused It rarely happens that developers are given the ; ! (
de of a COTS component , so sof t ware t hat reuses COTS component s has @ ! sour ce co
So, other than certain legal issues and problems with COTS com ponents, there ë
X Yhe Wofld W ide W Cb is a great SOIIFCC Of tlruan noWever, a.S reporteu ln zne nIJNJ utgest, lt aP- 1l
Ls myths,' that i apparently true stories that somehow pears thatthe story is nototally an urban myth- much ' 1
I
y just do not st and up under scruti ny when they are in- of i actual l y happened ( Green, 20001 Dr Anne-Marie j
I n vesti gat ed cl osel y One such urban myt h concerns code Gri sogono head of t he Si mul ati on Land Operati ons I '
reuse Division at the Australian Defence Science and Tech- l
#
j' The story is told thatthe Australian AirForce set up nology Organisation
,told the story ata meeting in Can- I g '
avirtualreality training simulator forhelicoptercombat berra, Australia, on May 6, 1999 Although the simula- j
.To make t he s cena ri os as eal ii as pos si bl e, t orwas des i gned o be as eal ii c pos si bl e ( even i n- ! j
'l- programmers included detailed landscapes and (in the cluded overz million virtualtrees,as indicatedon aerial ' l '!'f Northern Territory) herds of kangaroos.After all the photographs), the kangaroos were included for fun iI
lf dust from a herd disturbed by a helicopter might reveal The programmers indeed reused Stinger missile de- ! '
l '
ls the position of that helicopter to the enem y tachm ents so thathe kangaroos could detecthe arrival '
a ' The program mers w ere instructed to m odel both of helicopters, but the behavior of the kangaroos was ' I
. the m ovements of the kan/aroos and their reaction to set to ç'retreat'' so that the kancaroos, correctly, w ould 1 i
hel i copters To save ti me, t he programmers reused code f lee if a heli copt erapproached However , when t he soft- j k '
originally used to simulate the reaction of infantry to ware team tested their simulator in their laboratory (not ! !
att ack by a hel icopt er Onl y t wo changes were made: i n fr ont of vi si tors), they di scovered that they had for- j j )
'd They changedthe icon from a soldierto kangaroo
, and got ten to remove both the weapons and t fi re' ' behavior l ' I l ; !
a they increased the speed of movement of the hgures Also, they had not specihed what weapons were to be i i
IS ' One f i ne day, a gr oup of Aus t al i n pi l ot s wa nt ed us ed by t he s i mul a ed f gur es, s o when t he kangar oos I
t t o demonst r at ehei r pr owes s wi t h t he ii ght si mul at or f i ed on t he hel i copt er s, hey f ed t he def aul t weapon, j
t- to some visiting American pilots They E'buzzed'' (flew which happened to be large multicolored beachballs ' '
Very lOW OVer) t he vi rtual kangaroos As expected, the Gri sogono confi rmed that the kangaroos were im- 1
ill m ediately disarm ed and therefore it now is safe to fly 'kangaroos Scattered
l e
a ndl a un c e St i ng e rmi s i s t he el i op t r Th e pr o ov e Au s a a Bu t ot wi t s nd i g t hi s a py nd i g, r l
z. gram m ers had forgotten to rem ove thatpartof the code software professionalsstillm usttake care when reusing
-e when they reused the virtual infantry implementation code not to reuse too much of it I
i !
; l
'
j !
Trang 13j t C i j t er mi ne whet her del i berat e r euse of desi gns and code was f easi bl e t ls anergan and
2 G sso 19841 Over 5000 COBOL products in use were analyzed and classifed The
; ' ! on data For the next 6 years, a concerted att empt was made to reuse both design and :
' i eoue wherever possibl e.
l it 1 Functional modules were carefully designed
, tested, and document ed Products t hat 1
l
l 1 functional modules were found to be m ore reliable
, and less testing of the uc
! l T verb That is, the code was not physicall y present wi thin the appli cation product but in
1 1 l was included by the COBOL compi ler at compil ation time; the mechanism is similar la)
The r esul ti ng source code t her ef or e was shor t er han i f t he : s
1 copi ed code were physi
r 1 ample of a logic structure is t he update logic struct ure.This is used for perfonning tio
. ( ) ! t. ! ! ! a sequential update, such as the case study in section 5.1. l Error handling is built so
t I 1 ' , , ul es such as get -ansact i on, pri nt - page- heodi ngs, and pr i nf - cont r ol - ot al s Fi gur e a.
1 ! ' t 8 is a symbolic depi ction of the framework of a COBOL program logi c structure
l ; i ith the paragraphs Ell ed i n by functi onal modules
J 1 E r There ar e many advant ages o t he use of such t empl at es I t makes t he des i gn and Fu
! ! !'j j i coding of a product quicker and easier because the framework of the product already m a
' 1 that is needed is to till in the details Fault-prone areas such as end- tor
Trang 14hi ,
i F Funct i onal modul e
' i
1
Flgure la Symbolic representation of Raytheon t
I )
j ' '
) j
modifications or enhancements o nce a m aintenance programm er was fam iliar with I
tl1c Felevallt logic Strtlcttlre, it WaS alm ost as if he or she had been a m ember of the l Il
:original development team
By 1983, l ogic structures had been used over 5500 times in developing new prod- ! )
About 60 percent Of t he code consi st ed of unct i onal modul es, t hat s eusabl e j l uct s.
ing, and documentation ti me also l l i
; E
' was reduced bv 60 Dercent, leadifm to an estinlated 50 percent inerease in productivitv
' j '
) in software product development But, for Raytheon, the real benefit of the technique !
' lay in the hope that the readability and understandability resulting from the consistent g
r style would reduee the cost of m aintenanee by betw een 60 and 80 pereent Unfortu- i l:
i rnately
,Raytheon closed the division before the necessary m aintenance data could be .
In 1 977, he Toshi ba Cor porat i on s t ar t ed t he Fuchu Sof t ware Fact or y at he Toshi ba '- )I
l Fuchu w orks in Tokyo.At the Fuchu W orks, industrial process control system s are j , I
- tOrS, factory aut omati on, and trafsc control; at t he Software Factorys appli cation soft- ' l
l t
ware i s developed for t he process control computers for those systems (M atsumoto, ;
gl ,I -
k ?E
.
.
Trang 15' ' j By 1985, the Software Factory empl oyed a total of 2300 technical and manageri al
, i ! ! i 1 personnel About 60 percent of the code is i n FORTRAN augmented by real-ti me
I j ! ! l routi nes, 20 percent i n an assembl erl i ke l anguage, and t he r es t i n user -s peci hed,
ë i l de Because the effort to produce 1000 lines of FORTRAN is diff
erent from thatI
'
E l t needed to produce 1000 lines of assembler
,the uni t of producti vity used is equi val ent i
1 I ! t from the software Factory in 1985 was 7
.2 m illion EA SL Products ranged in
ë l 1
j ! size from I million to 2 1 m illion EA SL, with an average size of 4 m illion EASL
l !
j j Software was developed using the waterfall model, with detailed reviews and
I 1 inspecti ons at the end of each phase Producti vity, measured i n EASL, is the dl ivi ng
,I 9 j Ma t umo t o a t but es mpr ove me nt s i n bot h pr odu ct i vi t and qual i e us e o
I ' j : , 1 existi ng software (that i s, acci dental reuse) (M atsumoto, 19871 This reusabl e software
@ ( j 1 includes not only modul es but al so documentation of al l kinds
,such as designs,'j : ! j
) 2 ! 1 specihcati ons, contract s, and manuals A committ ee is responsible for deciding what
; I l i they are indexed by keyword for later retri eval Careful statisti cs are kept on the reuse
l l ' rate of every com ponent in the database In 1985, the docum entation reuse rate, that
I 1 !
1 j I is, the number of reused pages divided by the total numberof pages of documentation,
t j I was 32 percent n t he desi gn phas e, he reuse rat e was 33 per cent , wher eas 48 per cent
( l ' of code was r eus ed dur i ng t he i mpl ementat i on phas e.In addition, statistics are kept
j on t he si zes o f r eus ed sof t ware component s' , about 55 per cent wer e l K t o 10K EASL
1 convspondi ng statistics for 25 software products developed by NASA foll ow in
; ' : group that produces ground support soft ware for unmanned spacecraft control (Sel by,
i ! i- i 1 19891.Altogether 25 software products were investigated. They ranged in size from
.M odules fall ing into group 3 werereused wit h majorrevisi ons;
Trang 16'
j !
! :
: ! i
* a RE usE CASE 5TupI E5 Q1 @ l i j
,
ied ' More speci ficall y, 28 percent fell i nto group l l 0 percent into group 2, and 7 percent 1 1
d in more likely to be reused In addition, a large m odule is likely to perform a num ber of I
and be reused than i ts small er count erpart A complex i nterface impl ies a large number j ë ing of arguments, which tends to reduce the reuse of a module lnput-output processing 2 ll
1 j:an can be som ewhat application specihc and therefore less reusable Finally, com paring i ,
i 1
leen term inal modules in a m odule interconnection diagram w ith modules higher up in t !
! !
r e is t he di agram, a termi nal modul e is more likely to carry out a speci fic task whereas 1,
zing Secti on l 5 ) As a result, a terminal modul e is more li kel y to be reusabl e than a 1 ,
cl es A more constructi ve way of looki ng at Selby's results is to utili ze them to ensure i 2
1 that modules can be reused in future products M anagement should ensure that a j
I
e of specit ic desi gn objective shoul d be small modules with simple interfaces lnput - ' '
ivare outputprocessing should be Iocalized to a few m odules.A l1 m odules m ustbe properly !
g
lvhat There are considerable differences between the NASA group and the Fuchu
: : l
h r Sof t war e Fa c or y n par t ul a , h de ci s on us e s of t wa r wa s he per s ona l hoi c
z use of he NASA sof t ware devel oper s' , here wer e no manageri al di r ect i ves of any ki nd j
that The NASA staffers reused software simply because they believed that reuse is a l I
? : ;
lion
, worthwhile software engineering technique In addition,there were no software tools
cent to assist with the reuse process This situation is in stark contrast to the reuse-oriented :
kept management of the Fuchu works and the sophisticated software component retrieval )
*SL mechanism s employed there Despite this, surprisingly high reuse rates have been i
!
in The fourth case study highlights the effect of m anagem ent comm itmentto reuse i I
l : E
i iltl
i l a
l
A successful acci dental reuse scheme was impl emented at GTE Data Servi ces (Prieto
,199 1 1 Unl ike the NASA case study, a key aspect o j
llby, management Com m itm ent to the reuse Of source code m odules To prom ote reuse, a 1
7 rOm CaS h incent ive Of bet ween $50 and $ l 00 was paid for a module accepted for possible ' l
lifi
ed reuse, and royalties Were paid When the m odule actually was reused In addition, !
' budgets Were increased When projects they managed achi eved a hi gh level 5 i
Rped was achieved' , this saved t he company an esti mated $ l mill ion The followi ng year, k,
i was es t mat ed t hat t he r euse I evel rose t o 20 per cent , and a 50 per cent l evel was $ :
7
II z
Trang 17. I l k t hat it had ant ici pat ed overall savings of well over $10 mill ion by that date.
1 l ( The GTE r eus e pr ogr am r eveal s a number of nt eres t ng aspect s.First, the total
j I : second, the emphasis was on largermodul es (l0, 0001ines of codeormore), becauseof
' i l 1 i t he greaterpayof f.ln contrastto the NASA experience,w here sm aller modules tended
$ ' ; company rl-im, 19941. In general , these programs have been successful from the
, j j ; ) had an accidental reuse program in place since 1983 The section develops software
' ) ' ' i for manuf act ur i ng r es ource pl anni ng The component s chosen f orr euse are wr ien i
.
!I ;
l I .1 1 pascal and SPL (t he language for systems software on the HP 3000 computer system).
'
l I i i ' rhe faul t rate for new code is 4
.1 faults per 1000 noncomment l ines of code (KLOC)
j i ove r al l a ul t at e dr oppe d t o onl y 2 0 f ul t per KLOC, 51 pe r ent educ t on Pr
o-1 ductivity increased 57 percent
,to l 1 Kt- oc per person-month i n 1992 The program -
! ! j
i l i I 1 ' COS t $1 milli on but saved $4.1 mi llion between 1983 and 1992 Amazingly, the project
I hrmwar e f or pl ot t ers and pri nt er s A s i ngl e product consi s ng of 20, 000 noncom- :
. m ent lines of C w as developed over a period of 3 years and then reused.The gross
.
' j l cost of the reuse program between I 987 and 1994 (1994 data esti mat ed) was $2
.6I
' j Hewlett-packard currently is taking these ideas further lnstead of m erely reusing
! tirmware from one printer model in a subsequent m odel
, it set up a software productE
Trang 181 I i ;
i ; :): t
! !) '
a.a REus: CASE sTuolls am i
ij
' The overall lesson of these five case studies is that reuse is possible in practice l ,
l
and can result in signihcant eost savings However, the major push for reuse must
The hnal case study is a cautionary tale, rather than a success story ;
; '
j $ , 1
@
,
1, On June 4, l 996, the European Space agency Iaunched the Ari ane 5 rocket for the hrst )
time As a consequence of a software fault, the rocket crashed about 37 seconds after i :' l if toff The cost of the rocket and payl oad was about $500 mi llion, maki ng this the : most costly soft ware fault to date (Jdzdquel and Meyer, l 9971 (Cl earl ys no t inancial lvalue can be attached to faults that cause a loss of hum an life such as those listed in ! ;
the first Just in Case You W anted to Know box in this bo()k.) I I
The prim ary cause of the failure was an attempt to convert a 64-bit integer into a ,16-bit unsigned integer The number being converted was larger than 216 so an A da 9 E :
extepùion (run-time failure) occurred Unfortunately, there was no explicit exception ! lk
handl er in the code to deal with this exception, so the software crashed This caused 1 1
' Ironically the conversion that caused the failure was unnecessary Certain com - i !
formed before Ii ftoff to ali gn the i nerti al reference system These i l
computations should stop 9 seconds before liftoff However, if there is a subsequent I
.j i ' hol d i n the countdown resetting the i nerti al reference system after the countdown
1 l , h
as recom menced can take several hours To prevent that happening, the computa- j 1 y
tions continue for 50 seconds after the start of Qight m ode, that is, well into the qight ( ' l
incorporates an effective software quality assurance com ponent Then, why was there i '
ion handler in the Ada eode to handle the possibility of such an overoow? i
no except
' r
In order not to overload the com puter, conversions that could not possibly result in j '
overflow were left unprotected The code in question was l0 years old It had been I
d unchanged and without any further testing, from the software controlling the l :retlse
Ariane 4 rocket (the precursor of the Ariane 5).M athematical analysis had proven that i ' .
the colnputation in question was totally safe for the Ariane 4 However, the analysis ! ',
.i
was performed on the basis of cert ain assumpti ons that were true for the Ariane 4 but )
l Inot for the A riane 5.Therefore the anal ysis no longer was valid, and code needed the ,
( àprotection of an exception handler to cater to the possibility of an overEow.W ere i t j ,
f or he per for mance const r ai nt , here woul d sur el y have been except i on handl ers l l ;
pr evented the Ariane 5 crash if the rel evant module had incl uded an assertion that the p ;
ber to be converted was smal ler than 21 6 tlézéquel and Meyer, 19971 ( l
major l esson of this reuse experi ence is that software developed i n one j ,
context m ust be retested w hen reused in another context That is, a reused software l '
( ! '
:
d i '
; é'
E i
iI t
Trang 19! ' j '
j ; ! r el y excl usi vel y on t he r est ls ot mat hemat i cal pr oof s, as di scussed i n Sect i on 6 5 2.
1 r j r W e now examine the impact ot t he object-ori ented paradi gm on reuse.
1 W hen designing a product, a mem ber of the design team may realize that a m odule '
j or cl ass trom an earl ier desi gn can be reused i n the current project, wi th or wi thout
11 2 minor modifi cations.This type of reuse is particularly comm on in an organization
Trang 20I qI l
l '
'
p '- l
*.s REUSE DURING THE DESIGN AND IMPLEMENTATION PHM ES 2Q3 j 1'
l
I'
'
l l been t hat develops software in one specif ic appli cation domain,such as banking or air
ë
l 1ise to t raff ic control systems The organi zation can promote thi s type of reuse by setting up i @ ; 11s
.5.2 a repository of design com ponents likely to be reused in the future and encouraging : :' f
7 I desieners t o reuse t hem,perhaps by a cash bonus for each such reuse There are two ;
' <' '
advantages Ot this type Of reuse, lim ited though it m ay be First,tested m odule designs ; 1
ar e i ncor porat ed i nt o t he pr oduct The over al l des i gn t herefor e can be produced more ! ; !
quickly and is likely to have a higher quality than when the entire design is produced i' ! I
1 ' from scratch Second, ithe design of a modul e can be reused, then i t is l ikel y that i !
the im plem entation of that module also can be reused, if not the actual code then at ; !
t o be rarely wri te the routines to perform such common tasks as matrix inversion or finding i j
i envalues lnsteads a scienti fic library such as LAPACK 2 0 (Anderson et a1 , 19951 l ! 1
E !
is not is purchased Then, wheneverpossible, the routines in the scientihc library are utilized l
-1 odule i n fut ure software W i th the rise in popularity of the object-oriented paradi gm, class 2
ata in l ibrari es for scientiic soft ware have been devel oped such as LAPACK-F-I - gDongarra, I ;
iffpack (Langt angen, l 9941, and C-XSC (Kl at te et al , I
is the GUl toolkit s of thi s kind including the Java Abstract W i ndowing Toolki t (Flanagan : 1
l
);l
5 j
! 1lodule Flgve a.Q symbolic representation ofour types of design reuse Shading denotes ;
ri thout desi gn r euse wi t hi n ( a) a I i brar y or a t ool ki t ( b) a f r amework, ( c) a desi gn pat t ern, ond 2 j
( d) o sohwar e ar chi t ect ure compr i si ng a f ramewor k, a t ool ki t and t hree desi gn pat t erns i ) j :
r 1
ù
l Ii
1 l: