A type system and analysis for the automatic extra

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

ATypeSystemandAnalysisfortheAutomaticExtractionandEnforcementofDesignInformationPatrickLamMartinRinardLaboratoryforComputerScienceMassachusettsInstituteofTechnologyCambridge,MA02139{plam,rinard}@lcs.mit.eduAbstract.Wepresentanewtypesystemandassociatedtypechecker,analysis,andmodelextractionalgorithmsforautomaticallyextractingmodelsthatcaptureaspectsofaprogram’sdesign.Ourtypesystemenablesthedevelopertoplaceatokenoneachobject;thistokenservesastheobject’srepresentativeduringtheanalysisandmodelextraction.Thepolymorphisminourtypesystemenablestheuseofgeneral-purposeclasseswhoseinstancesmayservedifferentpurposesinthecomputation;programmersmayalsohidethedetailsofinternaldatastructuresbyplacingthesametokenonalloftheobjectsinthesedatastructures.Ourcombinedtypesystemandanalysisprovidethemodelextractionalgorithmswithsoundheapaliasinginformation.Ouralgorithmscanthereforeextractbothstructuralmodelsthatcharacterizeobjectrefer-encingrelationshipsandbehavioralmodelsthatcaptureindirectinterac-tionsmediatedbyobjectsintheheap.Previousapproaches,incontrast,limitedbyanabsenceofaliasinginformation,havefocusedoncontrol-flowinteractionsthattakeplaceatprocedurecallboundaries.Wehaveimplementedourtypechecker,analysis,andmodelextractionalgorithmsandusedthemtoautomaticallyextractdesignmodels.Ourexperienceindicatesthatitisstraightforwardtoproducethetokenannotationsandthattheextractedmodelsprovideusefulinsightintothestructureandbehavioroftheprogram.1IntroductionDesignabstractionssuchasobjectmodels[12]andmoduledependencydiagramsareacentralfeatureofmanysoftwaredevelopmentprocesses.Inthiscapacitytheyprovideawaytoquicklyandeasilyexploredesignalternativesandgivethemembersofthedesignteamacommonandeffectivelanguageforcommunicatingimportantaspectsofthedesign.?ThisresearchwassupportedinpartbyafellowshipfromCanada’sNaturalSciencesandEngineeringResearchCouncil,DARPA/AFRLContractF33615-00-C-1692,NSFGrantCCR-0086154,NSFGrantCCR-0073513,NSFGrantCCR-0209075,anEclipseInnovationGrant,andtheSingapore-MITAlliance.2Inprinciple,thedesignabstractionsshouldremainaprimarysourceofin-formationabouttheprogramforitsentirelifetime.Butthestandardpracticeisforprogrammerstomanuallyimplementthedesignonceithasbeenfinalized,raisingthepossibilityoftheimplementationdivergingfromthedesign.Thisdi-vergencebecomesevermorelikelyoverthelifetimeoftheprogram,limitingthecredibilityoftheoriginaldesignandthereforeitsutilityasasourceofinforma-tionabouttheprogram.Inmostcases,thedesigniseventuallydiscardedandthecodebecomestheprimarysourceofinformationabouttheprogram.Thispaperpresentsanewtypesystemandanassociatedanalysisthatto-gethersupporttheautomaticextractionofdesign-levelinformationfromthesourcecode.Thegoalistoestablishaguaranteedconnectionbetweenthepro-gramanditsdesign,restorethecredibilityofthedesignasareliablesourceofinformationabouttheprogram,andenabledeveloperstousedesignabstractionseffectivelythroughouttheentirelifetimeoftheprogram.Wefocusonabstractionsthatinvolvethestructureoftheheapandtheinfor-mationflow(orlackofsuchflow)betweendifferentsubsystems.Oneparticularlynovelaspectofourtechniqueisthatitaccuratelycapturesevenindirectinter-actionsmediatedbyobjectsintheheap.Existingapproaches,incontrast,focusonlyonthedirectinteractionsthattakeplaceatprocedureormethodcalls.Thekeyideabehindourapproachistoallowthedevelopertousethetypesystemtoplaceatoken(chosenfromafinitesetoftokensfixedatprogramanalysistime)oneachobjectintheprogram;thistokenservesastheobject’srepresentativeduringtheanalysisthatextractsthedesigninformationfromtheprogram.Thisapproachaddressesseveralcommonproblemsthatcomplicatetheeffectiveautomaticextractionofdesigninformation:–MultipleDesignElements,SingleCodeElement:Well-structuredpro-gramsfactorcommonbehaviorandstructureintoasingle,general-purposecodeelement(forexample,acontainerclassorobjectfactory).Differentinstantiationsofsuchanelementoftenhavedistinctconceptualpurposesinthecomputationandshouldthereforecorrespondtodifferentelementsinthedesign.Butstandardanalysisapproachestreateachcodeelementasaunit,conflatingtheattributesofitsdifferentinstantiationsandfailingtocaptureimportantdesign-leveldistinctions.Thepolymorphisminourtypesystemeliminatesthisproblem.Itallowsthedevelopertoplacedifferenttokensondifferentinstantiationsofthesameclasssothattheanalysisseparatesobjectswithdifferentconceptualpurposeseveniftheobjectshappentobeinstancesofthesamegeneral-purposeclass.–SingleDesignElement,MultipleCodeElements:Becausethedesigncapturesaspectsofthecomputationatahigherlevelofabstractionthanthecode,multiplecodeelementsareoftenrequiredtoimplementasingledesignelement.Forexample,aprimaryobjectmaymaintaincomplexinternaldatastructuresthatthedesignabstractsasconceptuallypartoftheobject.Anyapproachthatfailstoabstracttheseinternaldatastructureswilldeliveranoverlydetailedmodelthatobscureskeyaspectsofthedesign.3Ourtypesystemaddressesthisproblembyallowingthedevelopertoplacethesametokenonboththeprimaryobjectandalloftheobjectsthatim-plementitsinternaldatastructures.Theanalysisthentreatstheentirecol-lectionofobjectsasau

1 / 28
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功