設(shè)計(jì)模式案例(一)_第1頁
設(shè)計(jì)模式案例(一)_第2頁
設(shè)計(jì)模式案例(一)_第3頁
設(shè)計(jì)模式案例(一)_第4頁
設(shè)計(jì)模式案例(一)_第5頁
已閱讀5頁,還剩246頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論