Validator |
驗證領域規則(domain invariants)、輸入資料檢查 |
OrderValidator 驗證訂單是否可建立 |
Domain Layer(domain/service 或 domain/validation) |
Factory |
建立複雜 Aggregate 或 Entity,避免建構子過重 |
OrderFactory 負責建立 Order 與關聯的 OrderLine
|
Domain Layer(domain/factory) |
Translator / Mapper |
負責 DTO ↔ Entity ↔ Domain Object 轉換 |
OrderTranslator 、UserMapper
|
Application Layer(application/mapper 或 application/translator) |
Converter |
格式或型別轉換(非業務邏輯) |
CurrencyConverter |
Infrastructure Layer(infra/converter) |
Assembler |
將多個物件組裝成 DTO 或 ViewModel |
OrderDtoAssembler |
Application Layer(application/assembler) |
Adapter |
對接外部系統或 API |
PaymentGatewayAdapter |
Infrastructure Layer(infra/adapter) |
Policy |
表達可替換的業務規則 |
DiscountPolicy |
Domain Layer(domain/policy) |
Specification |
複雜查詢或條件的封裝 |
ActiveCustomerSpecification |
Domain Layer(domain/specification) |
Strategy |
行為可替換的演算法 |
ShippingCostStrategy |
Domain Layer(domain/strategy) |
Service |
跨 Aggregate 的領域操作,或應用服務邏輯 |
PaymentService |
Domain Service → Domain Layer / Application Service → Application Layer
|