首页 UML考试试题 - 副本

UML考试试题 - 副本

举报
开通vip

UML考试试题 - 副本UML考试试题 - 副本 面向对象分析与设计习题 一、单项选择题 1.到20世纪末,面向对象软件工程已经逐渐发展成熟,特别是(D)的 形成和广泛使用,采用面向对象分析与编程的软件开发方法已成为软件开发的主流方法。 A. Simula67语言 B. Smalltalk语言 C. Java语言 D. 统一建模语言(UML)的标准 2. 面向对象的运动产生了多种面向对象的语言, 其中(C)是一种混合性面向对象语言, 既支持面向过程的程序设计方法,又支持面向对象的程序设计方法,有广泛应用的基础和丰富开发环境的支持...

UML考试试题 - 副本
UML考试试题 - 副本 面向对象 分析 定性数据统计分析pdf销售业绩分析模板建筑结构震害分析销售进度分析表京东商城竞争战略分析 设计 领导形象设计圆作业设计ao工艺污水处理厂设计附属工程施工组织设计清扫机器人结构设计 习题 一、单项选择题 1.到20世纪末,面向对象软件工程已经逐渐发展成熟,特别是(D)的 形成和广泛使用,采用面向对象分析与编程的软件开发方法已成为软件开发的主流方法。 A. Simula67语言 B. Smalltalk语言 C. Java语言 D. 统一建模语言(UML)的 标准 excel标准偏差excel标准偏差函数exl标准差函数国标检验抽样标准表免费下载红头文件格式标准下载 2. 面向对象的运动产生了多种面向对象的语言, 其中(C)是一种混合性面向对象语言, 既支持面向过程的程序设计方法,又支持面向对象的程序设计方法,有广泛应用的基础和丰富开发环境的支持,因而使面向对象的程序设计能得到很快普及。 A. Smalltalk B. Eiffel C. C++ D. Java 3(下列不属于面向对象技术的基本特征的是(B)。 A. 封装性 B. 模块性 C. 多态性 D. 继承性 4. 面向对象程序设计将描述事物的数据与 (C) 封装在一起,作为一个相互依存、不可分割的整体来处理。 A. 信息 B. 数据隐藏 C. 对数据的操作 D. 数据抽象 5. 关于面向对象方法的优点,下列不正确的叙述是 (C)。 A. 与人类习惯的思维方法比较一致 B. 可重用性好 C. 以数据操作为中心 D.可维护性好 6. (D)是从用户使用系统的角度描述系统功能的图形表达方法。 A. 类图 B. 对象图 C. 序列图 D. 用例图 7. (C) 是表达系统类及其相互联系的图示,它是面向对象设计的核心,建立状态图、协作图 和其他图的基础。 A(对象图 B. 组件图 C. 类图 D. 配置图 8.(D)描述了一组交互对象间的动态协作关系,它表示完成某项行为的对象和这些对象之 间传递消息的时间顺序。 A(对象图 B. 协作图 C. 状态图 D. 序列图 9.(D)就是用于表示构成分布式系统的节点集和节点之间的联系的图示,它可以表示系统 中软件和硬件的物理架构。 A. 组件图 B. 协作图 C. 状态图 D. 配置图 10. 使用UML进行关系数据库的(B)时,需要设计出表达持久数据的实体类及其联系,并把它们映射成为关系数据库表(Table)、视图(View)等。 A. 业务Use Case模型设计 B. 逻辑数据模型设计 C. 物理数据模型设计 C. 物理实现设计 11.一个设计得好的OO系统具有(B) A. 低内聚、低耦合的特征 B. 高内聚、低耦合的特征 C. 高内聚、高耦合的特征 D. 低内聚、高耦合的特征 12.下面()不是UML的基本构成元素。(A) A. 控制语言 B. 基本构造块 C. 规则 D. 公共机制 is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to 13. 面向对象的特点主要概括为(C)。 A. 可分解性、可组合性、可分类性 B. 继承性、封装性、多态性 C. 抽象性、继承性、封装性、多态性 D. 封装性、易维护性、可扩展性、可重用性 14(构成对象的两个主要因素是(A)。 A. 属性和服务 B. 标识和内容 C. 继承和多态 D. 消息和封装 15.下列关于面向对象方法中描述中错误的是(C)。 A. 使用设计模式有助于在软件开发中应用面向对象技术 B. 选择面向对象程序设计语言时需要考虑开发人员对其的熟悉程度 C. UML作为一种可视化建模语言需要与RUP开发过程同时使用 D. 目前在软件生命周期的分析、设计、实现和测试中均可以应用面向对象方法 16. 顺序图主要可以为设计人员提供(A)信息。 A. 消息发送的顺序 B. 某个方法的执行流程 C. 类之间关联关系的多重性 D. 某个对象在不同状态之间的转移 17. 类和接口的关系类似于下面哪种类型的关系(D)。 A. 关联(association)和聚集(aggregation) B. 关联(association)和组合(composition) C. 脚本(scenario)和用例(use case) D. 包(Package)和子系统(subsystem) 18. 在类图中,那个类图中的类Order所生成的代码具有 Public class Order { Public Customer recipient; } 的形式,(A) B. A. D. C. 19. 下面那个图符表示UML中的实现关系,(C) B. A. C. D. 20. 一个银行业务系统采用如图琐事的配置图,则错误的是(D) is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to A. 与GUI有关的类应该部署在Branch Client上 B. 这个图表示一个三层的体系结构,不管Branch Client、Financial App Server、Database Server是运行在同一台机器上还是在不同机器上 C. 为了系统的可伸缩性(scalability),与业务逻辑有关的对象应该部署在Financial App Server上 D. 为了系统的可伸缩性,与业务逻辑有关的对象应该部署在Branch Client上 21. 关于用例与类的对比中(D)是错误的。 A 都属于模型结构元素 B 都存在继承关系 C 类描述系统的部分静态视图,用例描述系统动态的行为视图 D 类描述的是系统的内部构成,用例也可以描述系统的内部构成 22. Innovation公司正在为Rose开发插入件,使得Rose可以把OOA、OOD模型以各种图形格式导出,如JPEG格式、BMP格式、GIF格式等。在导出时,会根据不同的算法来生成相应的图形文件,这些算法很复杂。为了描述这些算法,在下面这些图中,那个是最适合的,(A)(注:活动图可以用来描述细节) A. 活动图 B. 状态图 C. 类图 D. 用例图 23. 计算机(Computer)由中央处理器、内存、软盘、硬盘、显示器、键盘、鼠标等组成。那么Computer类和其他类(CPU、RAM、FloppyDrive、HardDisk、Monitor、Keyboard、Mouse)之间的关系是:(D) A. 泛化关系(Generalization) B. 实现关系(Realization) C. 包含关系(Inclusion) D. 聚集关系(Aggregation) 24. 在状态图中不能表示下面那些概念,(D) A. 动作(action) B. 事件(event) C. 转移(transition) D. 类(class) 25.在数据库设计的 C 阶段开始考虑具体的数据库管理系统(DBMS)的特性。(C) A. 需求分析 B. 概念设计 C. 逻辑设计 .D 物理设计 26(在UML中,有3种基本构造块,分别是(A) A. 事物、关系和图 B. 注释、关系和图 C. 事物、关系和结构 D. 注释、关系和结构 27(在UML中,有四种关系,下面哪个不是(B) A.依赖关系 B.继承关系 C.泛化关系 D.实现关系 is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to 28(下面哪个不是UML中的静态视图(B) A.状态图 B.用例图 C.对象图 D.类图 29(在用例之间,会有三种不同的关系,下列哪个不是它们之间可能的关系( D ) A.包含(include) B.扩展(extend) C.泛化(generalization) D.关联(connect) 30(用例(Use-case)用来描述系统在事件做出响应时所采取的行动。用例之间是具有相关性的。在一个“订单输入子系统”中,创建新订单和更新订单都需要检查用户帐号是否正确。那么,用例“创建新订单”、“更新订单”与用例“检查用户帐号”之间是(B)关系 A.扩展(extend) B.包含(include) C.分类(classification) D.聚集(aggregation) 31(UML中类的有三种,下面哪个不是其中之一(B) A.实体类 B.抽象类 C.控制类 D.边界类 32(阅读图例,判断下列哪个说法是错误的。(c) A.读者可以使用系统的还书用例 B.每次执行还书用例都要执行图书查询用例 C.每次执行还书用例都要执行交纳罚金用例 D.执行还书用例有可能既执行图书查询用例,又执行交纳罚金用例 33(关于协作图的描述,下列哪个不正确(B) A.协作图作为一种交互图,强调的是参加交互的对象的组织; B.协作图是顺序图的一种特例 C.协作图中有消息流的顺序号; D.在ROSE工具中,协作图可在顺序图的基础上按“F5”键自动生成; 34. 设计模式具有的优点(a)。 A(适应需求变化 B.程序易于理解 C(减少开发过程中的代码开发工作量 D.简化软件系统的设计 35. 设计模式一般用来解决什么样的问题(a)。 A.同一问题的不同表相 B不同问题的同一表相 C.不同问题的不同表相 D.以上都不是 is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to 36. 设计模式的两大主题是(d)。 A.系统的维护与开发 B 对象组合与类的继承 C.系统架构与系统开发D.系统复用与系统扩展 37. 以下哪些问题通过应用设计模式不能够解决 。(c) A)指定对象的接口 B)针对接口编程 C)确定软件的功能都正确实现 D)设计应支持变化 38. 外观模式的作用是(b)。 A(当不能采用生成子类的方法进行扩充时,动态地给一个对象添加一些额外的功能。 B(为了系统中的一组功能调用提供一个一致的接口,这个接口使得这一子系统更加容易使用。 C(保证一个类仅有一个实例,并提供一个访问他的全局访问点。 D(在方法中定义算法的框架,而将算法中的一些操作步骤延迟到子类中实现。 39. Façade(外观)模式的意图是(a)。 A. 希望简化现有系统的使用方法。你需要定义自己的借口。 B(将一个无法控制的现有对象与一个特定借口相匹配。 C. 将一组实现部分从另一组使用它们的对象中分离出来。 D(你需要为特定的客户(或情况)提供特定系列的对象。 40. Adapter(适配器)模式的意图是(B)。 A. 希望简化现有系统的使用方法。你需要定义自己的接口。 B(将一个无法控制的现有对象与一个特定接口相匹配。 C. 将一组实现部分从另一组使用它们的对象中分离出来。 D(你需要为特定的客户(或情况)提供特定系列的对象。 41. 下面不属于创建型模式的有(C)。 A(抽象工厂模式( Abstract Factory ) B(工厂方法模式(Factory Method) C(适配器模式 (Adapter) D(单 例 模式 (Singleton) 42. 将一个类的接口转换成客户希望的另一个接口。这句话是对下列哪种模式的描述(C)。 A. 策略模式(Strategies) B(桥接模式(Bridge) C(适配器模式(Adapter) D( 单例模式(Singleton) 43. 以下关于结构型模式说法不正确的是 。(B) A)结构型模式可以在不破坏类封装性的基础上,实现新的功能。 B)结构型模式主要用于创建一组对象。 C)结构型模式可以创建一组类的统一访问接口。 is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to D)结构型模式可以在不破坏类封装性的基础上, 使得类可以同不曾估计到的系统进行交互。 44. 关于继承表述错误的是:(D)。 A.继承是一种通过扩展一个已有对象的实现,从而获得新功能的复用方法。 B.泛化类(超类)可以显式地捕获那些公共的属性和方法。特殊类(子类)则通过附加 属性和方法来进行实现的扩展。 C.在一定意义上说破坏了封装性,因为这会将父类的实现细节暴露给子类。 D.继承本质上是“白盒复用”,对父类的修改,不会影响到子类。 45.在不破坏类封装性的基础上,使得类可以同不曾估计到的系统进行交互。主要体现在(D)。 A外观模式(Facade) B装饰模式(Decorator) C策略模式(Strategies) D桥接模式(Bridge) 46. 行为类模式使用(B)在类间分派行为。 A接口 B继承机制 C对象组合 D委托 47. 下面的类图表示的是哪个设计模式,(D)。 A抽象工厂模式(Abstract Factory) B观察者模式(Observer) C策略模式(Strategies) D桥接模式(Bridge) 51. 下面的类图表示的是哪个设计模式,(A)。 A抽象工厂模式 B观察者模式 C 策略模式 D桥接模式 is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to 57. 下面的类图表示的是哪个设计模式,(D)。 A 策略模式(Strategies) B 装饰模式(Decorator) C 桥接模式(Bridge) D 观察者模式(Observer) 48. Bridge(桥接)模式的意图是(C)。 A. 希望简化现有系统的使用方法。你需要定义自己的借口。 B(将一个无法控制的现有对象与一个特定借口相匹配。 C. 将一组实现部分从另一组使用它们的对象中分离出来。 D(你需要为特定的客户(或情况)提供特定系列的对象。 49. 静态工厂的核心角色是(A)。 A.抽象产品 B.具体产品 C.静态工厂 D.消费者 50. 以下属于创建型模式的是(A)。 A抽象工厂模式(Abstract Factory) B 装饰模式(Decorator) C外观模式(Facade) D桥接模式(Bridge) is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to 52. Abstract Factory(抽象工厂)模式的意图是(D)。 A. 希望简化现有系统的使用方法。你需要定义自己的借口。 B(将一个无法控制的现有对象与一个特定借口相匹配。 C. 将一组实现部分从另一组使用它们的对象中分离出来。 D(提供一个创建一系列相关或相互依赖对象的接口,而无需指定它们具体的类 53. 在根据不同的机器选择设备驱动程序的案例中,以下叙述不准确的是(D)。 A. 可以使用switch语句选择驱动程序. B. 可以使用继承来实现选择驱动程序,但它可能会产生类组合爆炸问题.. C. 可以选择抽象工厂模式实现,且能避免组合爆炸问题. D. 使用继承的解决 方案 气瓶 现场处置方案 .pdf气瓶 现场处置方案 .doc见习基地管理方案.doc关于群访事件的化解方案建筑工地扬尘治理专项方案下载 要比switch语句有更多的优势. 54. 应用设计模式的一个优点是(A)。 A(适应需求变化 B.程序易于理解 C(减少开发过程中的代码开发工作量 D.简化软件系统的设计 55. 当我们想创建一个具体的对象而又不希望指定具体的类时,可以使用(A)模式。 A.创建型 B.结构型 C行为型 D.以上都可以 56. 在观察者模式中,表述错误的是(C)。 A.观察者角色的更新是被动的。 B.被观察者可以通知观察者进行更新 C.观察者可以改变被观察者的状态再由被观察者通知所有观察者依据被观察者的状态进行。 D.以上表述全部错误。 58. 当我们想创建一个具体的对象而又不希望指定具体的类时,可以使用(A)模式。 A.创建型 B.结构型 C行为型 D.以上都可以 59. 下列模式中,属于行为模式的是(B)。 A.工厂模式 B观察者 C适配器 D 以上都是 60. Observer模式不适用于(D)。 A当一个抽象模型存在两个方面,其中一个方面依赖于另一方面,将这二者封装在独立的 对象中以使它们可以各自独立的改变和复用。 B当对一个对象的改变需要同时改变其他对象,而不知道具体有多少个对象有待改变时。 C当一个对象必须通知其它对象,而它又不能假定其它对象是谁,也就是说你不希望这些 对象是紧耦合的。 D一个对象结构包含很多类对象,它们有不同的接口,而想对这些对象实施一些依赖于其具体类的操作。 二、判断题 1. 一个状态图最多只能由一个初态和一个终态。(F) 2. 协作图中的消息必须要有消息顺序号。(T) 3. 两个参与者(actor)之间可以有包含(include)关系、扩展(extend)关系或泛化is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to (generalization)关系,而包含关系和扩展关系是依赖(dependency)关系的版型。(F) 4. 参与者(actor)和用例(use case)之间的关系是关联(association)关系。(T) 5. 类A和类B之间的关系如图1所示,则称类B中的getName()方法是对类A中的 getName()方法的重载(overload)。(F) 图1 getName()方法之间的关系 图2 活动图 6. 如图2所示,活动Gesture和Stream audio可以并发进行。(T) 7. 一个软件系统,如果只有源代码,缺乏其他相应的辅助文档,如缺乏顺序图和类图,则可以利用Rose进行逆向工程得到顺序图和类图,但得到的顺序图和类图会比较简单。(F) 8. CMM描述了五个级别的软件过程成熟度,即初始级、可重复级、已定义、已管理级、优化级。(T) 9. UML由用例视图、物理视图、组件视图、进度视图和配置视图组成。(F) 10. 在设计类图时,可以不用对类图中的每个关联进行命名,但如果需要命名的话,最好用一个“动词”给关联命名。(T) 11. 适配器模式属于创建型模式。(F) 12. 在设计模式中,“效果”只是指“原因和结果”。(T) 13. 设计模式使代码编制不能真正工程化。(F) 14. 设计模式的两大主题是系统复用与系统扩展。(T) 15. Façade(外观)模式不仅可以为方法调用创建更简单的接口,还可以减少客户必须处理 的对象数量。(T) 16. 外观模式,当不能采用生成子类的方法进行扩充时,动态地给一个对象添加一些额外的 功能。(F) 17. Façade模式为子系统中的一组接口提供的界面可能不一致。(F) 18. Façade外观模式只能为方法调用创建更简单的接口,不能减少客户必须处理的对象数量 。(F) 19. 对象适配器模式是合成聚合复用原则的典型应用。(T) 20. Adapter模式使原本由于接口不兼容而不能一起工作的那些类可以一起工作。(T) 21. Façade模式和Adapter模式是相同类型的包装器。(F) 22. Adapter模式不是必须针对某个接口进行设计。(F) 23. 继承本质上是“白盒复用”,对父类的修改,不会影响到子类。(F) 24. 继承是一种通过扩展一个已有对象的实现,从而获得新功能的复用方法。(t) 25. 抽象工厂模式提供了一系列相关或相互依赖对象的接口且必须指定他们具体的类。(F) is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to 26. Abstract Factory(抽象工厂)模式确保系统总能根据当前的情况获得合适的对象。(T) 27. 在Abstract Factory(抽象工厂)模式中,客户对象不需要知道“向谁请求需要的对象”“如何使用这些对象”。(F) 28. Decorator(装饰)模式的意图是为一个对象连接附加的职责。(F) 29. 每个Decorator对象在被装饰的功能之前或之后执行自己的附加功能。(T) 30. Decorator(装饰)模式适用性是表示对象的部分-整体层次结构。(F) 三、填空题 1. 面向对象开发方法一改过去传统的以___(功能分析)___为基础的__(面向过程)__的结构化分析与设计方法,它模拟人们理解和处理客观世界的方式来分析问题,把系统视为一系列__(对象)_的集合,其__(面向对象的设计__又将分析的结果映射到某种面向对象实现工具的结构上,使映射过程有着比较直接的对应关系,使分析者、设计者和编程者都可使用相同的_概念_,从而使面向对象的软件开发能比较自然地模拟客观世界的活动,使问题描述空间与_解空间__在结构上尽可能一致。因此,采用面向对象方法可以更有效地开发大型软件系统。面向对象方法的_封装_、_继承_、__多态_等机制不仅支持软件复用,而且使软件维护工作可靠有效,可实现软件系统的柔性制造,更好地克服_软件危机__。因此,它已成为成熟的广为采用的软件开发方法。 2. 对象是客观实体的抽象表示,是由__描述对象属性的数据__和_对这些数据进行的操作行为__两部分组成。而_类_是对具有相同属性和行为的一组对象的抽象描述。因此,它可作为一种用户自定义类型和创建对象的样板,而按照这种样板所创建的一个个具体对象就是类的__实例__。通过_继承__关系又可形成一种类层次结构。 3. UML中用于描述系统的静态建模的视图称为静态视图,包括_用例图__、 _类图__、_对象图__、__包图__和__构件图_。 4. UML 从不同的视角为系统架构建模,可产生九种视图: _____用例图_____、_____类图______、____对象图______、 _____配置图______、____组件图______、 _ 协作图_____、 ____活动图______、____序列图_______、___状态图________。 5. ____序列图____是用来反映若干个对象之间动态协作关系的一种交互图。它主要反映对象之间已发送消息的先后次序和对象之间的交互过程。_____协作图____是用来描述实现某些服务所涉及的对象及其相互之间的关系(包括消息通信)的动态视图。建模者可以选择_______协作图________来反映对象之间的协作关系;如果需要强调时间和序列,最好选择________序列图_____;如果需要强调上下文相关,最好选择____协作图_____。 6. 适配器模式,分为类的适配器和对象的适配器两种实现。其中类的适配器采用的是继承 关系,而对象适配器采用的是(组合聚合 )关系。 7. Adapter模式有两种类型有 :对象Adapter模式、(类Adapter模式)。 8. UML是一种用来创建(程序模型)的图像语言。 9. ( Adapter适配器 )模式使原本接口不兼容而不能一起工作的类可以一起工作。 10. 适配器模式,分为类的适配器和对象的适配器两种实现。其中类的适配器采用的是(继承 )关系,而对象适配器采用的是组合聚类关系。 11. 在存在继承关系的情况下,方法向超类方向集中,而数据向(子类)方向集中。 12. 在进行设计以应对变化的过程中,应该遵循两条基本策略:找出变化并(封装变化点);is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to 优先使用对象组合,而不是类继承。 13. 封装性好的代码更容易测试,因为它与其他代码没有(耦合)。 14. (抽象工厂)模式提供了一系列相关或相互依赖对象的接口而无需指定他们具体的类。 15. 工厂模式分为简单工厂,工厂方法,( 工厂方法)三种类型。 四. 简答题 1. 简述面向对象软件开发方法的优点。 面向对象开发方法一改过去传统的以功能分析和功能分解为基础的面向过程的结构化分析与设计方法,面向对象开发方法模拟人们理解和处理客观世界的方式来分析问题,把系统视为一系列对象的集合,其面向对象的设计又将分析的结果映射到某种面向对象实现工具的结构上,使映射过程有着比较直接的对应关系,使分析者、设计者和编程者都可使用相同的概念,从而使面向对象的软件开发能比较自然地模拟客观世界的活动,使问题描述空间与解空间在结构上尽可能一致。因此,采用面向对象方法可以更有效地开发大型软件系统。面向对象方法的封装、继承、多态等机制不仅支持软件复用,而且使软件维护工作可靠有效,可实现软件系统的柔性制造,更好地克服软件危机。因此,它已成为成熟的广为采用的软件开发方法。到20世纪末,面向对象软件工程逐渐发展成熟,特别是统一建模语言(UML)标准的形成和广泛使用,使面向对象软件开发方法已成为软件开发的主流技术。 2. 简述面向对象技术的三大机制。 答:(1)封装性(encapsulation) 所谓封装就是把对象的属性和行为结合成一个独立的单位,使外界不能直接访问或修改 这些数据和代码,外界只能通过对象提供的接口函数来改变或获取对象的属性数据,这 就实现了消息隐蔽。 (2)继承性 如果在一个已定义的类上,增加一些特殊属性或操作,可以形成一个新的类,这个类不仅继承了前一个类的全部特征,而且具有新的特性,因此可看作前一个类的特例,是对前一个类的继承。前一个类称为父类,新产生的类叫做子类。通过继承关系可形成一种类层次结构,叫做继承结构。 (3)多态性 在类层次结构的不同类中,可用相同的函数名实现功能不同的函数。 3. 简述OOA模型的层次结构。 答:OOA模型采用五层次结构,它们分别是: (1)对象-类层 划分待开发系统及其环境信息的基本构造单位,标出反映问题域的对象和类,并用符号进行规范的描述,用信息提供者熟悉的术语为对象和类命名。 (2)属性层 定义对象和某些结构中的数据单元,继承结构中所有类的公共属性可放于通用类中。标识对象类必需的属性并放在合适的继承层次上,属性的特殊限制和实例连接关系也应标识出来。 is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to (3)服务层 表示对象的服务或行为,即是要定义类上的操作。 (4)结构层 标识现实世界中对象之间的关系。当一个对象是另一个对象的一部分时,用"整体-部分"关系表示;当一个类属于另一个类时,用类之间继承关系表示。 (5)主题层 可将相关类或对象划分为一个主题。 . 简述OOD模型的总体结构,并画图表示。 4 OOD体系结构的各个部分内容: (1)问题论域部分,在OOA模型的基础上,细化分析结果,设计一组构成底层应用模型的类和对象。 (2)人机交互部分:设计用户界面模型,该用户界面模型中的类和对象提供实现人机交互操作的接口函数。用户界面设计包括 菜单设计、窗口设计、输入/输出界面设计等等。 (3)任务管理部分:建立一些类,用以负责处理操作系统级的并发问题、中断、调度以及其它与特定平台有关的问题。 (4)数据管理部分:提供数据管理系统中存储和检索对象的基本结构,包括对永久性数据的访问和管理。数据管理设计包括: — 数据存放设计:数据存放设计选择数据存放的方式(文件存放、关系数据库表格存放或面向对象的数据库存放)。 — 设计相应的操作。为每个需要存储的对象和类增加用于存储管理的属性和操作,在类和对象的定义中加以描述。 问人任数 题机务据 论交管管 域互理理 部部部部 分分分分类边界class & object layer实例边界 (类及对象层) 实例连接attribute layer (类及对象层)属性 消息 service layer (服务层) 服务 struct layer (结构层)图1.5 OOD模型的总体结构 5. 分析下面的类图,画出新的类图,将原图中的多对多关系转换为1:M(一对多)关系。 subject layer主题(主题层) 答案: is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to 6(信用卡可能处于“开放”和“关闭”状态,其中“开放”状态可以直接进入“关闭”状态,而从“关闭”状态必须提供密码验证才能进入“开放”状态。“开放”状态又包括“透支”和“正常”状态之间的变化,当剩余金额少于零、或者使用额度大于剩余金额、或者结算余额小于零时进入透支状态,反之则为正常状态。画出信用卡的状态图。(6分) 7. 请判断以下类图中的类关系是否合适,并说明理由。 (1)飞机有机翼、机身、驾驶舱 (2)商场里的电器。1台电器可以 是1台洗衣机,也可以不是;1台 电器可以是1台电视机,也可以不 是;1台电器可以是1台空调,也(3)公司的员工很多,包括程序员、分析员、项目经 可以不是; 理„„ is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to (1)飞机有机翼、机身、驾驶舱 应改为“组合” (2)商场里的电器。1台电器可以是1台洗衣机,也可以不是;1台电器可以是1台电视机, 也可以不是;1台电器可以是1台空调,也可以不是; 应该为“泛化” (3)公司的员工很多,包括程序员、分析员、项目经理„„ 应改为“泛化” 8. 假设你从垃圾堆里捡到这样一张小纸片(如下图所示)。 根据现有信息尽可能判断: (1)“小车”类有哪几个操作, (2)“指挥小车UC”类的“执行任务”操作要做哪些工作,(采用伪代码描述) 图 时序图 参考答案: (1)“小车”类有哪几个操作, 返回小车当前位置() 转向和前进() (2)“指挥小车UC”类的“执行任务”操作要做哪些工作,(采用伪代码描述) 移动任务:更新行走断表和目的地() 移动任务:判断现有信息足以让小车行走() 小车:放回小车当前位置() 小车:验证小车尚未到达目的地() 移动:根据但前位置及断表信息计算出速度、角度() is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to 小车:转向和前进() 9. 简述统一建模语言UML的优点。 10. 简述面向对象技术的三大机制。 11. 简述面向对象分析的基本步骤。 12. 简述OOD模型的总体结构,并画图表示。 13. 应用UML进行系统分析和设计所需建立视图有那几种, 14.简述“开—闭”原则的基本思想。请举出一个使用了软件“开—闭”原则的软件设计模式,其中何处体现了“开—闭”原则。 答:“开—闭”原则:软件实体应当对扩展开放,而对修改关闭,“开-闭”原则要求软件系统能够在不需要修改原有类的基础上,通过增加类达到扩展功能的目的。 Abstract factory体现了这个原则,如果想增加一类新的products,只需在product类体系中增加各个products,然后在factory类体系结构中增加一个concrete factory就可以了,而不需要对现有类做任何修改,The Open-closed principle[ocp]在不改动过模块源代码的情况下扩展模块的行为。 软件实体(类模块 函数等)应该是可以扩展的,但是不可以修改的。 15.简述依赖例转原则的基本思想。请举出一个使用了软件依赖原则的软件设计模式,其中何处体现了依赖原则。 答:依赖倒置原则的基本思想是:?高层模块不应该依赖于低层模块,二者都应该依赖于抽象。?抽象不应该依赖于细节,细节应该不依赖于抽象。Tomplate method就体现了这个原则,它定义了一个操作中的算法骨架,而将一些步骤延迟到子类中,template method使得子类不改变一个算法的结构,即可重定义该算法的某些特定步骤。 16.什么是单一职责原则,请举出一个使用了单一职责原则的软件设计模式,其中何处体现了单一职责原则。 答:基本思想:SRP使得一个类或一个模块承担的责任尽可能的少,使尽可能少的因素或动机影响该类或该模块,即增大类或模块的内聚性,减少其耦合度,SRP是所有原则中最简单的之一,也是最难正确运用的之一。 COMMAND模式体现了SRP原则,大多数类都是一组方法和相应的一组变量的结合,而该模式只是封装了一个没有任何变量的函数,它对函数的关注超过了类,将一个请求封装为一个对象,从而可用不同的请求对客户进行参数化。 17.软件复用可采用类的继承方式和类的聚合方式,比较两者的优缺点。 答:聚合:一个对象拥有另一个对象或对另一个对象负责(即一个对象包含另一个对象或是另一个对象的一部分)并且聚合对象和其所有具有相同的生命周期(即所谓的“同生共死”关系)。 聚合复用优点:?容器类仅能通过被包含对象的接口来对其进行访问。?“黑盒”复用,因为被包含对象的内部细节对外是不可见。?包装性好。?实现上的相互依赖性比较小。?每一个类只专注于一项任务。?通过获取指定其他的具有相同类型的对象的使用,可以在运行期间动态地定义(对象的)组合。 聚合的缺点:?导致系统中的对象过多 ?为了能将多个不同的对象作为组合块来使用,必须仔细地对接口进行定义。 类继承:是一种通过扩展(一个已有对象的)实现,从而获得新功能的复用方法。 继承的优点:?容易进行新的实现,因为其大多数可继承而来 ?易于修改或扩展那些被复用的实现。 继承的缺点:?破坏了封装性,因为这会将父类的实现细节暴露给子类 ?“白盒”复用,因为父类的内部细节对于子类而言通常是可见的 ?当父类的实现更改时,子类也不得is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to 不随之更改 ?从父类继承来的实现将不能在运行期间进行改变。 18.画出工厂方法模式的结构图。什么情况下适合使用工厂方发模式, 其中product:为工厂模式所要创建的对象类型定义一个接口。 Concrete product:实现product接口。 Creator:声明工厂方法(factory method)返回值为product的一个对象。 Concrete creator:覆写factory Method(),返回值为concrete product 的一个具体实例。 在下面情况下你可以考虑使用工厂方法模式: 1) 当客户程序不需要知道要使用对象的创建过程。 2) 客户程序使用的对象存在变动的可能,或者根本就不知道使用哪一个具体的对象。 19.画出合成模式(Composite)的结构图。举例说明一个可以应用合成模式的软件设计实例,说明其中各角色的作用。 实例:计算机和立体组合音响这样的设备经常被组装成一部分整体层次结构或者是容器层次结构,例如:底盘可以包含驱动装置和平面板,总线含有多个插件,机柜包括底盘、总线等。这样结构很自然的用composite模式进行模拟。 Equipment类为在部分——整体层次结构中的所有设备定义一个接口。Equipment声明一些操作返回一个设备的属性,例如它的能是消耗和价格。子类为指定的设备实现了这些操作,Equipment还声明了一个Create Iterator 操作,该操作为访问它的零件返回一个Iterator ,这个操作的缺省实现返回一上NullIterator,它在空集上迭代。 Composite Equipment是包含其它设备的基类,它也是Equipment的子类。 is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to 20.简述门面模式(Facade)和中介者模式(Mediator)的基本思想,两者的差异何在, 答:门面模式(facade)又称外观模式。基本思想:为子系统中的一组接口提供一个一致的界面, Facade模式定义了一个高层接口,这个接口使得这一子系统更加容易使用。 “中介者模式”基本思想:Mediator Pattern 中文译为“中介者模式”、“调停者模式”。调停者模式的定义是:用一个调停对象来封装一系列的对象交互。调停者使各对象不需要显式地相互引用,从而使其耦合松散,而且可以独立地改变它们之间的交互。简单点来说,将原来两个直接引用或者依赖的对象拆开,在中间加入一个“调停”对象,使得两头的对象分别和“调停”对象引用或者依赖。 两者的差异: 从目的上看,调停者模式与门面模式有些相似。 但是门面模式是介于客户程序与子系统之间的,而调停者模式是介于子系统与子系统之间的。这也注定了它们有很大的区别:门面模式是将原有的复杂逻辑提取到一个统一的接口,简化客户对逻辑的使用。它是被客户所感知的,而原有的复杂逻辑则被隐藏了起来。而调停者模式的加入并没有改变客户原有的使用习惯,它是隐藏在原有逻辑后面的,使得代码逻辑更加清晰可用。 21.简述观察者模式的基本思想,如何实现当目标对象发生变化时多个观察者对象的同步更新,画出他们之间的协作图。 (1)Observer(观察者)基本思想:对象间的一种一对多的依赖关系。当一个对象的状态发生变化时,所有依赖于它的对象都得到通知并自动更新。 (2)协作:当Concrete Subject发生任何可能导到其参观者与其本身状态不一致的改变时,它将通知它的各个观察者。在得到一个具体的目标改变通知后,Concrete Object对象可向目标对象查询信息,Concrete Object使用这个些信息以使它的状态与目标对象的状态一致。 (3)协作图: 22.举一适合使用State模式的例子。与不使用该模式相比,有哪些优点, 举例:抽象状态类定义了一个抽象方法“写程序” is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to 与不使用该模式相比优点: State模式将特定的状态相关的行为封装在一个类中,由于所有状态相关的代码都存在于某个concrete state中,所以通过定义新的子类可以很容易的增加新的状态和转换。 23.有哪些模式的使用可以使得类的复用性增强,说明你的理由。 策略模式(strategy) 属于对象行为型模式,主要定义一系列的算法,把这些算法一个个封装成拥有共同接口的单独的类,并使他们之间互换,客户端调用他们的时候互不影响。算法使用和算法分离,即将变化的具体算法封装起来,降低了代码的耦合度,算法提取起来,使算法得到重用。 中介者模式(mediator) 用一个调停对象来封装一系列的对象交互。调停者使各对象不需要显式地相互引用,从而使其耦合松散,而且可以独立地改变它们之间的交互。即,将原来的两个直接引用或者依赖的对象拆开,在中间加入一个“调停”对象,使得两头的对象分别和“调停”对象引用或者依赖。提高了原有系统的可读性,将原有系统的多对多转化为一对多,提高了代码的可复用性。 适配器(Adapter)模式 是的原本由于接口不兼容而不能再一起的那些类可以一起工作。如画图程序中,已实现绘制点,直线等功能。为了让客户程序在使用的时候不用关心不同定义,定义个抽象类规范接口,当去实现绘图时,发现系统其它地方已有制图实现,但是系统已有的方法与抽象类中规定方法不一样,这时候用适配器模式可以解决这问题。适配器模式是为了面向接口编程中更好的复用。 24.比较Adapter和Proxy模式使用上的异同之处。 适配器模式(Adapter):将一个类的接口转换成客户希望的另外一个接口。Adapter 模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作。 代理模式有两个英文名字:Proxy Pattern 和 Surrogate Pattern。代理模式:为其他对象提供一种代理以控制对这个对象的访问。说白了就是,在一些情况下客户不想或者不能直接引用一个对象,而代理对象可以在客户和目标对象之间起到中介作用,去掉客户不能看到的内容和服务或者增添客户需要的额外服务。 两者的主要区别在于代理模式应用的情况是不改变接口命名的,而且是对已有接口功能的一种控制;而适配器模式则强调接口转换。 25.说明Observer模式的基本实现方式。如果不用该模式,要达到同样的效果,你会如何做, 观察者模式在关于目标角色、观察者角色通信的具体实现中,有两个版本。 一种情况便是目标角色在发生变化后,仅仅告诉观察者角色“我变化了”;观察者角色is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to 如果想要知道具体的变化细节,则就要自己从目标角色的接口中得到。这种模式被很形象的称为:拉模式——就是说变化的信息是观察者角色主动从目标角色中“拉”出来的。 还有一种方法,那就是我目标角色“服务一条龙”,通知你发生变化的同时,通过一个参数将变化的细节传递到观察者角色中去。这就是“推模式”——管你要不要,先给你啦。 这两种模式的使用,取决于系统设计时的需要。如果目标角色比较复杂,并且观察者角色进行更新时必须得到一些具体变化的信息,则“推模式”比较合适。如果目标角色比较简单,则“拉模式”就很合适。 如果不使用该模式,可采用策略模式,将不同的情况作为子类封装在一个类中,模拟observer模式中目标角色的不同状态,当外部状态发生变化时,可以选择不同的strategy1、strategy2…改变观察者角色,从而达到与观察者模式同样的效果。 26.请列举一个使用装饰模式的例子。画出你的例子的类图结构。 JUnit 中的装饰模式:在 JUnit 中,TestCase 是一个很重要的类,允许对其进行功能扩展。 在 junit.extensions 包中,TestDecorator、RepeatedTest 便是对 TestCase 的装饰模式扩展。下面我们将它们和上面的角色对号入座。 27.列举两个可以使我们在程序中不必使用if…else结构的软件设计模式。使用软件设计模式是如何做到这一点的, 策略模式(strategy)和状态模式(state) 策略模式是将不同算法(处理方法)封装到stategy类中,状态模式是将不同状态封装到state类中。二者都是通过,类中的子类,实现不同情况的调用,从而有效的替换充满在程序中的 if else 语句。 28.你认为在Linux平台上直接运行WIN32程序有可能吗,如认为不可能请说明理由;如认为可能应如何实现这一目标, (1)两个OS内部实现有很大差别,甚至连路径的分隔符都不一样,一个WIN32程序无论如何到了最后也要调用Window api,而这些api在linux上根本没有实现(2)例如:就用户界面来说,有些windows的控件,在Linux上根本连对应的具有类似功能的控件都没有怎么执行,如果再涉及进程,线程就更复杂了,差距也更大,如果想用一个win32程序在linux上执行,必须有一个间接层来缓和二者差距,然后要求WIN32程序只能调用这个间接层里面的库函数 29. Java是一个跨平台的软件语言。为了实现跨平台,你认为采用哪种软件模式来实现跨平台部分更合理,说明你的理由。 答:abstract factory实现跨平台比较合适。用abstract factory提供一个高层接口,来建造每个所需的Product,当然具体的实现要用Concrete factory来实现,然后让每个os对应一个Concrete factory,这样当其它的Java类库需要平台支持时,只需调用abstract is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to factory的相应函数即可,而无需关系它所在是什么平台。 例如:用户界面awt这个类体系,它是跨平台的,它本身不能有绘制图形界面的代码,因为这涉及具体的平台。所以它肯定要调用一个抽象工厂模式类的相应函数,具体实现就由concrete factory来负责。 Bridge模式可以分离接口及其实现部分,使接口部分和实现部分可以独立变化,同时可以对客户隐藏实现细节,实现bridge实现跨平台部分就有可能对不同的平台编写不同的具体实现,而同时又保持接口部分java语言可以独立变化。 30. 在一个国际电子零售系统中,需要考虑为不同的国家的消费者的定单计算税费问题,请 用模式的方法考虑如何解决该问题。画出该模式的类图。 通过策略Strategy模式,可以将这些规则封装在一个抽象类中,然后派生出一系列的具体类 。通过从一个抽象派生类执行算法的所有不同方式,主模块就无需再操心实际使用的是哪一 个,这样能够允许发生新的变化。 五. 试用UML对教学管理系统及相关的数据库系统进行分析和设计。学生选课系统一般包括(1)选课管理功能;(2) 成绩管理功能。试完成下列工作: (1)建立系统静态结构模型—画出系统用例图和类图;(10分) 查询学生成绩 (2) 建立系统动态结构模型—画出系统序列图和协作图;(10分) (3)建立关系数据库逻辑模型。(10分) (1) 系统用例图如下 查询课程成绩查询课程信息老师老师 学生学生选课注册 学生成绩管理管理学生信息 管理老师信息管理员管理员管理课程信息 成绩统计(b)成绩管理的用例图(a)选课管理的用例图管理开设课程 对象类图如下: 1..*0..*0..*1..* 教师课程学生编号编号课程名姓名姓名描述开设课程选修课程地址地址学时课程名学生名电话电话授课日期课程名加入课程()授课时间学期地点 增加 记录 混凝土 养护记录下载土方回填监理旁站记录免费下载集备记录下载集备记录下载集备记录下载 ()指定老师()(a)选课对象类图选课统计()学生满否()学生成绩登记课程名学生名开设课程授课日期学期 授课时间课程名 地点成绩(b)成绩管理对象类图指定老师()加入成绩()成绩统计学生满否()打印()学期 课程名 成绩 按课程统计() 按学生统计() 打印()is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to (2)把需要持久存储的数据实体类及其联系,映射成为如下关系数据库表: 学生(学生号、姓名、出生日期、性别、籍贯、地址、电话、入学时间、专业、班级备注) 教师(教师号、姓名、出生日期、性别、籍贯、地址、电话、职称、专长、备注) 课程(课程号、课程名、描述、学分、学时、性质、备注) 开设课程(课程号、学期、授课日期、授课时间、地点、选修人数、备注) is an effective shortcut to scientific and technological innovation. To active exploration "research" joint innovation of path, through joint development, and technology cooperation, variety form, will University Hospital by of hi-tech results in I County for into, formed reality productivity; to relies on technology cooperation led economic structure upgrade, around I County industry layout, active docking University, and research hospital by, hi-tech research results, with external think tank, speed up transformation upgrade chemical, and mechanical, traditional industry, speed up life paper, and food, and textile, and mechanical tool, new products development, and technology development, and New process innovation, promoted related industry by single products to diversified extends, by General products to high-end products extends, promoted industry expanded capacity, and upgrade grade, nine Xin day of in cosmetics industry has near ten years of accumulation, and Nanjing Institute cooperation for industry upgrade, both joint development of "Chinese God SOAP", take "micro-business" mode for letter sale, products innovation and sales mode innovation are brings has good of benefits; to
本文档为【UML考试试题 - 副本】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_686908
暂无简介~
格式:doc
大小:319KB
软件:Word
页数:47
分类:
上传时间:2017-10-16
浏览量:37