Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UML class diagram: how to model relations about calling a method or starting an activity or service

I'm creating my first Android app. I have avoided to label associations with user or system interactions (e.g. I have labeled starts instead startsWhenClick; I have labeled starts instead startsWhenDetection). However, after reading this, I'm considering to change the starts associations by << create >> dependencies. I'm confused!

The app works as follow. When the app starts, LauncherActivity will call the methods of BaseActivity to start the activity marked in SettingsActivity (it could be SettingsActivity too). LauncherActivity will launch both services too. This is the diagram:

full class diagram

Note: this question is the continuation of this question.

like image 615
chelder Avatar asked Feb 10 '14 22:02

chelder


People also ask

How do you show relationships in UML class diagram?

To show a composition relationship in a UML diagram, use a directional line connecting the two classes, with a filled diamond shape adjacent to the container class and the directional arrow to the contained class.

How do you represent a method in class diagram?

On a class diagram, public messages (and any public attributes) are shown with a plus sign ( ) in front of them. Methods also have parentheses after them, indicating that data may be passed as parameters along with the message. The message parameters, as well as the type of data, may be included on the class diagram.

What are the 3 relationships that can be shown in UML diagram define them?

Since it is termed as a link, it demonstrates how things are interrelated to each other at the time of system execution. It constitutes four types of relationships, i.e., dependency, association, generalization, and realization.

How are UML classes represented in a class diagram?

In UML, a class represents an object or a set of objects that share a common structure and behavior. They're represented by a rectangle that includes rows of the class name, its attributes, and its operations.


1 Answers

It is not a real class diagram.

  • Starts and calls belong to notes, or if you are sure you want to see them on connections, do stereotypes on DEPENDENCIES, not associations.
  • You still have no associations, and they are the main part of the class diagram. Look here about how to work with them. You should create associations first. Only after that show the dependencies. (It is not a common rule, but you should do so for better understanding)
  • As for the actions you are trying to show here, do State Machine diagram for them, then probably Sequence or Activity diagram. Don't use Interaction overview diagram, you'll get lost in it.

But stop putting so many actions on the class diagram

IMHO, because Activities have no or almost no structure dependencies, the appropriate class diagram will be very poor - simple blocks without associations. And dependencies all over the field... So, the class diagram is not useful on this level. It seems, I have told you already, that class diagrams are for classes that are in one same Android intent - one or more for an intent.

As for communication diagram, I think it is not your case. It is more common, close to user, than sequence or activity diagrams. It is for the case when you have very many sorts of messages and you are planning their routes. For Camel planning, for example. But alas - it has not implemented message patterns. So, it remains only for very common planning of systems with mass messaging. Your "messages" are starting, initiating components and so on. You can't show it with that diagram.

You can try Object Diagram, or Composite Structure diagram. If you want to show functionality on the class diagram, you can't do it, but you can move to these ones.

like image 140
Gangnus Avatar answered Sep 22 '22 12:09

Gangnus