What do you think about passing typeless maps to APIs (packages, systems, adapters) outer to Core Domain as in 1st Way below?
Strongly-typed objects are inside Domain API, and business rules are using them.
1st WAY:
Domain -> Web API -> Clients
Passes strongly-typed domain objects
Whenever a request comes from the Web API, it requests to Domain and Domain passes the strongly-typed domain objects (like:
[]SomeDomainObject
) to the APIThen, the Web API transforms these into JSONs and response back to the clients
2nd WAY:
Domain -> Web API -> Clients
Passes property maps which loose their types
Whenever a request comes from the Web API, it requests to Domain and Domain transforms the strongly-typed domain objects into property maps (like:
map[string][object]
) and passes them to the APIThen, the Web API transforms these into JSONs and response back to the clients
In the 1st way:
When domain objects or rules change, that can affect Web API. For example: Web API needs to accommodate itself for the new data added to the domain objects.
So, change in Domain reflects in change in outer services because of
types
In the 2nd way:
Domain controls everything. Whenever domain objects or rules change, Web API will automatically response back with what the domain wishes.
Any change in Domain automatically be reflected to outer clients, because they'll not need to see Domain entities, they'll only see properties. And, can easily pass them to the clients as they're supplied from the Domain.
Downside is that Web API will loose the strong type-safety of Domain objects and will only see typeless property maps.