Shop modules
Seven classes of a shop in four packages: Ordering and Catalog nested inside Shop, Billing beside it, and the customer outside all of them. Classes name their package with in; relations run across package borders as before. The description names every package with what it holds, and the table gains a Package column such as Shop › Ordering.
Shop modules
examples/shop-modules.json{
"schemaVersion": 1,
"type": "classes",
"title": "Shop modules",
"source": "Illustrative domain model",
"width": 900,
"height": 860,
"classes": {
"packages": [
{
"id": "shop",
"label": "Shop"
},
{
"id": "ordering",
"label": "Ordering",
"in": "shop"
},
{
"id": "catalog",
"label": "Catalog",
"in": "shop"
},
{
"id": "billing",
"label": "Billing"
}
],
"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()"
],
"in": "ordering"
},
{
"id": "line",
"label": "OrderLine",
"attributes": [
"+ quantity: Int",
"+ price: Money"
],
"in": "ordering"
},
{
"id": "product",
"label": "Product",
"attributes": [
"+ sku: String",
"+ name: String",
"+ price: Money"
],
"in": "catalog"
},
{
"id": "payment",
"label": "Payment",
"kind": "interface",
"methods": [
"+ charge(amount: Money): Receipt"
],
"in": "billing"
},
{
"id": "card",
"label": "CardPayment",
"attributes": [
"- number: String"
],
"methods": [
"+ charge(amount: Money): Receipt"
],
"in": "billing"
},
{
"id": "status",
"label": "Status",
"kind": "enum",
"attributes": [
"PLACED",
"PAID",
"SHIPPED",
"CANCELLED"
],
"in": "ordering"
}
],
"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 | Package | Attributes | Methods | Relations |
|---|---|---|---|---|---|
| Customer | Class | + id: Int; + name: String; + email: String | + placeOrder(): Order | is associated with Order (1 : 0..*) [places] | |
| Order | Class | Shop › Ordering | + 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 | Shop › Ordering | + quantity: Int; + price: Money | is associated with Product (* : 1) | |
| Product | Class | Shop › Catalog | + sku: String; + name: String; + price: Money | ||
| Payment | Interface | Billing | + charge(amount: Money): Receipt | ||
| CardPayment | Class | Billing | - number: String | + charge(amount: Money): Receipt | implements Payment |
| Status | Enumeration | Shop › Ordering | PLACED; PAID; SHIPPED; CANCELLED |