0
votes

is it allowed to draw a sequence diagram with classes and systems as lifelines.

For example:

I want to model a part of the domain logic with a sequence diagram. Can I model a the lifeline once as a class and once as a whole system (remote system or a whole layer/jar file)?

Example-1:

There is the Class Scheduler which invokes the FileDownloader class which calls a FileServer? So I have the "Scheduler" (Class) the "FileDownloader" (Class) and the "FileServer"(remote System) as a lifeline.

Example-2:

Or I have a Class called Scheduler which invokes the "AccountingService" which calls the "Persistence Layer" which calls the "Database" So I have the "Scheduler" (Class) the "AccountingService"(Class) the "PersistenceyLayer" (Whole Layer or .jar File) and the "Database" (System).

Is it allowed to mix these up in a sequence diagram. In some descriptions about sequence diagrams there would only modelled classes that call classes or systems that call systems.

Thanks.

3
In sequence diagrams, displaying a class means "when I make an instance / object of this class, this activities occur".umlcat

3 Answers

0
votes

What do you mean by "System" ? In UML there is not definition of system. You probably mean System as a name of Class or Component, or is it a stereotype? If yes, you can mix it. Jar file is artifact. Artifact is Classifier as well. If artifact plays role in internal or communication structure, it can be represented by lifeline as well.

Lifeline represents instance of specific type which participate in interaction. Referenced type could be any connectable element from classifier owning interaction (sequence diagram, for example Class, Component or other types of classifiers). To learn more about UML, I recommend you to read UML superstructure specification document. Dowload it for free from omg.. UML Superstructure

0
votes

Lifeline usually represents a role (it can be what you call system or even a human being), or an object. Notice, not class but its instance! Lifeline represents any thing with some behaviour. Classes mostly describe not their own behaviour, but behaviour of their instances. You'll have a class as a timeline only when you are modelling its static fields and functions. Or when you are in JS or similar language and your class is really a prototype

So, mixing of large and small objects, components or roles is absolutely OK. It is a part of standard UML usage. But do not mix instances and classes if you are modelling for "traditional" languages! Are you sure that it is the class "Sheduler" that invokes something, and not an instance myBestSheduler of this class?

0
votes

In sequence diagrams, displaying a class means "when I make an instance / object of this class, this activities occur".

And, other external stuff, that interact with your program, like the users ("actors"), Shared Libraries /DLLs, Web Services, Operating System, Network, whatever ...

... are considered objects ("instance of a class").

A Sequence Diagram, is composed by several objects, each one, with its own "Lifeline" or "TimeLine", that interact among them, (several "Lifeline (s)").