1. 程式人生 > >5.2 領域模型建模指導

5.2 領域模型建模指導

而不是 pic clas 重復 return tex sep 可能 esc

? 敏捷建模Agile Modeling – 類圖的草圖

? – 是否利用工具建模

  ? 創建領域模型的目的是快速地理解關鍵的概念,並在涉眾之間交流

    the purpose of creating a domain model is to quickly understand and communicate of the key concepts   ? 完美不是目標 Perfection is not the goal

  ? 是否利用工具,酌情 For tool, may or not

? 報告性的、或者總結性的對象,是否定義為概念 Report Objects / summary object : to be an concept

  ? E.g. Include ‘Receipt‘ in the Model?

  ? In general, showing a report of other information in a domain model is not useful since all its information is    derived or duplicated from other sources

    ? This is a reason to exclude it

  ? On the other hand, it has a special role in terms of the business rules:

  ? It usually confers the right to the bearer of the (paper) receipt to return bought items (顧客退貨的憑據)

  ? This is a reason to show it in the model Guideline
? 構建領域模型,類似地圖制作

  ? 使用現有的名詞 Use the existing names in the territory

    ? For example, if developing a model for a library, name the customer a "Borrower" or "Patron” the terms used by the library staff

    ? 剔除掉無關的、或者超出範圍的一些特征 Exclude irrelevant or out-of-scope features

      ? 例如,在課程的案例“大富翁遊戲 Monopoly”,第一次叠代中,有些概念,如各類卡 片 cards (“免進 監獄Get out of Jail Free” card) 暫不考慮,所以就不顯示“Card”

      ? 不需要額外增加沒必要的概念!Do not add things that are not there
? 如何對非真實世界的概念建模

  ? 有些軟件系統著眼於解決領域問題,但是在現實中或者業務中很少有概念與之對應

    ? 例如,電信領域“交換機”相關的概念

      ? 消息、連接、端口、對話、路由、協議 Message, Connection, Port, Dialog, Route, Protocol

? 經常容易出錯的選擇:Attributes vs. Classes ,原則:

  ? 如果認為某概念類X不是現實世界中的數字或文本,那麽X可能是概念類而不是屬性

    ? 如果符合下列條件,可能是一個類

      ? 有很多元素構成 Composed of multiple elements (has attributes-states)

      ? 有一些操作、行為 There are operations (behavior)

      ? 有數量單位 Has units of quantity

    ? 例如

      ? Store ?

      ? consider the domain of airline reservations. Should destination be an attribute of Flight, or a separate conceptual class Airport ?
? 對一些描述‘Description’性質的概念建模

  ? A description class contains information that describes something else

  ? For example, a ProductDescription that records the price, picture, vendor, and text description of an Item

  ? 為什麽單獨作為概念類

    ? Where to find product information when they were sold out 商品賣光了之後, 到哪裏去找商品的信息 呢

    ? Each Product of same type has its product description information, is there any problem 如果每一個 同類產品的信息都含有產品描述,有什麽問題嗎

      ? Repeat, redundant, inconsistency, and a waste of storage space 重復、累贅,不 一致、浪費存 儲空間
? 定義成“描述”類的原則

  ? 如果描述內容獨立於對應 的事物 ,如產品、產品 描述

  ? 如果刪除對象的同時刪除 了描述,而該描述還需要 繼續維護

  ? 為了減少重復或者更清晰

5.2 領域模型建模指導