第7讲. 模式与对象设计.ppt

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
* * * * 作业 针对系统消息构造顺序图 设计类图 写一个文档,说明GRASP模式如何在你的设计中运用的 * * 寻找ProductSpecification SalesLineItem 要与匹配进入的itemID 的ProductSpecification 建立关联 ?这意味着基于一个itemID 匹配,必须返回一个 ProductSpecification 谁必须负责“基于一个itemID 匹配,必须返回一个 ProductSpecification ”? Creation模式? Controller模式? * * 专家模式 依据领域模型,ProductCatalog 逻辑上包含所有的ProductSpecifications 我们可以设计一个ProductCatalog 对象负责该责任 谁应该发送 getSpecification 消息给ProductCatalog 来请求ProductSpecification呢 可以假设在启动用例的初始化过程中,创建长生命周期的Register 和ProductCatalog 实例,并且Register 对象与ProductCatalog 对象之间存在永久关联,这样,可以让Register 给ProductCatalog 发送getProductDescription消息. 可见性: 一个对象“看见”或引用另一个对象的能力 * * 从数据库中检索ProductSpecification 不可能把所有 ProductSpecification 全部放在内存中 但是可以把它们放在关系数据库或者对象数据库中,然后按需检索 为了简单起见,从数据库中检索的问题稍后讨论 * * 2: makeLineItem(spec, qty) enterItem(id, qty) 1: spec := getSpecification(id) 2.1: create(spec, qty) 1.1: spec := find(id) :Register :Sale :Product Catalog sl: SalesLineItem SalesLineItem :SalesLineItem :Product Specification 2.2: add(sl) by Expert by Controller This find message is to the Map object (the multiobject), not to a ProductSpecification. CAUTION: This is a multiobject collection (such as a Map), not a ProductSpecification. It may contain many ProductSpecifications. CAUTION: This is a multiobject collection (such as a List), not a SalesLineItem. It may contain many SalesLineItems. by Creator add the newly created SalesLineItem instance to the multiobject (e.g., List) * * 4.3.3. 对象设计: endSale 当收银员按下表示商品条目输入完毕的按钮后,将会产生endSale 系统操作 Contract CO3: endSale Operation: endSale() Cross References: Use Cases: Process Sale Preconditions: There is an underway sale. Postconditions: -Sale.isComplete became true (attribute modification) * * 选择控制类 继续使用Register 作为控制器 * * 设置Sale.isComplete 属性 除非是控制器或者创建问题,否则信息专家模式应该是我们首先考虑的模式 谁应该负责将Sale的属性 isComplete 设置为true呢? 根据信息专家模式, 应该是由Sale 本身完成. :Register endSale() s :Sale 1: becomeComplete() by Expert by Controller * * UML 表示约束,注释和算法的方法 有些时候在UML中,我们希望用文字来描述方法中的算法,或者指定某些约束 约束: semantically meaningfully information attac

文档评论(0)

xina171127 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档