您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 信息化管理 > Restructuring software A case study
RestructuringSoftware:ACaseStudyTIMHOPKINSComputingLaboratoryUniversityofKentCanterbury,CT27NFKent,UKtrh@ukc.ac.ukJune2,1998AbstractWeuseknotcountandpathcountmetricstoidentifywhichroutinesintheLevel1BLASmightbene tfromcoderestructuring.Wethencon-siderhowbothlogicalrestructuringandtheimprovementsinthefacilitiesavailablefromsuccessiveversionsofFortranhaveallowedustoimproveboththecomplexityofthecodeasmeasuredbyknotcount,pathcountandcyclomaticcomplexity,andtheuserinterfaceofoneoftheidenti- edroutineswhichcomputetheEuclideannormofavector.Withthesereductionsincomplexitywehopethatwehavecontributedtoimprove-mentsinthemaintainabilityandclarityofthecode.Softwarecomplexitymetricsandthecontrolgraphareusedtoquantifyandprovideavisualguidetothequalityofthesoftware,andtheperformanceofaFortrancoderestructuringtoolisreported.Finallywegivesomeindicationofthecostoftheextranumericalrobustnesso eredbytheBLASroutineovertheuseofnewFortran90intrinsicfunctions.keywords:SoftwarecomplexitymetricsFortranEuclideannormSoft-waretoolsINTRODUCTIONThreeofthemostimportantqualitiesofsoftware,asfarastheenduserisconcerned,arerobustness,reliabilityande ciency.Thoseinterestedin xingbugsandupgradingsoftwarearealsokeenthatthecodebeeasytounderstand,test,andmaintain.Detailsofthese,andotherimportantsoftwarefactorsmaybefoundinFenton[1]andWatts[2].Theabilitytoproduceclear,readablecodedependsbothontheimplemen-tationlanguageandtheprogrammer.Theprogramminglanguageneedstohavethecontrolanddatastructuresavailabletoallowthecodertogenerateacleanandsimple,yete cient,implementationofthealgorithm.Ingeneral,thefewer1facilitiesalanguageprovidesthemoredi cultitisforaprogrammertogeneratesuchcode.Fortranhasevolvedfromtheverysimple‘highlevel’languageofthe1950’s,throughFortran66,the rstprogramminglanguagetobestandardised[3],andFortran77[4],arelativelyminormodernisation,tothemuchlargerandmorecomplexFortran90[5].TheLevel1BasicLinearAlgebraSubroutines(BLAS)[6],originallypub-lishedinFortran66,implementedanumberofcommonvectoroperationsandweredesignedtobeusedasbuildingblocksforlinearalgebrasoftware.Rou-tineswereprovidedtodealwiththedi erentnumericaldatatypesavailableinStandardFortran66(defaultprecisionforrealandcomplexanddoublepre-cisionreal).Theroutinesweredesignedtobebothnumericallyrobustande cient(manyusedloopunrolling[7]toobtainbetterperformance),althoughformaximale ciencyitwasexpectedthatspeciallytunedversionswouldbemadeavailableforparticularhardwareplatforms.Firstwedescribebrie ythreesoftwaremetricsandlookathowtheywereusedtohelpidentifywhichoftheLevel1BLASwerelikelytobedi culttounderstand,testandmaintain.Wethenconsiderhowrestructuringthecodea ectedthemetricstoascertainwhetherthechosenmeasureso eranyhelpinquantifyingtheimprovementsmadetothecode.WealsoreportonhowwelltwoFortrancoderestructurersfaredontheoriginalandrewrittenFortran66routines.AFortran77versionofoneoftheroutinesispresented.Wethenconsiderhowthenewfacilitieso eredbyFortran90maybeusedtoimproveboththecodeandtheuserinterface.FinallywelookattheimpactwhichtheuniversaluseofIEEE oating-pointarithmeticmayhaveontheunderlyingmethodandthecostofnumericalrobustness.SOFTWARECOMPLEXITYMEASURESInattemptingtoassistintheproductionofhighqualitysoftware,variousmeth-odshavebeenproposedtolimitthecomplexityofindividualcodemodulesandmanymethodsofmeasuringcodecomplexityhavebeenadvocated(seeZuse[8]foranextensivebibliography).Inordertohelpinquantifyingthee ectsofanychangeswemaketothesoftware,wewillconsidertheuseofthreeofthesemetrics1.knotcount[9]whichprovidessomeindicationofcodingclarity,2.pathcount(avariantonthemetricproposedbyNejmeh[10])whichgivesanestimateofthee ortrequiredfortesting,3.cyclomaticcomplexity[11]whichalsoattemptstoestimatethetestingef-fortrequired.Inadditionwewilllookatapictorialrepresentationofthecodeintheformofacontrolgraph.Theprogramcontrolgraphisadirectedgraphconsistingofbasic2blocksofcode(nodes)connectedbydirectedarcs(edges)correspondingtothe owofcontrolbetweenthesenodes.Abasicblockofcodeisasequenceofex-ecutablestatementscontainingnodecisionsortransfersofcontrol.Cyclomaticcomplexityisrelatedtothecontrolgraphandisde nedtobethecyclomaticnumberV(G)=edges nodes+2Thismaybeshowntobeequivalenttothenumberofpredicatesusedinthecodeplusone.ItisgenerallyacceptedthatcompoundpredicatescontributemoretoprogramcomplexitythansimplepredicatesandMyers[12]suggeststheuseofacomplexityintervalwhoselowerboundisV(G)andwhoseupperboundisonemorethanthetotalnumberofconditions.WorkbyShepperd[13]andShepperd&Ince[14]hashighlightedanumberoftheoreticalproblemswiththeuseofcyclomaticcomplexityasasoftwaremetric;weconsiderthesefurtherintheConclusion.TheknotcountofWoodwardetal[9]givesagoodindicationofprogramclarity.Itisdependentbothontheimplementationlanguageandtheorderofstatementsinthecode.Aknotissaidtooccurinapieceofcodewheneverthepathsassociatedwithtwotransfersofcontrolintersect(seeFigure1fortwoexamples).Thegreaterthenumberofknotsinaprogramunitthelessintelligiblethecodeislikelytobe.do10i=1,na(i)=a(i)+b(i)if(a(i).gt.bmax)goto20continuea(n+1)=1continue1020
本文标题:Restructuring software A case study
链接地址:https://www.777doc.com/doc-3390128 .html