类图包含菜单和接口吗?

huangapple go评论52阅读模式
英文:

Does analysis class diagram contain a menu and interface?

问题

我正在为与教师和学生相关的应用程序实现一个类图,作为一项作业。一个学生可以有很多老师。

我将在编码中实现一个菜单。我应该将菜单和接口添加为类吗?
如果是的话,我应该如何将它们连接起来?
菜单和接口可以包含什么?
我可以说:菜单有设置和教师页面,其中包含了所有教师的个人资料吗?

英文:

I am implementing a class diagram for an application related to teachers and students as an assignment. A student can have many teachers.

I will implement a menu in coding. Should I add menu and interface as classes?
If yes, how should I link all these?
What can menu and interface contain?
Could I say: menu has settings and teachers page, which has all teachers profiles in it?

答案1

得分: 1

一个只包括应用程序领域中的类(例如教师、学生、课程等),而没有包含任何应用程序内部(例如与用户界面相关的类)的类图被称为“领域模型”。其目的不是记录应用程序中使用的所有可能类,而是侧重于领域知识,与应用程序的结构或实现方式无关。这样的领域模型将在创建移动应用程序、基于文本的终端应用程序或语音控制应用程序时保持不变。

另一方面,您可能也想提供关于应用程序设计的见解,例如使用菜单类、数据库连接器等等... 这也是可以的。由您决定类图的目的以及您想要显示的内容。唯一需要避免的是拥有一个包含所有内容的庞大图表,因为这样会使解释任何内容变得过于复杂。最好选择几个类图,侧重于设计的不同方面。

如果您想在同一个图表中结合具有非常不同目的的类,例如UI类、领域类和业务逻辑,可以使用“实体-边界-控制”(Entity-Boundary-Control)的1 架构,以帮助理解哪个类实现了哪个技术目的。

编辑:分析图

您的标题和评论特指分析图。分析图并未在UML标准中明确定义,而是取决于方法论的选择:

  • 一些方法将分析模型视为独立存在的,仅包含问题领域的元素,而设计图则显示解决方案领域。
  • 但也有一些方法将分析模型视为进化成设计模型的第一阶段。
  • 统一过程将分析类定义为实体边界控制,因为它们与用例直接相关,用例对应了需求。它们不会包含诸如菜单之类的细节(这将属于边界类的细化部分)。但它们将包含不仅仅是领域模型的实体。 1: https://en.m.wikipedia.org/wiki/Entity-control-boundary
英文:

A class diagram with only classes belonging to the domain of application (e.g teachers, students, classes, ..) without any of the app's internals (e.g. UI related classes) is called a "domain model". Its goal is not to document all possible classes used in your app, but to focus on the domain knowledge, independently of how the app is structured or implemented. Such domain model would stay the same if you create a mobile app, a text based terminal application, or a voice controlled app.

On the other side you may also want to give insights on how your app is designed, i.e. using menu classes, database connectors, etc... This is also fine. It's up to you to decide what is the purpose of your class diagram and what you want to show with it. The only thing that you should avoid is to have one huge diagram with everything, because it'll be too complex to explain anything. Better go with several class diagrams focusing on different aspects of your design.

One thing that may help if you want to combine in the same diagram classes with very different purpose, i.e UI classes, domain classes and business logic, is the Entity-Boundary-Control stereotypes, to help to understand what class fulfills which technical purpose.

Edit: Analysis diagrams

Your title and your comments refer specifically to analysis diagrams. Analysis diagrams are not defined by the UML standard and depend on methodological choice:

  • Some methods see analysis models as self-standing with only elements of the problem space, whereas design diagrams show the solution space.

  • But some other methods see analysis models just a first stage that evolves into a design model.

  • The Unified Process defines analysis classes to be Entity Boundary Controls, because they are directly related to Use-Cases, which model requirements. They would not contain details such as menus (which will belong to refinements of the boundary classes). But they would contain more than only entities of the domain model.

huangapple
  • 本文由 发表于 2023年2月19日 22:25:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/75500805.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定