PlantUML Object Diagram Syntax Guide
What is an Object Diagram? An Object Diagram is a structural UML diagram that acts as a concrete, real-time snapshot of your application state. While a Class Diagram outlines the abstract blueprints, data types, and structural rules of a system, an object diagram visualizes a live execution instance at a specific point in time. It models actual objects instantiation, displays the exact values assigned to their fields, and highlights the specific linkages that exist between those instances during runtime. This specific UML diagram type is incredibly valuable for debugging complex data structures, explaining highly nested relation states (such as parent-child tree graphs), or verifying that an engineering design pattern behaves as expected under specific edge-case variables. With VPasCode, you can script out live object relations cleanly, bypassing manual box-drawing tools entirely. Core Syntax Guide: Elements and Constructs To design an accurate, standards-compliant UML object diagram in PlantUML, you need to understand object instantiations, field value assignments, and instance link mappings. 1. Instantiating Objects (Name vs. Class Types) Objects are declared using the object keyword. Based on standard UML modeling conventions, you define an object by providing its unique instance name, followed by a colon, and its parent class blueprint type: PlantUML Edit PlantUML in VPasCode object “currentUser : Account” as activeUser Edit PlantUML in VPasCode Pro Tip: Always use the as keyword to map a long instance name declaration to a short, internal shorthand ID (like activeUser) to make drawing linkage lines fast and clean. 2. Assigning Field States and Run-Time Values To populate your objects with test data values, open up a body block using trailing curly braces and write your data key-value allocations on separate lines. Unlike class definitions, do not append data types here—use actual operational values: PlantUML Edit PlantUML in VPasCode object “adminCart : ShoppingCart” as cart1 { cartId = “CART-9081” itemCount = 3 isTaxExempt = false } Edit PlantUML in VPasCode 3. Mapping Instance Linkages Connections between concrete instances in an object diagram represent real-world memory pointers rather than abstract structural patterns. You map these links using solid double dashes (–). You can also append string labels to indicate the functional context of the link: PlantUML Edit PlantUML in VPasCode activeUser — cart1 : “owns and modifies” Edit PlantUML in VPasCode Best Practices for Practical Object Maps Focus on What Matters: Do not list every single field from a class definition. Only include key variable values that directly explain the specific runtime state or bug you are trying to illustrate. Keep Links Neutral: Avoid using inheritance triangles or strict composition diamonds on an object diagram. Use simple, flat relationship lines (–) or basic arrow tips (–>) to show references. Align Iterations Horizontally: If you are mapping an array list or sequence of historical objects, use horizontal navigation arrows like -right-> to force instances to render cleanly in a single line. Real-World PlantUML Object Diagram Examples Example 1: Identity Token Session State (Concrete Value Mappings) This boilerplate maps a live security authorization state, demonstrating how a single authenticated user links out to multiple specific active machine session instances with distinct data variables. PlantUML Edit PlantUML in VPasCode @startuml object “targetUser : UserAccount” as user { userId = 1042 username = “dev_admin” status = “ACTIVE” } object “sessionMobile : UserSession” as session1 { sessionId = “SESS-AAA-99” deviceOS = “iOS 17” ipAddress = “192.168.1.54” } object “sessionDesktop : UserSession” as session2 { sessionId = “SESS-BBB-11” deviceOS = “macOS 14” ipAddress = “72.44.12.102” } ‘ Establish runtime linkages user — session1 : “authenticated on” user — session2 : “authenticated on” @enduml Edit PlantUML in VPasCode Syntax Breakdown: This layout captures a definitive scenario in production code: one specific user record (ID 1042) driving two completely separate runtime session instances simultaneously. Each session container tracks its own isolated metadata layout parameters. Example 2: E-Commerce Invoice Fulfillment State (Multi-Entity Maps) This advanced system blueprint maps a completed financial transaction graph. It charts exactly how order records, transaction logs, and warehouse packages relate to one another at a specific point in time. PlantUML Edit PlantUML in VPasCode @startuml object “buyerProfile : Customer” as customer { email = “[email protected]” tier = “VIP” } object “activeOrder : Order” as order { orderNumber = “#99122” subtotal = 149.99 currency = “USD” } object “stripeTransaction : LedgerEntry” as ledger { referenceId = “ch_3Mv8x” gatewayStatus = “SUCCESS” settledAt = “2026-05-26” } object “packageA : Shipment” as ship1 { trackingCode = “1Z999AA1” carrier = “UPS” weightKg = 1.4 } object “packageB : Shipment” as ship2 { trackingCode = “1Z999AA2” carrier = “UPS” weightKg = 0.8 } ‘ Structural execution links customer — order : “submitted” order — ledger : “funded by” order — ship1 : “fulfilled via” order — ship2 : “fulfilled via” @enduml Edit PlantUML in VPasCode Syntax Breakdown: This template provides a highly structured overview of a complex system state. It shows a single order linked to a successful checkout transaction log, and split into two distinct physical shipment files. This level of detail makes it an excellent blueprint for auditing data structures and system processes.