用例图中如何区分include和extend?

本文通过直观图表解析需求分析中包括include和extend两种关系的区别,帮助理解复杂需求之间的联系。主要包括如何判断使用include还是extend来描述用例之间的关系。

需求分析的时候,复杂的需求总是让人很难搞清用例之前的关系,generalize关系比较容易搞清,最易混淆的就是include和extend了。网上好多都对此讲解的不明白,甚至出错。本文告诉你如何判断到底是用include还是extend?

看完下图就明白了。本图是用visio画的,所以《uses》其实是代表《include》(微软总是不服从标准)。


1. 《include》意为包含,也就是use,两个用例之间的关系,执行一个用例就要使用并执行另一个用例。比如想要“预约”就要“验证ID”。要“借书”就要“验证ID”。

2. 《extend》意为扩展,“还书”的时候可能会缴纳罚款(书本过期),但不一定所有“还书”必“缴纳罚款”。在满足一定的扩展条件后(过期)则要执行另一个用例。

可以看出来,《include》的用例大多情况下都是从几个用例中提取出来的公共部分。而《extend》是在执行一个用例时,满足一定extend points后会执行其他用例。

欢迎大家讨论!

### UML Use Case Diagram Include vs Extend Difference and Usage Scenario In the context of Unified Modeling Language (UML), both `<<include>>` and `<<extend>>` relationships are used to show dependencies between use cases but serve different purposes. #### Understanding <<include>> The `<<include>>` relationship indicates that one use case includes or contains another. This means part of a use case's behavior can be factored out into a separate, reusable piece represented by an included use case. The including use case cannot function without this inclusion; it relies on the functionality provided by the included use case[^1]. For instance, consider a banking system where logging in is necessary before performing any transactions like withdrawing money or transferring funds. Here, "Log In" would be an included use case because these actions depend upon successful authentication through login. ```plantuml @startuml actor User User --> (Withdraw Money) (User) .> (Log In) : <<include>> @enduml ``` #### Exploring <<extend>> Conversely, the `<<extend>>` relation signifies optional extensions to base behaviors defined within primary use cases. An extending use case adds new functionalities under certain conditions while not altering core operations when those criteria aren't met[^2]. Imagine again our bank application scenario extended further so users could receive notifications about their account balance after completing withdrawals only if they opted-in previously for such alerts. Thus, "Receive Notification" extends "Withdraw Money". ```plantuml @startuml actor User User --> (Withdraw Money) (Withdraw Money) ..> (Receive Notification) : <<extend>> @enduml ``` By distinguishing between mandatory (`<<include>>`) versus conditional additions (`<<extend>>`), developers gain clearer insights into how systems should operate logically during design phases involving analysis modeling and design tasks conducted possibly concurrently with each other[^3]. --related questions-- 1. How does incorporating `<<include>>` impact overall software architecture? 2. Can multiple use cases simultaneously extend a single main use case? What implications arise from doing so? 3. Are there scenarios better suited specifically towards using either `<<include>>` over `<<extend>>`, or vice versa? 4. When designing complex applications integrating various business processes, what considerations come into play regarding real-life knowledge management solutions' integration capabilities mentioned earlier[^4]?
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值