您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 管理学资料 > SA022Style调用返回仓库
1SE3121021:SoftwareArchitectureSoftwareArchitectureStyle2SoftwareArchitectureStyle:Call/Return调用/返回3Call/Return的不同种类•Mainprogramandsubroutines主程序和子程序–Classicalprogrammingparadigm-functionaldecomposition•Object-Oriented/AbstractDataTypes–Information(representation,accessmethod)hiding•Layeredhierarchies–Eachlevelonlycommunicateswithitsimmediateneighbors•Other–Client/Server–……4History•Mainprogramandsubroutines–单线程控制,划分为若干处理步骤•Functionalmodules–把处理步骤集成到模块内•AbstractDataTypes–操作和数据捆绑在一起,隐藏具体实现•Objects–方法(动态绑定),多态(子类),重用(继承)•OOArchitectures–对象活动在不同的进程/线程–Client/Server,tieredstyles•Components–多个接口,二进制兼容,中间件也是编程语言的发展历程5MainProgramandSubroutine思考:此图为有向图,是否可能出现环?6MainProgramandSubroutine•Problem:Thispatternissuitableforapplicationsinwhichthecomputationcanappropriatelybedefinedviaahierarchyofproceduredefinitions.存在层次结构•Context:Manyprogramminglanguagesprovidenaturalsupportfordefiningnestedcollectionsofprocedures(过程的嵌套)andforcallingthemhierarchically.Theselanguagesoftenallowcollectionsofprocedurestobegroupedintomodules,therebyintroducingname-spacelocality.Theexecutionenvironmentusuallyprovidesasinglethreadofcontrolinasinglenamespace.•Solution:–Systemmodel:callanddefinitionhierarchy,subsystemsoftendefinedviamodularity–Components:proceduresandexplicitlyvisibledata–Connectors:procedurecallsandexplicitdatasharing–Controlstructure:singlethread7MainProgramandSubroutine:Model•Hierarchicaldecomposition:–Basedondefinition-userelationship–Usesprocedurecallasinteractionmechanism•Singlethreadofcontrol:–Supporteddirectlybyprogramminglanguages•Hierarchicalreasoning:–Correctnessofasubroutinedependsonthecorrectnessofthesubroutinesitcalls。这里有递归的含义•Subsystemstructureimplicit:–Subroutinestypicallyaggregatedintomodules8MainProgramandSubroutine10CriteriaforModularization•Whatisamodule?–Commonview:apieceofcode.Buttoolimited.–Compilationunit,includingrelateddeclarationsandinterface•Whymodularizeasystem,anyway?–Management:Partitiontheoveralldevelopmenteffort•divideandconquer–Evolution:Decouplepartsofasystemsothatchangestoonepartareisolatedfromchangestootherparts–Understanding:Permitsystemtobeunderstoodascompositionofmind-sizedchunks•Keyissue:whatcriteriatouseformodularization11ModuleDecomposition•Parnas–Hidesecrets.OK,what’sa“secret”?•Representationofdata•Propertiesofadevice,otherthanrequiredproperties–Trytolocalizefuturechange•Hidesystemdetailslikelytochangeindependently•Exposeininterfacesassumptionsunlikelytochange–Usefunctionstoallowforchange•They’reeasiertochangethanvisiblerepresentation隐藏“会变”的,暴露“不变”的12Encapsulation/InformationHiding•Parnas:Hidesecrets(notjustrepresentations)•Booch:Object’sbehaviorischaracterizedbyactionsthatitsuffersandthatitrequires•Practicallyspeaking:–Objecthasstateandoperations,butalsohasresponsibilityfortheintegrityofitsstate(state相当于内部数据成员)–Objectisknownbyitsinterface–Objectisprobablyinstantiatedfromatemplate(类)–Objecthasoperationstoaccessandalterstateandperhapsgenerator(构造函数)–Therearedifferentkindsofobjects(e.g.,actor,agent,server)13Object-Oriented15ElementsofObjectArchitectures•Encapsulation:Restrictaccesstocertaininformation封装:限制对某些信息的访问•Interaction:Viaprocedurecallsorsimilarprotocol交互:通过过程调用或类似的协议•Polymorphism:Choosethemethodatrun-time多态:在运行时选择具体的操作•Inheritance:Shareddefinitionsoffunctionality继承:对共享的功能保持唯一的接口•Reuseandmaintenance:Exploitencapsulationandlocalitytoincreaseproductivity复用和维护:利用封装和聚合提高生产力严重依赖于具体使用的语言16ProblemswithObjectApproaches•Managingmanyobjects–vastseaofobjectsrequiresadditionalstructuring大量对象需要额外的结构来容纳–hierarchicaldesignsuggestedbyBoochandParnas•Managingmanyinteractions–singleinterfacecanbelimiting&unwieldy(hence,“friends”)只提供单一的接口不灵活(于是,“友元”)–somelanguages/systemspermitmultipleinterfaces(innerclass,interface,multipleinheritance)•Distributedresponsibilityforbehavior–makessystemhardtounderstand–interactiondiagramsnowusedindesign•Capturingfamiliesofrelateddesigns–types/classesareoftennotenough类图无法表示运行时内存状态–designpatterns作为解决此问题的一个分支17ManagingLargeObjectSets•PureO-Odesignleadstolargeflatsystemswithmanyobjects–Sameoldproblemscanreappear–Hundredsofmodules=hardtofindthings–Needawaytoimposestructure•Needadditionalstructureanddiscipline•Structuringoptions–Layers(whicharenotnecessarilyobjects)–Supplementalindex–Hierarchicaldecomposition:bigobjectsandlittleobjects18StylisticVariations•Client-server–Objectsareprocesses进程就是对象–Asymmetric:clientknowsaboutservers,butnotviceversa不对称:客户端知道服务器,反之则不然•Tiered–Elaborationonclient-serverC/S模式的扩展–Aggregationintorun-timestrata运行时层的结合–Usuallysmallnumberoftiers通常只有少量的层•Components(later)–Multipleinterfaces–Specialprotocolsfordynamicreconfiguration支持动态配置的专门协议20OSI参考模型2122Thelayeredarchitecturalpattern•Problem:Thispatternissuitableforapplicationsthatinvolvedistinctclassesofservicesthatcanbearrangedhierarchically.Oftentherearelayersforbasicsystem-levelservices,forutilitiesappropriatetomanyapplications,andforspecifictasksoftheapplication.•Context:Frequently,eachclassofserviceisassignedtoalayerandseveraldifferentpatternsareusedtorefinethevariouslayers.Layersaremostoftenusedatt
本文标题:SA022Style调用返回仓库
链接地址:https://www.777doc.com/doc-1243676 .html