chartletv0.21.0chartlet.casoon.de

← All examples

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
Order model
Order modelClass diagram with 7 classes and 6 relations. Most connected: Order (4 connections). Bottleneck: Order; without it the diagram falls apart. Customer: 3 attributes, 1 method. Customer is associated with Order (1 : 0..*) [places]. Order: 3 attributes, 2 methods. Order is composed of OrderLine (1 : 1..*); depends on Payment [paid by]; depends on Status. OrderLine: 2 attributes, 0 methods. OrderLine is associated with Product (* : 1). Product: 3 attributes, 0 methods. Payment: 0 attributes, 1 method. CardPayment: 1 attribute, 1 method. CardPayment implements Payment. Status: 4 attributes, 0 methods.Customer → Order: places0..*1Order → OrderLine1..*1OrderLine → Product1*Payment → CardPaymentOrder → Payment: paid byOrder → Statusplacespaid byCustomerCustomer+ id: Int+ name: String+ email: String+ placeOrder(): OrderOrderOrder+ id: Int+ placedAt: Date+ status: Status+ total(): Money+ cancel()OrderLineOrderLine+ quantity: Int+ price: MoneyProductProduct+ sku: String+ name: String+ price: MoneyPayment – «interface»«interface»Payment+ charge(amount: Money): ReceiptCardPaymentCardPayment- number: String+ charge(amount: Money): ReceiptStatus – «enumeration»«enumeration»StatusPLACEDPAIDSHIPPEDCANCELLED

Source: Illustrative domain model

Show chart data
Data for Order model
ItemKindAttributesMethodsRelations
CustomerClass+ id: Int; + name: String; + email: String+ placeOrder(): Orderis associated with Order (1 : 0..*) [places]
OrderClass+ id: Int; + placedAt: Date; + status: Status+ total(): Money; + cancel()is composed of OrderLine (1 : 1..*); depends on Payment [paid by]; depends on Status
OrderLineClass+ quantity: Int; + price: Moneyis associated with Product (* : 1)
ProductClass+ sku: String; + name: String; + price: Money
PaymentInterface+ charge(amount: Money): Receipt
CardPaymentClass- number: String+ charge(amount: Money): Receiptimplements Payment
StatusEnumerationPLACED; PAID; SHIPPED; CANCELLED
  • Class diagram
  • Document a domain model