João P. BragançaSometimes our model can’t be as pure as the driven snow. Sometimes we have to use a really crappy external model because replacing it outright would be too expensive. Typically we deal with this in our tests with some kind of mocking framework.
Example,we have a use case for ‘creating’ an item in the ERP system. Of course in real life nothing ever gets ‘created.’ Instead our inventory items are ‘created’ upstream in the product development context.
João P. BragançaThe Soap Box Part We’ve heard this before, but it bears repeating: CQRS is not just for greenfield event-sourced ddd systems. It can apply to crappy brownfield systems too. It may even have more relevance there.
Let’s take the penultimate brownfield system, an ERP system. In particular, Navision. Navision has a fantastic interface for interacting with it (snipped for brevity):
public interface SalesPrice_Port { Read_Result Read(Read request); ReadMultiple_Result ReadMultiple(ReadMultiple request); Create_Result Create(Create request); Update_Result Update(Update request); Delete_Result Delete(Delete request); } In other words, a 100% behavior free SQL-like interface that isn’t sql because you have Create / Read instead of INSERT / SELECT.