Monday, 25 September 2023

How to Add Fields to Objects in PlantUML?

Using the symbol : followed by the field’s name, we can add fields to the object.

Example

object "ChatServer:Project" as chatServer
chatServer : name = "Chat Server"
chatServer : description = "applicaiton send and receive messages"

addFieldsToObject.txt

@startuml

title "Object Association"

object "Anand:Manager" as anand
anand : name = Anand
anand : age = 45

object "Ravi:Employee" as ravi
object "Sailu:Employee" as sailu

ravi --> anand : reports to
sailu --> anand : reports to

object "ChatServer:Project" as chatServer
chatServer : name = "Chat Server"
chatServer : description = "applicaiton send and receive messages"

anand ..> chatServer : manages

@enduml

Above snippet generate below diagram.


 

You can even use {} to group the fields at the time of defining the object.

 

Example

object "ChatServer:Project" as chatServer{
	name = "Chat Server"
	description = "applicaiton send and receive messages"
}

 

addFieldsUsingBraces.txt

@startuml

title "Object Association"

object "Anand:Manager" as anand {
	name = Anand
	age = 45
}

object "Ravi:Employee" as ravi
object "Sailu:Employee" as sailu

ravi --> anand : reports to
sailu --> anand : reports to

object "ChatServer:Project" as chatServer{
	name = "Chat Server"
	description = "applicaiton send and receive messages"
}

anand ..> chatServer : manages

@enduml

 

Above snippet generate below diagram.

 


 


Previous                                                    Next                                                    Home

No comments:

Post a Comment