首页 软件工程-实践者的研究方法(9)精编版

软件工程-实践者的研究方法(9)精编版

举报
开通vip

软件工程-实践者的研究方法(9)精编版Chapter10Component-LevelDesignSoftwareEngineering:APractitioner’sApproach,7/ebyRogerS.PressmanWhatisaComponent?OMGUnifiedModelingLanguageSpecification[OMG01]definesacomponentas“…amodular,deployable,andreplaceablepartofasystemthatencapsulates...

软件工程-实践者的研究方法(9)精编版
Chapter10Component-LevelDesignSoftwareEngineering:APractitioner’sApproach,7/ebyRogerS.PressmanWhatisaComponent?OMGUnifiedModelingLanguageSpecification[OMG01]definesacomponentas“…amodular,deployable,andreplaceablepartofasystemthatencapsulatesimplementationandexposesasetofinterfaces.””OOview:acomponentcontainsasetofcollaboratingclassesConventionalview:acomponentcontainsprocessinglogic,theinternaldatastructuresthatarerequiredtoimplementtheprocessinglogic,andaninterfacethatenablesthecomponenttobeinvokedanddatatobepassedtoit.OOComponentConventionalComponentConventionalComponentBasicDesignPrinciplesOpen-ClosedPrinciple(开闭 原则 组织架构调整原则组织架构设计原则组织架构设置原则财政预算编制原则问卷调查设计原则 ).“Amodule[component]shouldbeopenforextensionbutclosedformodification.SubstitutionPrinciple(替换原则).“Subclassesshouldbesubstitutablefortheirbaseclasses.DependencyInversionPrinciple(依赖倒置原则).“Dependonabstractions.Donotdependonconcretions(具体实现).”InterfaceSegregationPrinciple(接口分离原则).“Manyclient-specificinterfaces(专用接口)arebetterthanonegeneralpurposeinterface.ReleaseReuseEquivalencyPrinciple(发布复用等价原则).“Thegranule(粒度)ofreuseisthegranuleofrelease.”CommonClosurePrinciple(共同封装原则).“Classesthatchangetogetherbelongtogether.(同时变更的类应封装在一起)”CommonReusePrinciple(共同重用原则).“Classesthataren’treusedtogethershouldnotbegroupedtogether.”DesignGuidelinesComponentsNamingconventionsshouldbeestablishedforcomponentsthatarespecifiedaspartofthearchitecturalmodelandthenrefinedandelaboratedaspartofthecomponent-levelmodelInterfacesInterfacesprovideimportantinformationaboutcommunicationandcollaboration(aswellashelpingustoachievetheOPC)DependenciesandInheritanceitisagoodideatomodeldependenciesfromlefttorightandinheritancefrombottom(derivedclasses)totop(baseclasses).Cohesion(内聚度)Conventionalview:the“single-mindedness”ofamoduleOOview:cohesionimpliesthatacomponentorclassencapsulatesonlyattributesandoperationsthatarecloselyrelatedtooneanother.Levelsofcohesion(内聚度依次递减)FunctionalLayerCommunicationalSequentialProceduralTemporal 设计 领导形象设计圆作业设计ao工艺污水处理厂设计附属工程施工组织设计清扫机器人结构设计 目标:模块内各动作的内聚度越高越好。Coupling(耦合度)Conventionalview:ThedegreetowhichamoduleisconnectedtoothermodulesandtotheexternalworldOOview:aqualitativemeasureofthedegreetowhichclassesareconnectedtooneanotherLevelofcoupling(耦合度依次递减)ContentCommonControlDataRoutinecallExternal设计目标:模块之间的耦合度越底越好。ComponentLevelDesign-IStep1.Identifyalldesignclassesthatcorrespondtotheproblemdomain.Step2.Identifyalldesignclassesthatcorrespondtotheinfrastructuredomain.(forexample,GUIcomponent,OScomponents)Step3.Elaboratealldesignclassesthatarenotacquiredasreusablecomponents,includingthemessage,interface,attributeandoperation.Step3a.Specifymessagedetailswhenclassesorcomponentcollaborate.(CollaborationDiagramwithmessagesisshown)ComponentLevelDesign-IStep3b.Identifyappropriateinterfacesforeachcomponent.下图为PrintJob重构类和接口定义Step3c.Elaborateattributesanddefinedatatypesanddatastructuresrequiredtoimplementthem.Component-LevelDesign-IIStep3d.Describeprocessingflowwithineachoperationindetail.实例:右图为ComputePaperCost()操作的ActivityDiagram.Component-LevelDesign-IIIStep4.Describedatasources(database)andidentifytheclassesrequiredtomanagethem.Step5.Developandelaboratebehavioralrepresentationsforaclassorcomponent.(右图为PrintJob类的StateChart)Step6.Elaboratedeploymentdiagramstoprovideadditionalimplementationdetail.AlgorithmDesignModelrepresentsthealgorithmatalevelofdetailthatcanbereviewedforqualityoptions:decisiontable/treegraphical(e.g.flowchart,boxdiagram)PAD(ProgramAnalysisDiagram)pseudocode(e.g.PDL)DecisionTableFlowchartNS(Box)DiagramProgramAnalysisDiagram(PAD)ProgramAnalysisDiagram(PAD)例:模块binary(x,v,n,p)完成判断一个特定值x是否出现在已经按递增顺序排好序的数组v中。如果存在则返回相应下标mid,否则返回值-1。ProgramDesignLanguage(PDL)ProgramDesignLanguage(PDL)StepwiseRefinementopenwalktodoor;reachforknob;opendoor;walkthrough;closedoor.repeatuntildooropensturnknobclockwise;ifknobdoesn'tturn,thentakekeyout;findcorrectkey;insertinlock;endifpull/pushdoormoveoutofway;endrepeatDesigningConventionalComponentsThedesignofprocessinglogicisgovernedbythebasicprinciplesofalgorithmdesignandstructuredprogrammingThedesignofdatastructuresisdefinedbythedatamodeldevelopedforthesystemThedesignofinterfacesisgovernedbythecollaborationsthatacomponentmusteffectAlgorithmDesigntheclosestdesignactivitytocodingtheapproach:reviewthedesigndescriptionforthecomponentusestepwiserefinementtodevelopalgorithmusestructuredprogrammingtoimplementprocedurallogicuse‘formalmethods’toprovelogicY逐步求精方法示例:骑士周游问题。给出一块有n2个格子的棋盘。一位骑士放在初始坐标为(x0,y0)的格子里,然后按照国际象棋的规则移动。问题是找到一种可以走遍整个棋盘的 方案 气瓶 现场处置方案 .pdf气瓶 现场处置方案 .doc见习基地管理方案.doc关于群访事件的化解方案建筑工地扬尘治理专项方案下载 (如果这种方案存在),即计算一个n2-1次移动的周游,使得棋盘上每一个格子恰好被走过(访问过)一次。(1)数据结构设计:棋盘:用一个二维整型数组h[i,j],i=1..n,j=1..n马的移动位置:有8个可走位置。马的初始位置为(x,y),下一个移动位置(x+a[k],y+b[k]),其中k=1..8。棋盘格子h[x,y]是否被访问过,可以用下面的方式记录:X0PDL描述举例0表示格子[x,y]未被访问过i表示格子[x,y]在第i次移动中被访问过,1<=i<=n2h[x,y]=3241马5867ka[k]b[k]1212123-124-215-2-16-1-271-282-1(2)算法设计:试探+回溯步1:初始化;步2:对给定的马的当前位置调用“试探下步移动”;步3:if下步移动成功then步3.1:打印移动结果;else步3.2:打印无解ednif“初始化”细化为:1.1马的8个可移动位置的差值分别按照前面 表格 关于规范使用各类表格的通知入职表格免费下载关于主播时间做一个表格详细英语字母大小写表格下载简历表格模板下载 中的值预先放在a、b数组中;1.2棋盘h[i,j]在马未访问过时应该都预先放入0;1.3马的最初位置可以是(1,1);此时该位置所确定的棋盘格子认为被访问过,因此应有h[1,1]=1。步3中对“下步移动成功”的判断可以对步2中“试探下步移动”即过程try(i,x,y,q)调用结果的返回值q作判断即可:q为true即为移动成功,q为false即为移动失败。步3.1“打印移动结果”即输出数组h[i,j]的各元素之值。其中i,j的取值为1到n;步3.2“打印无解”即是输出一个提示信息。PDL描述举例(2)算法设计:试探+回溯步1:初始化;步2:对给定的马的当前位置调用“试探下步移动”;步3:if下步移动成功then步3.1:打印移动结果;else步3.2:打印无解。endif对于马的当前位置的下步移动应该有8个候选位置用K计数,候选次序是前面图示中的逆时针方向进行。一旦进入下一步即一个新的位置,同样又要“试探下步移动”。如果本步移动成功,那么返回“真”,否则返回“假”。因此是一个递归过程try(i,x,y,q)。“试探下步移动”可设为try(i,x,y,q):2.0做候选准备;2.1repeat2.1.1从下一步移动表中挑选出下一步候选者;2.1.2if候选者可接受then进行移动;endif2.2until移动成功或再无候选者;2.3返回移动成功与否的标志.马在当前位置而且在下步移动前,一个位置都没有试探过,因此k值应为0。8个候选位置试探完毕时k值应为8。PDL描述举例“试探下步移动”还需要细化:2.0做候选准备;2.1repeat2.1.1从下一步移动表中挑选出下一步候选者2.1.2如果候选者可接受,则2.1.2.1进行移动;2.2until移动成功或再无候选者;2.3返回移动成功与否的标志.如果候选者的当前步为k,则候选者的下一步变为k+1。下一步的候选者“可接受”的条件应该是:u,v不能越界而且该步所处位置未被访问过,可表示为(1<=u<=n)and(1<=v<=n)and(h[u,v]=0)2.1.2.1“进行移动”可以进一步细化为:记录移动;if盘未走遍then“试探下步移动”即为递归调用步2;if“试探下步移动”不成功then删去这一记录即回溯;else用局部变量q1表示并赋true;endifendif设挑出的下一步候选者为(u,v),则u用x+a[k],v用y+b[k]替换。“移动成功”可把ture赋予局部变量q1;“再无候选者”意味着当前马的位置的下一步已经对可能的8个位置都试完了,因此可表示为k=8。移动成功与否可把变量q1的值赋予变量qPDL描述举例2.1.2.1“进行移动”还需要细化:记录移动;if盘未走遍then“试探下步移动”即为递归调用步2;if“试探下步移动”不成功then删去这一记录;else给q1赋值true;endifendif“记录移动”可以表示为:h[u,v]被赋予当前所试探的次数i。i是一个全局变量“盘未走遍”可以表示为:i<n2“试探下步移动”应该是一个递归调用,可以表示为:try(i+1,x,y,q1)“试探下步移动不成功”可以表示为:NOTq1“删去这一记录”可以表示为:h[u,v]被赋予0PDL描述举例PRAGRAMKNIGHTSTOUR//第1步:定义变量并初始化DECLAREn:asinteger;q:asboolean;GET(n);DO-WHILEi<=nDO-WHILEj<=nh[i,j]=0;j=j+1;ENDDOi=i+1;ENDDO;a[1]=2;b[1]=1;a[2]=1;b[2]=2;a[3]=-1;b[3]=2;a[4]=-2;b[4]=1;a[5]=-2;b[5]=-1;a[6]=-1;b[6]=-2;a[7]=1;b[7]=-2;a[8]=2;b[8]=-1;//第2步:试探下步移动h[1,1]=1;try(2,1,1,q);//调用过程//第3步:输出结果IFqTHENDO-WHILEi<=nDO-WHILEj<=nPUT(h[i,j]);j=j+1;ENDDO换行;i=i+1;ENDDOELSEPUT(“打印无解”);ENDIFENDPROG基于PDL描述获得最终算法//递归过程定义PROCEDUREtry(i,x,y,q)DECLAREi,x,y:asintegerARG;q:asbooleanARG;k=0;REPEATUNTILk=8orq1k=k+1;q1=FALSE;u=x+a[k];v=y+b[k];IF((1≤u≤n)and(1≤v≤n)and(h[u,v]=0))THENtry(i+1,u,v,q1);IFNOTq1THENh[u,v]=0ELSEq1=TRUE;ENDIFENDIFENDREPq=q1;ENDPROCComponent-BasedDevelopmentWhenfacedwiththepossibilityofreuse,thesoftwareteamasks:Arecommercialcomponentsavailabletoimplementtherequirement?Areinternally-developedreusablecomponentsavailabletoimplementtherequirement?Aretheinterfacesforavailablecomponentscompatiblewithinthearchitectureofthesystemtobebuilt?Component-BasedSEalibraryofcomponentsmustbeavailable.componentsshouldhaveaconsistentstructure.astandardshouldexist,e.g.,OMG/CORBAMicrosoftCOMSunJavaBeansOMG/CORBATheObjectManagementGrouphaspublishedacommonobjectrequestbroker(代理)architecture(OMG/CORBA).Anobjectrequestbroker(ORB)providesservicesthatenablereusablecomponents(objects)tocommunicatewithothercomponents.ObjectswithintheclientapplicationrequestoneormoreservicesfromtheORBserver.Requestsaremadedynamicallyatruntime.Aninterfacecontainsallnecessaryinformationabouttheservice’srequestandresponseformats.CORBA架构图基于CORBA的技术架构实例统一接入平台的技术架构图MicrosoftCOMThecomponentobjectmodel(COM)providesaspecificationforusingcomponentsproducedbyvariousvendors(供应商)withinanapplicationrunningundertheWindowsoperatingsystem.COMencompassestwoelements:COMinterfaces(implementedasCOMobjects)asetofmechanismsforregisteringandpassingmessagesbetweenCOMinterfaces.组件对象模型(COM)COM是微软对网页服务器与客户端、应用系统与Office软件间互动的一项组件技术。COM可以被应用于多种平台上(不限于Windows)。COM提供跟程序语言无关的方法实现一个组件,因此可以在其他环境中执行。COM要求组件遵照一个共同的界面,该界面与操作 内容 财务内部控制制度的内容财务内部控制制度的内容人员招聘与配置的内容项目成本控制的内容消防安全演练内容 无关。COM组件由以Win32动态连接库(DLL)或可执行文件(EXE)形式发布的可执行代码组成。遵循COM规范编写出来的组件将能够满足对组件架构的所有要求。COM组件可以给应用程序、操作系统以及其他组件提供服务;自定义的COM组件可以在运行时刻同其他组件连接起来构成某个应用程序;COM组件可以动态的插入或卸出应用。SunJavaBeansTheJavaBeanscomponentsystemisaportable,platformindependentCBSEinfrastructuredevelopedusingtheJavaprogramminglanguage.TheJavaBeanscomponentsystemprovidesasetoftools,calledtheBeanDevelopmentKit(BDK),thatallowsdeveloperstoanalyzehowexistingBeans(components)workcustomize(定制)theirbehaviorandappearanceestablishmechanismsforcoordinationandcommunicationdevelopcustomBeansforuseinaspecificapplicationtestandevaluateBeanbehavior.JavaBeanArchitecture1、有时候读书是一种巧妙地避开思考的方法。2、阅读一切好书如同和过去最杰出的人谈话。3、越是没有本领的就越加自命不凡。4、越是无能的人,越喜欢挑剔别人的错儿。5、知人者智,自知者明。胜人者有力,自胜者强。6、意志坚强的人能把世界放在手中像泥块一样任意揉捏。7、最具挑战性的挑战莫过于提升自我。。8、业余生活要有意义,不要越轨。9、一个人即使已登上顶峰,也仍要自强不息。10、你要做多大的事情,就该承受多大的压力。11、自己要先看得起自己,别人才会看得起你。12、这一秒不放弃,下一秒就会有希望。13、无论才能知识多么卓著,如果缺乏热情,则无异纸上画饼充饥,无补于事。14、我只是自己不放过自己而已,现在我不会再逼自己眷恋了。谢谢大家
本文档为【软件工程-实践者的研究方法(9)精编版】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
个人认证用户
MR杨
暂无简介~
格式:ppt
大小:861KB
软件:PowerPoint
页数:0
分类:建筑/施工
上传时间:2020-09-20
浏览量:85