Order model
Seven classes of a shop: attributes and methods in their own compartments, an interface and an enumeration with their stereotypes, a composition with a filled diamond, a realization with a hollow triangle, dependencies dashed, and cardinalities at the ends. chartlet lays it out; the description and the table give every class with its members and relations.
Order model
examples/order-model.json{
"schemaVersion": 1,
"type": "classes",
"title": "Order model",
"source": "Illustrative domain model",
"width": 900,
"height": 720,
"classes": {
"classes": [
{
"id": "customer",
"label": "Customer",
"attributes": [
"+ id: Int",
"+ name: String",
"+ email: String"
],
"methods": [
"+ placeOrder(): Order"
]
},
{
"id": "order",
"label": "Order",
"attributes": [
"+ id: Int",
"+ placedAt: Date",
"+ status: Status"
],
"methods": [
"+ total(): Money",
"+ cancel()"
]
},
{
"id": "line",
"label": "OrderLine",
"attributes": [
"+ quantity: Int",
"+ price: Money"
]
},
{
"id": "product",
"label": "Product",
"attributes": [
"+ sku: String",
"+ name: String",
"+ price: Money"
]
},
{
"id": "payment",
"label": "Payment",
"kind": "interface",
"methods": [
"+ charge(amount: Money): Receipt"
]
},
{
"id": "card",
"label": "CardPayment",
"attributes": [
"- number: String"
],
"methods": [
"+ charge(amount: Money): Receipt"
]
},
{
"id": "status",
"label": "Status",
"kind": "enum",
"attributes": [
"PLACED",
"PAID",
"SHIPPED",
"CANCELLED"
]
}
],
"relations": [
{
"from": "customer",
"to": "order",
"fromCardinality": "1",
"toCardinality": "0..*",
"label": "places"
},
{
"from": "order",
"to": "line",
"kind": "composition",
"fromCardinality": "1",
"toCardinality": "1..*"
},
{
"from": "line",
"to": "product",
"fromCardinality": "*",
"toCardinality": "1"
},
{
"from": "card",
"to": "payment",
"kind": "realization"
},
{
"from": "order",
"to": "payment",
"kind": "dependency",
"label": "paid by"
},
{
"from": "order",
"to": "status",
"kind": "dependency"
}
]
}
}Focus
Source: Illustrative domain model
Show chart data
| Item | Kind | Attributes | Methods | Relations |
|---|---|---|---|---|
| Customer | Class | + id: Int; + name: String; + email: String | + placeOrder(): Order | is associated with Order (1 : 0..*) [places] |
| Order | Class | + id: Int; + placedAt: Date; + status: Status | + total(): Money; + cancel() | is composed of OrderLine (1 : 1..*); depends on Payment [paid by]; depends on Status |
| OrderLine | Class | + quantity: Int; + price: Money | is associated with Product (* : 1) | |
| Product | Class | + sku: String; + name: String; + price: Money | ||
| Payment | Interface | + charge(amount: Money): Receipt | ||
| CardPayment | Class | - number: String | + charge(amount: Money): Receipt | implements Payment |
| Status | Enumeration | PLACED; PAID; SHIPPED; CANCELLED |