版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
DesignPatterns,ArchitecturalPatternsPascalMolliUniversityHenri-PoincaréPascal.Molli@loria.fr1Bibliography…«
ASystemofPattern
»BushmannetAll«
DesignPatterns
»GammaetAll«
ConcurrentProgramminginJava
»D.Lea.«
DistributedObjects
»OrfalietAll«
ApplyingUMLandPatterns
»Larman2Patterns…«
Patternshelpyoubuildonthecollectiveexperienceofskilledsoftwareengineers.
»«
Theycaptureexisting,well-provenexperienceinsoftwaredevelopmentandhelptopromotegooddesignpractice
»«
Everypatterndealswithaspecific,recurringprobleminthedesignorimplementationofasoftwaresystem
»«
Patternscanbeusedtoconstructsoftwarearchitectureswithspecificproperties…
»3BecomingaChessMasterFirstlearnrulesandphysicalrequirementse.g.,namesofpieces,legalmovements,chessboardgeometryandorientation,etc.
Thenlearnprinciplese.g.,relativevalueofcertainpieces,strategicvalueofcentersquares,powerofathreat,etc.
However,tobecomeamasterofchess,onemuststudythegamesofothermastersThesegamescontainpatternsthatmustbeunderstood,memorized,andappliedrepeatedlyTherearehundredsofthesepatterns4BecomingaSoftwareDesignerMasterFirstlearntherulese.g.,thealgorithms,datastructuresandlanguagesofsoftware
Thenlearntheprinciplese.g.,structuredprogramming,modularprogramming,objectorientedprogramming,genericprogramming,etc.
However,totrulymastersoftwaredesign,onemuststudythedesignsofothermastersThesedesignscontainpatternsmustbeunderstood,memorized,andappliedrepeatedlyTherearehundredsofthesepatterns5SoftwareArchitectureAsoftwarearchitectureisadescriptionofthesubsystemsandcomponentsofasoftwaresystemandtherelationshipsbetweenthem.
Subsystemsandcomponentsaretypicallyspecifiedindifferentviewstoshowtherelevantfunctionalandnon-functionalpropertiesofasoftwaresystem.
Thesoftwaresystemisanartifact.Itistheresultofthesoftwaredesignactivity.6ComponentAcomponentisanencapsulatedpartofasoftwaresystem.Acomponenthasaninterface.Componentsserveasthebuildingblocksforthestructureofasystem.
Ataprogramming-languagelevel,componentsmayberepresentedasmodules,classes,objectsorasetrelatedfunctions.7SubsystemsAsubsystemisasetofcollaboratingcomponentsperformingagiventask.Asubsystemisconsideredaseparateentitywithinasoftwarearchitecture.
Itperformsitsdesignatedtaskbyinteractingwithothersubsystemsandcomponents…8ArchitecturalPatterns AnarchitecturalPatternexpressafundamentalstructuralorganizationschemaforsoftwaresystems.Itprovidesasetofpredefinedsubsystems,theirresponsibilities,andincludesrulesandguidelinesfororganizingtherelationshipsbetweenthem.9Designpatterns Adesignpatternprovidesaschemeforrefiningthesubsystemsorcomponentsofasoftwaresystem,ortherelationshipsbetweenthem.Itdescribesacommonly-recurringstructureofcommunicatingcomponentsthatsolvesageneraldesignproblemwithinaparticularcontext.10Idioms AnIdiomisalow-levelpatternspecifictoaprogramminglanguage.Anidiomdescribeshowtoimplementparticularaspectsofcomponentsortherelationshipsbetweenthemusingthefeaturesofthegivenlanguage.11Framework Aframeworkisapartiallycompletesoftware(sub-)systemthatisintendedtobeinstantiated.Itdefinesthearchitectureforafamilyof(sub-)systemsandprovidesthebasicbuildingblockstocreatethem.Italsodefinestheplaceswhereadaptationsforspecificfunctionalityshouldbemade.12FirstExampleADiceGameAPlayerrolls10x2dicesIfresult=7,score=score+10pointsAttheend,scoreoftheplayerisregistredinthehighscoretable.13menuviewHighscoreStartturn=0RollDiceturn++UpdatehighscoreTurn<10[highscore][start][exit][true][false]ActivityDiagram14AnalysisDiagram…15DesignStageManageUserInterfaceManagePersistenceofhighscoreinafileorinrelationaldatabaseRealizeanlayeredarchitecture:ApplytheLayerArchitecturalPattern16Layerhelpstostructureapplicationthatcanbedecomposedintogroupsofsubtasksinwhicheachgroupofsubtasksisataparticularlevelofabstraction.17Layer:examples18Layer:Structure19Layer:Structure20Layerandcomponents…21Layers:VariantsRelaxedLayeredSystem:Alayer«
j
»canuseserviceofj-1,j-2…AlayercanbepartiallyopaqueSomeservicetolayerj+1,otherstoallupperservices…Layeringthroughinheritance:LowerlayersareimplementedasbaseclassesHigherlevelcanoverridelowerlevel…22Layers:KnownUsesVirtualmachines:JVMandbinarycodeformatAPI:LayerthatencapsulateslowerlayersInformationSystemPresentation,Applicationlogic,DomainLayer,DatabaseWindowsNT(relaxedfor:kernelandIOandhardware)Systemservices,Resourcemanagement(Objectmanager,securitymonitor,processmanager,I/Omanager,VMmanager,LPC),Kernel(exceptionhandling,interrupt,multiprosynchro,threads),HAL(HardwareAbstractionLevel)Hardware23Layers:benefitsReuseoflayersSupportforstandardization(POSIX)DependenciesarekeptlocalExchangeabilities:ReplacementofoldimplementationwithAdapterPatternDynamicexchangewithBridgePattern24Layers:LiabilitiesCascadesofchangingbehaviorLowerefficiencyUnnecessarywork:functionsofalayercalledmanytimesforoneserviceDifficultyofestablishingcorrectgranularityoflayers:Tofewlayer->lessbenefits,tomuchlayer->complexityandoverhead…25ApplyingLayerArchitecturePlayViewHighScoreFichierouBDDUICorePersistence26Package
decompositionUI<<layer>>Core<<layer>>Persist<<layer>>Util<<subsystem>>27Layer«
core
»Containbusinesslogicclasses…AdaptanalysisclassesforimplementationUseofsingletonIdiom…28Singleton(Idiom)Ensureaclassonlyhasoneinstance,andprovideaglobalpointofaccesstoit.29SingletonStructure30Core«
Layer
»:1erdiagrammeDesignAnalyse31Package
decompositionUI<<layer>>Core<<layer>>Persist<<layer>>Util<<subsystem>>32ObserverOne-to-manydependencybetweenobjects:changeofoneobjectwillautomaticallynotifyobservers33Observer:ApplicabilityAchangetooneobjectrequireschanginganunknownsetofothersObjectshouldbeabletonotifyothersthatmaynotbeknownatthebeginning34Observer:Structure35Observer:ConsequencesAbstractcouplingbetweensubjectandobserverSupportforbroadcastcommunicationHardtomaintain36ApplyingObserverPattern37ObserverView38Viewsaregraphicalobjects39SettingupObserver40Observer:ChangePropagation:Die:Randomizer:DieView1:getValue()2:setValue(int)3:notifyObservers()4:update(Observable,Object)5:getState()3:JLabel6:setText(3)41Architectureencouche...UICoreDecouplingclassesandinterfaces42Package
decompositionUI<<layer>>Core<<layer>>Persist<<layer>>Util<<subsystem>>43PatternFactoryMethodIntentDefineaninterfaceforcreatinganobject,butletsub-classesdecidewhichclasstoinstantiateletaclassdeferinstantiationtosubclassesAlsoknownasVirtualConstructor44FactoryMethod Applicability:Usewhenaclasscannotanticipatetheclassofobjectsitmustcreateaclasswantsitssubclassestospecifytheobjectsitcreatesclassesdelegateresponsibilitytooneofseveralhelpersubclasses,andyouwanttolocalizetheknowledgeofwhichhelpersubclasstodelegate.45Structure46FactorymethodConsequencesProvidehooksforsubclassesconnectsparallelclasshierarchiesKnownusesMacApp,ET++ClassViewinsmalltalk80MVC(controllercreation)OrbixORBforgeneratingPROXYobject47Layer«
Persist
»ClassestechniquesdepersistancesAssurerl
’indépendanceCore/Persistpouvoirchangerde«
persistentengine
»Parexemple:Persistancepar«
Sérialisation
»Persistanceviaunebasededonnéesrelationnelle(JDBC).48ApplyingFactoryProduitabstraitFabriqueabstraiteProduitconcretFabriqueconcrête49ApplyingFactory50Summary1Architecturalpattern:Layer2DesignPatterns:Observer,Factory1Idiom:SingletonPb:Combiningpatterntocombinetheirforces…5152
Bankexample…Abasicbanksystem:1bank,nAccount.
Eachaccountbelongto1client.Eachaccountiscreditedbyanamountamoney.BankfunctionsWithdrawalonaaccount,Creditanaccount,Transfermoneyfromoneaccounttoanother…53Naivesolution54NaiveSolution55ApplyingCommandPattern…Encapsulatearequestasanobject,therebylettingyouparameterizeclientswithdifferentrequests,queueorlogrequests,andsupportundoableoperations.56CommandExample57CommandExample58CommandStructure59CommandStructure60CommandConsequencesCommanddecouplestheobjectthatinvokestheoperationfromtheonethatknowshowtoperformit.Commandsarefirst-classobjects.Theycanbemanipulatedandextendedlikeanyotherobject.
It'seasytoaddnewCommands,becauseyoudon'thavetochangeexistingclasses.61ApplyingCommandPattern62ApplyingCommandPattern63CompositePatternComposeobjectsintotreestructurestorepresentpart-wholehierarchies.Compositeletsclientstreatindividualobjectsandcompositionsofobjectsuniformly.64CompositeExample65CompositeExample66CompositeStructure67ApplyingCompositeonCommand68ApplyingComposite6970ApplyingSingleton71AndSoon…Storingstate:MementoPatternObservingAccount:ObserverPatternVisitingallobjectgraph:VisitorPatternRemoteaccess:Proxypattern…72ProxyPatternProvideasurrogateorplaceholderforanotherobjecttocontrolaccesstoit.73ProxyExample74ProxyStructure75Proxybenefitsremoteproxycanhidethefactthatanobjectresidesinadifferentaddressspace.Avirtualproxycanperformoptimizationssuchascreatinganobjectondemand.
Bothprotectionproxiesandsmartreferencesallowadditionalhousekeepingtaskswhenanobjectisaccessed.76From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al77AdapterPatternConverttheinterfaceofaclassintoanotherinterfaceclientsexpect.Adapterletsclassesworktogetherthatcouldn'totherwisebecauseofincompatibleinterfaces.78AdapterExample79AdapterStructure80VisitorPatternRepresentanoperationtobeperformedontheelementsofanobjectstructure.Visitorletsyoudefineanewoperationwithoutchangingtheclassesoftheelementsonwhichitoperates.81Visitorexample82Visitorexample83Visitorapplicabilitymanydistinctandunrelatedoperationsneedtobeperformedonobjectsinanobjectstructure,andyouwanttoavoid"polluting"theirclasseswiththeseoperations84VisitorStructure85VisitorStructure86VisitorConsequencesVisitormakesaddingnewoperationseasyAvisitorgathersrelatedoperationsandseparatesunrelatedonesAddingnewConcreteElementclassesishardVisitingacrossclasshierarchiesAccumulatingstate.Breakingencapsulation87ChainofresponsabilityAvoidcouplingthesenderofarequesttoitsreceiverbygivingmorethanoneobjectachancetohandletherequest.Chainthereceivingobjectsandpasstherequestalongthechainuntilanobjecthandlesit.88
89ChainofResponsability90Chainofresponsability91ParticipantsHandler(HelpHandler) definesaninterfaceforhandlingrequests.(optional)implementsthesuccessorlink.ConcreteHandler(PrintButton,PrintDialog)handlesrequestsitisresponsiblefor.canaccessitssuccessor.iftheConcreteHandlercanhandletherequest,itdoesso;otherwiseitforwardstherequesttoitssuccessor.Client
initiatestherequesttoaConcreteHandlerobjectonthechain.92Example…Awt1.0From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al93StrategyDefineafamilyofalgorithms,encapsulateeachone,andmaketheminterchangeable.Strategyletsthealgorithmvaryindependentlyfromclientsthatuseit.94Strategy…95Strategy96ParticipantsStrategy(Compositor)declaresaninterfacecommontoallsupportedalgorithms.ContextusesthisinterfacetocallthealgorithmdefinedbyaConcreteStrategy.ConcreteStrategy(SimpleCompositor,TeXCompositor,ArrayCompositor)implementsthealgorithmusingtheStrategyinterface.Context(Composition)isconfiguredwithaConcreteStrategyobject.maintainsareferencetoaStrategyobject.maydefineaninterfacethatletsStrategyaccessitsdata.97Strategy…From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al98StateAllowanobjecttoalteritsbehaviorwhenitsinternalstatechanges.Theobjectwillappeartochangeitsclass.From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al99ExempleFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al100StructureFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al101ConsequencesItlocalizesstate-specificbehaviorandpartitionsbehaviorfordifferentstatesItmakesstatetransitionsexplicitStateobjectscanbesharedFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al102DecoratorAttachadditionalresponsibilitiestoanobjectdynamically.Decoratorsprovideaflexiblealternativetosubclassingforextendingfunctionality.From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al103ExampleFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al104ExampleFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al105ExampleFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al106StructureFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al107Applicabilitytoaddresponsibilitiestoindividualobjectsdynamicallyandtransparently,thatis,withoutaffectingotherobjects.forresponsibilitiesthatcanbewithdrawnwhenextensionbysubclassingisimpracticalFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al108ConsequencesMoreflexibilitythanstaticinheritanceAvoidsfeature-ladenclasseshighupinthehierarchyAdecoratoranditscomponentaren'tidenticalLotsoflittleobjectsFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al109From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al110BridgeDecoupleanabstractionfromitsimplementationsothatthetwocanvaryindependently.From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al111BridgeFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al112BridgeFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al113BridgeStructure…From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al114BridgeDecouplinginterfaceandimplementationImprovedextensibilityHidingimplementationdetailsfromclientsFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al115ExampleFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al116From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al117BuilderSeparatetheconstructionofacomplexobjectfromitsrepresentationsothatthesameconstructionprocesscancreatedifferentrepresentations.From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al118BuilderFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al119BuilderStructure…From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al120BuilderFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al121BuilderConsequencesItletsyouvaryaproduct'sinternalrepresentationItisolatescodeforconstructionandrepresentationItgivesyoufinercontrolovertheconstructionprocessFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al122FlyWeightUsesharingtosupportlargenumbersoffine-grainedobjectsefficiently.From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al123FlyWeightFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al124Flyweight:StructureFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al125FlyweightexampleFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al126Flyweight:InstancesFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al127Flyweight:ApplicabilitéEtatintrinsèque/extrinsèque…Lesétatsextrinsèquespeuventêtrecalculés…From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al128Flyweight(ilariencompris…)From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al129IteratorProvideawaytoaccesstheelementsofanaggregateobjectsequentiallywithoutexposingitsunderlyingrepresentationFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al130IteratorFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al131Iteratorexample:From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al132ExempleFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al133MementoWithoutviolatingencapsulation,captureandexternalizeanobject'sinternalstatesothattheobjectcanberestoredtothisstatelater.From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al134MementoStructure…From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al135Memento…PreservingencapsulationboundariesItsimplifiesOriginatorUsingmementosmightbeexpensive.DefiningnarrowandwideinterfacesHiddencostsincaringformementosFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al136CaseStudyFrom«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al137Designproblems…Documentstructure.ThechoiceofinternalrepresentationforthedocumentaffectsnearlyeveryaspectofLexi'sdesign.Allediting,formatting,displaying,andtextualanalysiswillrequiretraversingtherepresentation.Thewayweorganizethisinformationwillimpactthedesignoftherestoftheapplication.
Formatting.HowdoesLexiactuallyarrangetextandgraphicsintolinesandcolumns?Whatobjectsareresponsibleforcarryingoutdifferentformattingpolicies?Howdothesepoliciesinteractwiththedocument'sinternalrepresentation?
From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al138Designproblems…Embellishingtheuserinterface.Lexi'suserinterfaceincludesscrollbars,borders,anddropshadowsthatembellishtheWYSIWYGdocumentinterface.SuchembellishmentsarelikelytochangeasLexi'suserinterfaceevolves.Henceit'simportanttobeabletoaddandremoveembellishmentseasilywithoutaffectingtherestoftheapplication.
Supportingmultiplelook-and-feelstandards.Lexishouldadapteasilytodifferentlook-and-feelstandardssuchasMotifandPresentationManager(PM)withoutmajormodification.From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al139Designproblems…Embellishingtheuserinterface.Lexi'suserinterfaceincludesscrollbars,borders,anddropshadowsthatembellishtheWYSIWYGdocumentinterface.SuchembellishmentsarelikelytochangeasLexi'suserinterfaceevolves.Henceit'simportanttobeabletoaddandremoveembellishmentseasilywithoutaffectingtherestoftheapplication.
Supportingmultiplelook-and-feelstandards.Lexishouldadapteasilytodifferentlook-and-feelstandardssuchasMotifandPresentationManager(PM)withoutmajormodification.From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al140Designproblems…Spellingcheckingandhyphenation.HowdoesLexisupportanalyticaloperationssuchascheckingformisspelledwordsanddetermininghyphenationpoints?Howcanweminimizethenumberofclasseswehavetomodifytoaddanewanalyticaloperation?From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al141From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al142From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al143From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al144From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al145From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al146From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al147From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al148From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al149From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al150From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al151From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al152From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al153From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al154From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al155From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al156From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al157Summary(C.Alexander)Itispossibletomakebuildingbystringingtogetherpatterns,inaratherlooseway.Abuildingmadelikethis,isanassemblyofpatterns.Itisnotdense.Itisnotprofound.Butitisalsopossibletoputpatternstogetherinsuchwaythatmanypatternsoverlapinthesamephysicalspace:thebuildingisverydense;ithasmanymeaningscapturedinasmallspace;andthroughthisdensity,itbecomesprofound.158ArchitecturalPatterns…FromMUDtoStructure…Layers,PipeandFilters,BlackboardDistributedSystems…Broker,PipeandFilters,MicrokernelInteractiveSystems…MVC,PACAdaptableSystems…Microkernel,Reflection…159Layerhelpstostructureapplicationthatcanbedecomposedintogroupsofsubtasksinwhicheachgroupofsubtasksisataparticularlevelofabstraction.160Layer:examples161Layer:Structure162Layer:Structure163Layerandcomponents…164LayerandFacadeDP…165LayerandFacadeDP166Layers:VariantsRelaxedLayeredSystem:Alayer«
j
»canuseserviceofj-1,j-2…AlayercanbepartiallyopaqueSomeservicetolayerj+1,otherstoallupperservices…Layeringthroughinheritance:LowerlayersareimplementedasbaseclassesHigherlevelcanoverridelowerlevel…167Layers:KnownUsesVirtualmachines:JVMandbinarycodeformatAPI:LayerthatencapsulateslowerlayersInformationSystemPresentation,Applicationlogic,DomainLayer,DatabaseWindowsNT(relaxedfor:kernelandIOandhardware)Systemservices,Resourcemanagement(Objectmanager,securitymonitor,processmanager,I/Omanager,VMmanager,LPC),Kernel(exceptionhandling,interrupt,multiprosynchro,threads),HAL(HardwareAbstractionLevel)Hardware168Layers:benefitsReuseoflayersSupportforstandardization(POSIX)DependenciesarekeptlocalExchangeabilities:ReplacementofoldimplementationwithAdapterPatternDynamicexchangewithBridgePattern169Layers:LiabilitiesCascadesofchangingbehaviorLowerefficiencyUnnecessarywork:functionsofalayercalledmanytimesforoneserviceDifficultyofestablishingcorrectgranularityoflayers:Tofewlayer->lessbenefits,tomuchlayer->complexityandoverhead…170PipesandFiltersProvidesastructureforsystemsthatprocessastreamofData.Eachprocessingstepisencapsulatedinafiltercomponent.Dataispassedthroughpipesbetweenadjacentfilters.Recombiningfiltersallowstobuildfamiliesofrelatedsystems.171PipesandFilters:Example172PipesandFilters:Structure173PipesandFilters174PipesandFilters:pushpipeline175PipesandFilters:pullpipeline176PipesandFilters:push-pullpipeline177PipesandFilters:ThreadedFilters178PipesandFilters:KnownUsesUnixCMSPipelines(extensionIBMmainframes)LASSPTools(NumericalAnalysis)Graphicalinputdevices(knobsorsliders)FiltersfornumericalanalysisanddataextractionDatasinkstoproduceanimationfromnumericaldatastreams…Khoros:Imagerecognition…WEB!!Servlet!!179PipesandFiltersbenefitsNointermediatefilenecessary(butpossible)FlexibilitybyfilterexchangeFlexibilitybyrecombinationReuseoffiltercomponentsRapidprototypingofpipelineEfficiencybyparallelprocessing180PipesandFiltersLiabilitiesSharingstateinformationisexpensiveorinflexibleEfficiencygainbyparallelprocessingisoftenanillusion
Costofdatatransfer,filtersthatconsumealldatabeforeoneoutput,contextswitchononecomputer,synchronizationoffiltersviapipesDatatransformationoverheadErrorHandling181[SunDeveloppers]From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al182From«
SystemofPatterns
»Buschmann&Alland«
DesignPattern
»Gamma&Al183Blackboard TheBlackboardarchitecturalpatternisusefulforproblemsforwhichnodeterministicsolutionstrategiesareknown.Severalspecializedsubsystemsassembletheirknowledgetobuildapossiblypartialorapproximatesolution.184BlackboardExample185BlackboardStructure186BlackboardStructure187BlackboardStructure188BlackboardVariantsProductionSystem(OPSLanguage)Blackboard:workingmemoryKnowledgesource:Condition-actionrulesControl:conflictresolutionmodule.
Repository:
blackboard:Data,
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年中职农业技术(农业技术应用)试题及答案
- 2025年大学一年级(医学检验技术)临床微生物检验试题及答案
- 2025年中职农业经济管理(农村经济核算)试题及答案
- 2025年高职第二学年(制冷与空调技术)制冷系统设计专项测试卷
- 2025年大学第四学年(生物技术)基因工程综合测试试题及答案
- 2025年大学编辑出版学(编辑校对基础)试题及答案
- 2025年大学(口腔医学)口腔医学心理学试题及答案
- 2025年大学护理技能综合训练(护理综合技能)试题及答案
- 2025年高职新能源汽车检测与维修(汽车减排管理)试题及答案
- 2025年中职西式烹饪工艺(海鲜烹饪)试题及答案
- 2022年-2024年青岛卫健委事业编中医笔试真题
- JJG(交通) 070-2006 混凝土超声检测仪
- 合作销售矿石协议书
- 2025上海初三各区一模、二模作文题、主题归纳及审题分析指导
- 围手术期心肌梗塞的护理
- 2025-2026学年苏教版(2024)小学科学二年级上册期末测试卷附答案(共三套)
- 垃圾清运补充合同范本
- 2026届湖南省长沙市长郡集团九年级物理第一学期期末预测试题含解析
- 生日主题宴会设计方案
- 《JJG 1081.1-2024铁路机车车辆轮径量具检定规程 第1部分:轮径尺》 解读
- 《基坑围护结构渗漏检测技术标准》
评论
0/150
提交评论