View on GitHub

Typed Use Case

Use case definition, for which this console application can generate PlantUML diagram, where all services are domain specific type safe.

Tuc Participants

Home / Tuc / Participants


All participants of the use case must be defined.

NOTE: Order in this definition determines the order of participants in puml result.

The minimal participants definition.

participants
    MyService MyDomainName

Participants:


Active Participant

In order to use a participant in the use-case, it must be an active participant.

NOTE: Every participant is active, unless it is a Component.

Syntax

participants                                    // keyword starting a participant section
    {TypeName} {DomainName} ( as "{Alias}" )    // active participant

Type Name

Participant’s Domain type name.

TIP: Use a PascalCase for type name.

Domain Name

Domain, where a participant is defined.

TIP: Use a PascalCase for domain name.

Alias

Optional part of participant definition.

Alias is used as a participant title in the puml file. If alias is not set, type name will be used instead.

Example

Let’s say, we have domain Example.

Domain types will be in exampleDomain.fsx (or ExampleDomain.fsx).

// exampleDomain.fsx

type MainService = Initiator

type Service = {
    DoSomeWork: Input -> Output
}
participants
    MainService Example as "Main Service"
    Service Example

In puml:

actor "Main Service" as MainService <<Example>>
participant "Service" as Service <<Example>>

NOTE: Initiator will be declared as an actor in the puml.

Component

Component is used, when you need to group participants together.

Component can not be used anywhere in the use-case - its only purpose is grouping participants in the puml.

Syntax

participants                                            // keyword starting a participant section
    {ComponentTypeName} {DomainName}                    // component participant
        {TypeName} ( {DomainName} ) ( as "{Alias}" )    // active participant, from component
// exampleDomain.fsx

type MainService = Initiator

type ServiceA = {
    DoSomeWork: Input -> Output
}

type ServiceB = {
    DoSomeWork: Input -> Output
}

type ServiceComponent = {
    ServiceA: ServiceA
    ServiceB: ServiceB
}
participants
    MainService Example as "Main Service"   // this is Active Participant
    ServiceComponent Example                // this is a Component
        ServiceA Example                    // this is Active Participant of the Component
        ServiceB as "Service B"             // this is Active Participant of the Component

In puml:

actor "Main Service" as MainService <<Example>>
box "ServiceComponent"
    participant "ServiceA" as ServiceA <<Example>>
    participant "Service B" as ServiceB <<Example>>
end box

Data Object

Data object is a special kind of an Active Participant and it stands for a Database, Stream, Storage, …

NOTE: It may also be used in the Component.

Syntax

participants                                    // keyword starting a participant section
    [{TypeName}] {DomainName} ( as "{Alias}" )  // active participant

Example of different data objects (you can use whatever names you want).

// myDomain.fsx

// Data object types
type Database<'Entity> = Database of 'Entity list
type Cache<'CachedData> = Cache of 'CachedData list

// Domain specific data object service
type InteractionDatabase = InteractionDatabase of Database<InteractionEntity>

and InteractionEntity = InteractionEntity

type InteractionCache = InteractionCache of Cache<InteractionEntity>
participants
    [InteractionDatabase] My as "Interaction DB"
    [InteractionCache] My

In puml:

database "Interaction DB" as InteractionDatabase <<My>>
database "InteractionCache" as InteractionCache <<My>>

Stream

Stream is a specific kind of a Data object.

Syntax

participants                                            // keyword starting a participant section
    [{TypeName}Stream] {DomainName} ( as "{Alias}" )    // active participant

NOTE: It has a special definition in the domain types.

Example

// myDomain.fsx

// Data object types
type Stream<'Event> = Stream of 'Event list

// Domain specific data object service
type InteractionStream = InteractionStream of Stream<InteractionEvent>

and InteractionEvent =
    | Confirmed
    | Rejected
participants
    [InteractionStream] My as "Interaction Stream"

In puml:

collections "Interaction Stream" as InteractionStream <<My>>

Formatting

Participant’s Alias may contain a formatting, supported by a PlantUML

participants
    MainService Domain as "**bold**"
    MainService Domain as "*italics*"
    MainService Domain as "--stroked--"
    MainService Domain as "__underlined__"
    MainService Domain as "~~waved~~"
    MainService Domain as "<back:cadetblue><size:18>formatted</size></back>"
    MainService Domain as "<u:red>This</u> is <color #118888>displayed</color> **<color purple> with </color> <s:red>some</strike> formatting**"