简体   繁体   English

UML 图 + Android 类

[英]UML diagrams + Android classes

I've been developing an Android app for a while but I didn't start with any particular diagram.我一直在开发一个 Android 应用程序,但我没有从任何特定的图表开始。 And now comes the time to do some real diagrams but I don't know how.现在是时候做一些真正的图表了,但我不知道怎么做。 Not because I'm not familiar with UML but because of Android and it's components.不是因为我不熟悉 UML,而是因为 Android 及其组件。

For example, my app requires that the user needs to be logged in in order to see a menu.例如,我的应用程序要求用户需要登录才能看到菜单。 From there the user can choose the options he wants.用户可以从那里选择他想要的选项。 The user can also do his registration.用户也可以进行注册。

Although this might be a silly and simple example...The point is...I didn't use any class named "Person" with getters and setters;虽然这可能是一个愚蠢而简单的例子......重点是......我没有使用任何名为“Person”的类和 getter 和 setter; or any class named "Request" with getters and setters and other methods.或任何名为“Request”的类,带有 getter 和 setter 以及其他方法。 My app use classes like "Login.class", "SignIn.class", "MenuActivity.class", "HistoryActivity.class".我的应用程序使用“Login.class”、“SignIn.class”、“MenuActivity.class”、“HistoryActivity.class”等类。

My question is...how do I use UML for an Android app?我的问题是...如何将 UML 用于 Android 应用程序? I mean I can't have a conceptual model diagram that says "Person"-----"Request", right?我的意思是我不能有一个概念模型图,上面写着“人”-----“请求”,对吧?

Thanks in advance.提前致谢。

I think you are confused with different types of UML diagram types,我认为您对不同类型的 UML 图类型感到困惑,

There are,有,

Structural UML diagrams结构 UML 图

  1. Class diagram类图
  2. Package diagram封装图
  3. Object diagram对象图
  4. Component diagram组件图
  5. Composite structure diagram复合结构图
  6. Deployment diagram部署图

Behavioral UML diagrams行为 UML 图

  1. Activity diagram活动图
  2. Sequence diagram时序图
  3. Use case diagram用例图
  4. State diagram状态图
  5. Communication diagram通讯图
  6. Interaction overview diagram交互概览图
  7. Timing diagram时序图

And more, I think you are talking about Class diagram.而且,我认为您在谈论类图。 Since class diagrams are technical and are targeted for the development team, It is totally fine to have all these Login.class, SignIn.class, MenuActivity.class, HistoryActivity.class in your class diagram.由于类图是技术性的并且是针对开发团队的,因此在您的类图中包含所有这些 Login.class、SignIn.class、MenuActivity.class、HistoryActivity.class 是完全没问题的。

But you can use conceptual things like Person, Request ect in your other UML diagrams (eg Use Case).但是您可以在其他 UML 图表(例如用例)中使用诸如人员、请求等概念性事物。 because in these diagram this is targeted for many users not just developers, So using MenuActivity does not make any sense.因为在这些图中,这是针对许多用户而不仅仅是开发人员,所以使用 MenuActivity 没有任何意义。 Using conceptual entities is the way to go here.使用概念实体是这里的方法。

Good luck祝你好运

Your example suggests that you're trying to capture a some sort of use case.您的示例表明您正在尝试捕获某种用例。 In this case you may need an activity diagram to demostrate the higher level view or a communication diagram if you're more concerned with more detailed one.在这种情况下,如果您更关心更详细的视图,您可能需要一个活动图来演示更高级别的视图或通信图

UML isn't concerned with programming languages, platforms and so on. UML 与编程语言、平台等无关。 Its main purpose is to provide a notation which can be used to communicate ideas without necessarily getting into too much details.它的主要目的是提供一种符号,可用于交流想法,而不必涉及太多细节。 So the first thing you need to consider is why you need diagrams in the first place and what you want to communicate with them.因此,您首先需要考虑的是为什么首先需要图表以及您想与它们交流什么 Given these questions answered it will become clear what kind of diagrams you need.鉴于回答了这些问题,您将清楚您需要什么样的图表。

There is such thing as "4+1 model" which aims to separate the software model into several views.有“4+1 模型”之类的东西,旨在将软件模型分成几个视图。 These views show different aspects of the software and concerned with different levels of detail.这些视图显示了软件的不同方面,并涉及不同级别的细节。 In Unified Process, for example, it is adviced to model from "top" to "bottom" of the solution, from high-level overview of use cases and main features to the actual implementation details.例如,在统一流程中,建议从解决方案的“顶部”到“底部”建模,从用例和主要特性的高级概述到实际实现细节。 UML supports that providing different types of diagrams as well. UML 也支持提供不同类型的图表。

So if I understood I can use those conceptual terms (Person, Request) even if they aren't any classes with those names at all...they are used as an example right?因此,如果我理解我可以使用这些概念术语(人、请求),即使它们根本不是具有这些名称的任何类......它们被用作示例,对吗?

You indeed can, but not in diagrams with low-level features like Activities.您确实可以,但不能在具有活动等低级功能的图表中使用。 You may want to build a domain class diagram that will include Persons and other entities relevant to your application, but won't be really represented in code.您可能想要构建一个域类图,其中将包含与您的应用程序相关的人员和其他实体,但不会真正在代码中表示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM