0
votes

I have a SessionManager class, that I create objects of in every class a user needs to be logged in to reach I am unsure of the type of relationship created here as I seem to have confused myself with all of the definitions online. I am trying to create a UML class diagram representing all of the classes in my application. Would this be an Aggregation relationship or simply an associated relationship?

I have no classes that extend each other as I have made an Android app that uses intents to pass from activity to activity, I'm simply creating objects of some classes in other classes.

Additionally, is there any way to represent an intent on a UML class diagram?

Creating SessionManager Object:


SessionManager sessionManager;

Using checkLogin() method from SessionManagerClass in onCreate method:


sessionManager = new SessionManager(this);
        sessionManager.checkLogin();

3

3 Answers

-1
votes

It would have HAS-A relationship, in other words, Aggregation.

Aggregation is a special form of association. It is a relationship between two classes like association, however its a directional association, which means it is strictly a one-way association. It represents a HAS-A relationship

UML Construction Demo

Aggregation UML sample

Aggregation UML

Source

More info:

Aggregation vs composition

0
votes

I think Composition relationship is correct in this case.

class A {
   private B b = new B();
}
//or
class A {
   private B b;
   public A() {
      b = new B();
   }
}
0
votes

Composite aggregation is about runtime. Composed elements are to destroyed along with the composing element. The table on p. 110 of UML 2.5 states

composite | Indicates that the Property is aggregated compositely, i.e., the composite object has responsibility for the existence and storage of the composed objects (see the definition of parts in 11.2.3).

It seems appropriate to model this (filled diamond at the association end) in your case. The SessionManager should be some kind of factory producing Session objects which it holds responsibility for.