DDD: Domain model namespaces convention

Viewed 2260

I'm writing an application with a domain model in PHP, and am wondering which naming convention I should adopt.

Let's say I have a Customer, having an Address within its aggregate root.
I also have a Product, having an Option within its aggregate root.

I have two alternatives:

  1. Keep aggregate roots at the root of the domain model:

    Customer
    Customer\Address
    Product
    Product\Option
    

    Pro: I can use both Customer and Product in the same namespace
    Con: Customer has to reference its own Address as Customer\Address

  2. Group all aggregate classes in the same namespace, including the aggregate root:

    Customer\Customer
    Customer\Address
    Product\Product
    Product\Option
    

    Pro: Customer can reference its address as Address
    Con: from my root domain namespace, I have to reference:

    • Customer as Customer\Customer
    • Product as Product\Product
1 Answers
Related