武汉理工软件设计与体系结构复习仅供参考.docx
《武汉理工软件设计与体系结构复习仅供参考.docx》由会员分享,可在线阅读,更多相关《武汉理工软件设计与体系结构复习仅供参考.docx(18页珍藏版)》请在冰豆网上搜索。
武汉理工软件设计与体系结构复习仅供参考
1简答题
什么是防止变异模式?
是如何设计对象,子系统和系统,使这些元素内部的变化或不稳定性不会对其他元素产生不良影响。
解决方案:
识别预测的变化或不稳定之处,分配职责用以创建稳定接口。
2.什么是依赖反转原理?
把你的类从具体的实现中隔离开,使它们依赖于抽象类或接口。
它促进了代码面向接口而不是实现,这通过保证对实现的低耦合来增加系统的灵活性。
3.仓库风格的组件和连接器是什么?
组件:
(1)一个能表示出系统的正确状态的数据结构
(2)操作主要数据结构的独立组件的集合。
连接器:
典型的过程调用或是直接内存访问。
什么是响应时间?
⏹measureofthelatencyanapplicationexhibitsinprocessingarequest
对一个应用程序在处理请求显示出的潜在因素的测量标准。
常用的中间件有那几种类型?
⏹CORBA(CommonObjectRequestBrokerArchitecture)
⏹Message-orientedmiddleware
⏹J2EE
⏹Messagebrokers
⏹Businessprocessorchestrators
(1)常见的对象请求代理架构
(2)面向消息的中间件
(3)Java2EnterpriseEdition(Java2的企业版)
(4)消息代理
(5)业务过程代理
管道过滤器风格?
在管道/过滤器风格的软件体系结构中,每个构件都有一组输入和输出,构件读输入的数据流,经过内部处理,然后产生输出数据流。
这个过程通常通过对输入流的变换及增量计算来完成,所以在输入被完全消费之前,输出便产生了。
因此,这里的构件被称为过滤器,这种风格的连接件就象是数据流传输的管道,将一个过滤器的输出传到另一过滤器的输入
架构师需要的核心技能是什么?
⏹Manyresponsibilities:
❑Liaisonwithstakeholders
❑Technologyknowledge
❑Softwareengineering
❑Riskmanagements
(1)涉众之间的交流
(2)技术知识
(3)软件工程学
(4)风险管理
什么是软件架构?
⏹It’saboutsoftwaredesign
❑Allarchitectureissoftwaredesign,butnotalldesignissoftwarearchitecture
❑Partofthedesignprocess
⏹Simply,architecturefocuseson‘issuesthatwillbedifficult/impossibletochangeoncethesystemisbuilt’
❑Qualityattributeslikesecurity,performance
❑Non-functionalrequirementslikecost,deploymenthardware
❑Moreontheselaterinthissession
它是关于软件设计:
所有的架构是软件设计,但不是所有的设计都是软件架构。
设计过程的一个部分
简单地说,架构关注“一旦系统建立后就很难或是不可能改变的问题”:
质量属性,例如安全性,性能
非功能性需求,像开销,硬件配置
更多的是在这个部分之后的
答:
软件架构(softwarearchitecture)是一系列相关的抽象模式,用于指导大型软件系统各个方面的设计。
软件架构是一个系统的草图。
软件架构描述的对象是直接构成系统的抽象组件。
各个组件之间的连接则明确和相对细致地描述组件之间的通讯。
在实现阶段,这些抽象组件被细化为实际的组件,比如具体某个类或者对象。
在面向对象领域中,组件之间的连接通常用接口_(计算机科学)来实现。
什么是架构风格?
一组原则。
你可以把它看成是一组为系统家族提供抽象框架的粗粒度模式。
什么是架构视图?
一个架构视图是对于从某一视角或某一点上看到的系统所做的简化描述,描述中涵盖了系统的某一特定方面,而省略了此方面无关的实体。
OO风格的组件和连接器是什么?
⏹Components:
areobjects.
⏹Connectors:
arefunctionandprocedureinvocations(methods).
组件:
对象
连接器:
功能和过程调用(方法)
什么是可伸缩性?
⏹“Howwellasolutiontosomeproblemwillworkwhenthesizeoftheproblemincreases.”
当问题的规模增加,对一些问题的解决方案能否很好的运作。
理论上,可以称为软件系统的工作负载能力和硬件资源的投入成比例。
换句话说,在一个具有良好伸缩性的系统中,如果你加大工作量两倍,那么软件系统将使用两倍系统资源(假设足够的化),同时获得两倍的工作能力,当然也不可能无限制的和硬件增加成比例。
反过来说,一个可伸缩性差的系统,在一个低端的PCserver和高配的小机上的性能是没有很大的区别的。
什么是开闭原则?
•TheOCP(Open-ClosedPrinciple)statesthatclassesshouldbeopenforextensionandclosedformodification,inthatyoushouldbeabletoaddnewfeaturesandextendaclasswithoutchangingitsinternalbehavior.Theprinciplestrivestoavoidbreakingtheexistingclassandotherclassesthatdependonit,whichwouldcreatearippleeffectofbugsanderrorsthroughoutyourapplication.
开闭原则陈述了类应该对扩展开放,对修改关闭;这样你就能够添加新的特征,扩展一个类而不需要改变它的内部行为。
这个原则避免破坏存在的类和其他依赖它的类,这样可能会造成你的整个应用程序产生故障和错误的涟漪。
开放封闭原则(OCP)中的类应该对扩展开放,对修改关闭,你应该能够添加新的特点和延长上课不改变其内部的行为。
原则竭力避免打破了现有的阶级和其他课程,而依靠它,这将创造一个连锁效应,在你的错误和错误的应用。
什么是信息专家模式?
我们在设计对象(类)时,如果某个类能够在某方面具有完整信息,足以实现某责任,就将这个责任分配给这个类,这个类即所谓的信息专家.
2详述以下问题
GRASP模式的具体内容
1.Creator
AssigntoclassBtheresponsibilitytocreateaninstanceofclassAif
1.BaggregatesAobjects.
2.BcontainsAobjects.
3.BrecordsinstancesofAobjects.
4.BcloselyusesAobjects.
5.BhastheinitializingdatathatwillbepassedtoAwhenitiscreated.
2.Expert
“…expressesthecommon‘intuition’thatobjectsdothingsrelatedtotheinformationtheyhave.”
Assigntheresponsibilityfor“knowing”[something]totheobject(class)thathastheinformationnecessarytofulfilltheresponsibility.
3.Controller
ThecontrolleristhefirstobjectbeyondtheUIlayerthatisresponsibleforreceivingorhandlingasystemoperationsmessage.
4.LowCoupling
Measuresthedegreeofdependencythatexistsbetweenmodules.
5.HighCohesion
Measureofthedegreeof“relatedness”thatelementswithinamoduleshare.
Degreetowhichthetasksperformedbyasinglemodulearefunctionallyrelated.
6.Polymorphism
Whenrelatedalternativesorbehaviorsvarybytype(class),assignresponsibilityforthebehavior—usingpolymorphicoperations—tothetypesforwhichthebehaviorvaries.
7.PureFabrication
Assignahighlycohesivesetofresponsibilitiestoanartificialorconvenienceclassthatdoesnotrepresentaproblemdomainconcept—somethingmadeup,tosupporthighcohesion,lowcoupling,andreuse.
8.Indirection
Problem:
Howtoassignresponsibilitytoavoiddirectcoupling?
Howtode-coupleobjects?
Solution:
Assignresponsibilitytoanintermediatoryobjecttomediatebetweenthetwocomponents
9.ProtectedVariations
Problem:
Howtodesignobjects,subsystems,andsystemssothatthevariationsorinstabilityintheseelementsdoesnothaveanundesireableimpactonotherelements?
Solution:
Identifypointsofpredictedvariationorinstability;assignresponsibilitytocreateastableinterfacearoundthem.
1.创造者
分配给类B职责来创造类A的一个实例如果:
(1)B聚合A的对象
(2)B包含A的对象
(3)B记录A的对象的实例
(4)B紧密地使用A的对象
(5)B被创建时有初始化的数据传递给
2.专家
在设计对象(类)时,如果某个类能够在某方面具有完整信息,足以实现某责任,就将这个责任分配给这个类,
3.控制器
控制器是在用户接口层上的第一个对象,负责接收和处理系统的操作信息。
4.低耦合
测量存在于模块之间的依赖程度
5.高内聚
测量一个共享的模块内元素的相关性
一个单独模块执行任务的程度是功能相关的
6.多态
当相关的供选方案或行为随着类型的变化而变化时,给行为分配职责—使用多态操作—来适合行为变化的类型。
7.纯虚构
分配一系列高度聚合的职责给虚假的类或是不表现某事完成的领域问题概念的有用的类,它支持高内聚、低耦合、可重用。
8.间接
问题:
如何分配职责避免直接耦合?
如何减弱对象的耦合?
解决方案:
分配职责给中间的调解对象来调解两个组件之间的关系。
9.防止编译
问题:
如何设计对象,子系统和系统,使其内部的变化和不稳定不会对其他元素产生不良影响?
解决方案:
识别设计变化或不稳定之处,分配职责用以在这些变化之外创建稳定接口。
GRASP用职责设计对象:
"DesigningObjectswithResponsibilities".它包含了9个基本模式:
1.信息专家(Informationexpert)2.创建者(Creator)3.高内聚(HighCohesion)4.低耦合(LowCoupling)5.控制器(Controller)6.多态性(Polymorphism)7.纯虚构(PureFabrication)8.间接性(Indirection)9.变化预防(ProtectedVariations)GRASP的主要特征:
-对象职责分配的基本原则。
-主要应用在分析和建模上。
GRASP的核心思想的理解:
自己干自己的事(职责的分配)自己干自己的能干的事(职责的分配)自己只干自己的事(职责的内聚)
常见的架构风格
1.PipeandFilterArchitecturalStyle
⏹Suitableforapplicationsthatrequireadefinedseriesofindependentcomputationstobeperformedonordereddata.
⏹Acomponentreadsstreamsofdataonitsinputsandproducesstreamsofdataonitsoutputs.
⏹Components:
calledfilters,applylocaltransformationstotheirinputstreamsandoftendotheircomputingincrementallysothatoutputbeginsbeforeallinputisconsumed.
⏹Connectors:
calledpipes,serveasconduitsforthestreams,transmittingoutputsofonefiltertoinputsofanother.
2.Object-OrientedStyle
⏹Suitableforapplicationsinwhichacentralissueisidentifyingandprotectingrelatedbodiesofinformation(data).
⏹Datarepresentationsandtheirassociatedoperationsareencapsulatedinanabstractdatatype.
⏹Components:
areobjects.
⏹Connectors:
arefunctionandprocedureinvocations(methods).
3.ImplicitInvocationStyle
⏹Suitableforapplicationsthatinvolveloosely-coupledcollectionofcomponents,eachofwhichcarriesoutsomeoperationandmayintheprocessenableotheroperations.
⏹Particularlyusefulforapplicationsthatmustbereconfiguredonthefly:
❑Changingaserviceprovider.
❑Enablingordisablingcapabilities.
⏹Insteadofinvokingaproceduredirectly...
❑Acomponentcanannounce(orbroadcast)oneormoreevents.
❑Othercomponentsinthesystemcanregisteraninterestinaneventbyassociatingaprocedurewiththeevent.
❑Whenaneventisannounced,thebroadcastingsystem(connector)itselfinvokesalloftheproceduresthathavebeenregisteredfortheevent.
Aneventannouncement“implicitly”causestheinvocationofproceduresinothermodules.
4.Client-ServerStyle
⏹Suitableforapplicationsthatinvolvedistributeddataandprocessingacrossarangeofcomponents.
⏹Components:
❑Servers:
Stand-alonecomponentsthatprovidespecificservicessuchasprinting,datamanagement,etc.
❑Clients:
Componentsthatcallontheservicesprovidedbyservers.
⏹Connector:
Thenetwork,whichallowsclientstoaccessremoteservers.
5.LayeredStyle
⏹Suitableforapplicationsthatinvolvedistinctclassesofservicesthatcanbeorganizedhierarchically.
⏹Eachlayerprovidesservicetothelayeraboveitandservesasaclienttothelayerbelowit.
⏹Onlycarefullyselectedproceduresfromtheinnerlayersaremadeavailable(exported)totheiradjacentouterlayer.
⏹Components:
aretypicallycollectionsofprocedures.
⏹Connectors:
aretypicallyprocedurecallsunderrestrictedvisibility
6.RepositoryStyle
⏹Suitableforapplicationsinwhichthecentralissueisestablishing,augmenting,andmaintainingacomplexcentralbodyofinformation.
⏹Typicallytheinformationmustbemanipulatedinavarietyofways.Oftenlong-termpersistenceisrequired.
⏹Components:
⏹Acentraldatastructurerepresentingthecorrectstateofthesystem.
⏹Acollectionofindependentcomponentsthatoperateonthecentraldatastructure.
⏹Connectors:
⏹Typicallyprocedurecallsordirectmemoryaccesses.
7.InterpreterStyle
⏹Suitableforapplicationsinwhichthemostappropriatelanguageormachineforexecutingthesolutionisnotdirectlyavailable.
⏹Components:
includeonestatemachinefortheexecutionengineandthreememories:
⏹currentstateoftheexecutionengine
⏹programbeinginterpreted
⏹currentstateoftheprogrambeinginterpreted
⏹Connectors:
⏹procedurecalls
⏹directmemoryaccesses
8.Process-ControlStyle
⏹Suitableforapplicationswhosepurposeistomaintainspecifiedpropertiesoftheoutputsoftheprocessat(sufficientlynear)givenreferencevalues.
⏹Components:
❑ProcessDefinitionincludesmechanismsformanipulatingsomeprocessvariables.
❑ControlAlgorithmfordecidinghowtomanipulateprocessvariables.
⏹Connectors:
arethedataflowrelationsfor:
❑ProcessVariables:
⏹Controlledvariablewhosevaluethesystemisintendedtocontrol.
⏹Inputvariablethatmeasuresaninputtotheprocess.
⏹Manipulatedvariablewhosevaluecanbechangedb