其他分享
首页 > 其他分享> > 6.4 操作契约 Operation Contracts

6.4 操作契约 Operation Contracts

作者:互联网

4、操作契约 Operation Contracts

   “用例描述”的补充

   强调: 用例中重要的动作,其开始与结束是需要一些约束

4.5 操作契约的后置条件

   定义Definition

     后置条件描述了领域对象状态的变化 describe changes in the state of objects in the domain model

     状态变化包括

       是否创建、删除了对象?instances created / deleted

       对象间的关系是否发生变化?associations formed or broken

       有对象的属性变化了吗?and attributes changed

   为什么要后置条件? Why post-condition

     也不是始终都需要的 they aren't always necessary

       如果开发人员很容易明白该如何去做,就不用写操作契约了

        If developers can comfortably understand what to do without them, then avoid writing contracts      操作契约比较细节地、精确地定义了一个操作应该承担的职责

     契约,是面向对象分析过程中非常有用的工具

       把问题说清楚、无歧义

       先不考虑设计,集中于分析 what must happen 而不是how it is to be accomplished
4.6 创建后置条件

   建议 Apply the following advice to create contracts

     Identify system operations from the SSDs .

     For system operations that are complex and perhaps subtle in their results,

        or which are not clear in the use case, build a contract

     To describe the postconditions, use the following categories:

       instance creation and deletion

       attribute modification

       associations formed and broken

   常见错误

     描述契约

       (better) A SalesLineItem was created

       (worse) A SalesLineItem is created; or Create a SalesLineItem

     忘记对象之间的关系发生了变化

       The SalesLineItem was associated with the Sale (association formed)
4.7 后置条件 & 领域模型

   后置条件体现在领域模型的对象 postconditions are expressed in the context of the Domain Model objects      What instances can be created?

       those from the Domain Model

     What associations can be formed?

       those in the Domain Model

     and so on

   在定义契约的过程中,经常触发对领域模型的修改

     记录新的概念类、属性 ?

     领域模型是否有新的关系 ?
4.8 对领域模型的修改

标签:associations,后置,created,Contracts,formed,SalesLineItem,6.4,契约,Operation
来源: https://www.cnblogs.com/mayZhou/p/10548440.html