1 / 27

Chapter 18

Chapter 18. 使用 GRASP 的对象设计示例. 大纲. 用例实现 应用 GRASP 为类分配职责 应用 UML 阐述和思考对象的设计. 什么是用例实现. 用例如何在设计模型中实现. 系统事件. 用例实现. 领域模型. 如何实现 makeNewSale. 契约(后置条件) 创建了 Sale 的实例 s s 被关联到 Register s 的属性被初始化 选择控制器 类型 1 还是类型 2 ?. 如何实现 makeNewSale. 如何实现 enterItem. 如何实现 enterItem. 契约(后置条件)

Download Presentation

Chapter 18

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 18 使用GRASP的对象设计示例

  2. 大纲 • 用例实现 • 应用GRASP为类分配职责 • 应用UML阐述和思考对象的设计

  3. 什么是用例实现 • 用例如何在设计模型中实现

  4. 系统事件

  5. 用例实现

  6. 领域模型

  7. 如何实现makeNewSale • 契约(后置条件) • 创建了Sale的实例s • s被关联到Register • s的属性被初始化 • 选择控制器 • 类型1还是类型2?

  8. 如何实现makeNewSale

  9. 如何实现enterItem

  10. 如何实现enterItem • 契约(后置条件) • 创建了SalesLineItem的实例sli • sli被关联到当前的Sale • sli.quantity赋值为quantity • 基于itemID的匹配,sli被关联到ProductDescription • 控制器类的选择

  11. 如何实现enterItem

  12. 用代码表示对象的协作? Register::enterItem(id, qty){ ProductDescription desc = ProductCatelog.getInstance().get(id); currentSale.makeLineItem(desc,qty); }

  13. 修改后的设计类图

  14. 如何实现endSale • 契约(后置条件) • Sale.isComplete被设为真 • 控制器的选择

  15. 计算销售总额

  16. 如何实现makePayment • 契约(后置条件) • 创建了Payment的实例p • p.amountTendered被赋值为amount • p被关联到当前的Sale • 当前的Sale被关联到Store

  17. 如何实现makePayment

  18. 记录Sale

  19. 记录Sale

  20. 计算余额

  21. 最终的DCD

  22. 比较 SaleTable RegisterTable

  23. 比较 Service_3 Service_n

  24. 如何将UI层连接到业务层 • 获取业务对象的方法 • 从应用的入口方法(如main方法)创建业务层的 “根”对象,并传递给UI。 • 从工厂对象取得业务对象。

  25. 启动应用(代码) public class Main { public static void main(String[] args) { Store store = new Store(); Register register = store.getRegister(); ProcessSaleJFrame frame = new ProcessSampleJFrame(register); ....... } }

  26. 启动应用(交互图)

  27. UI层获取合计额的设计

More Related