You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

UML用例图设计疑问:登录功能的关联方式如何选择

How to Model Login in UML Use Cases for Your Authenticated App

Great question—this is such a common sticking point when modeling authentication flows, so let’s break it down clearly with UML best practices.

First off, you absolutely should draw a direct association between your User actor and the Login use case. Why? Because users can intentionally initiate the login process on their own (think: opening your app and clicking "Log In" to gain access). This is a valid, standalone action a user can take, so it deserves its own direct link.

Second: Use include Relationships for All Core Use Cases

Now, for your core features (the ones that require a logged-in state)—like "View Personal Dashboard", "Submit a Request", or whatever your app’s main functions are—you’ll want to use the include relationship to tie them to Login.

Here’s the reasoning:

  • The include relationship in UML means the core use case cannot complete successfully without first executing the included use case. So if a user tries to access a core feature while unauthenticated, the system will automatically trigger the Login flow first.
  • If the user is already logged in (has a valid access token), the Login step is just skipped—you can document this logic in the use case’s description, but the diagram will still clearly show the dependency.

A Quick Note on Preconditions vs. include

You might be thinking, "Could I just add a precondition like 'User has a valid access token' to each core use case instead?" That’s technically valid, but the include relationship makes the dependency visual at a glance. For stakeholders who might not dig into every use case’s written details, the diagram will immediately show that login is required for all core features.

Final Quick Structure Recap

  • Your User actor connects directly to the Login use case (for intentional login actions)
  • Your User actor connects to each core use case
  • Each core use case has an include arrow pointing to the Login use case (to enforce the authentication requirement)

This setup correctly frames login as a supporting (not core) use case while making it crystal clear that access to your app’s main functionality depends on it.

内容的提问来源于stack exchange,提问作者Jones

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 07:07:10