ドメインの文書化
データベース駆動設計(ER図)やクラス駆動設計(クラス図)を使わずに要件をどう記録すべきか UML を使うこともできるが、作業がしづらく、ドメインの微妙な部分を表現するには十分でない場合も この構文は日本語話者にとっては結構ハードル高い気がする... radish-miyazaki.icon
日本語使えばいいじゃん
データ構造: Name AND Address のように、AND を用いて両方が必須なことを表現 また、Email OR PhoneNumber のように、OR を用いてどちらか一方が必須なことを表現
e.g. 注文確定のワークフロー
ワークフロー
code:text
bounded context: Order-Taking
workflow: "Place order" =
input: UnvalidatedOrder
output (on successs):
OrderAcknowledgmentSent
AND OrderPlaced (to send to shipping)
AND BillableOrderPlaced (to send to billing)
output (on error):
ValidationError
// ステップ 1
do ValidateOrder
If order is invalid then:
return with ValidationError
// ステップ 2
do PriceOrder
// ステップ 3
do SendAcknowledgmentToCustomer
// ステップ 4
create and return the events
substep "ValidateOrder" =
input: UnvalidatedOrder
output: ValidatedOrder OR ValidationError
dependencies: CheckProduceCodeExists, CheckAddressExists
validate the customer name
check that the shipping and billing address exist
for each line:
check product code syntax
checkt that product code exists in ProductCatalog
if everything is OK, then:
return ValidatedOrder
else
return ValidationError
substep "PriceOrder" =
input: ValidatedOrder
output: PricedOrder
dependencies: GetProductPrice
for each line:
get the price for the product
set the price for the line
set the amount to bill ( = sum of the line prices )
substep "SendAcknowledgmentToCustomer" =
input: PricedOrder
output: None
create acknowledgment letter and send it
and the priced order to the customer
データ構造
code:text
bounded context: Order-Taking
data WidgetCode = string starting with "W" then 4 digits
data GizmoCode = string starting with "G" then 3 digits
data ProductCode = WidgetCode OR GizmoCode
data UnitQuantity = integer between 1 and 1000
data KilogramQuantity = float between 0.05 and 100.00
data OrderQuantity = UnitQuantity OR KilogramQuantity
data UnvalidatedOrder =
UnvalidatedCustomerInfo
AND UnvalidatedShippingAddress
AND UnvalidatedBillingAddress
AND list of UnvalidatedOrderLine
data UnvalidatedOrderLine =
UnvalidatedProductCode
AND UnvalidatedOrderQuantity
data ValidatedOrder =
ValidatedCustomerInfo
AND ValidatedShippingAddress
AND ValidatedBillingAddress
AND list of ValidatedOrderLine
data ValidatedOrderLine =
ValidatedProductCode
AND ValidatedOrderQuantity
data PriceOrder =
ValidatedCustomerInfo
AND ValidatedShippingAddress
AND ValidatedBillingAddress
AND list of PricedOrderLine
AND AmountToBill
data PricedOrderLine =
ValidatedOrderLine
AND LinePrice
data PlacedOrderAcknowledgment =
PriceOrder
AND AcknowledgmentLetter