1

I like to organise packages in my solutions to correspond three classical onion architecture layers:

  • domain
  • application
  • infrastructure

Let's consider an example exchange application which calculates stock prices. This example application might need some initial data of companies which are available. The companies must be understandable for the domain, of course. I know that i should have only business rules in the domain package, however the business won't live without this initial collection of companies. Most of tutorials i've experienced have this data somewhere in the infrastructure and it's dependencies. For example someone configures the persistency and somewhere in there adds some records or whatever to the database. I've created a static collection of all aggregates needed to be persisted before running the application in the domain package. Then referenced them in the infrastructure package to execute insert logic on application start. Is it correct approach? If not, please explain what am i doing wrong? Regards

Bulchsu
  • 580
  • 11
  • 33

1 Answers1

0

I think that your approach (hardcoded static data defined in the domain as aggregates),is even more correct than loading the storage device with plain data in the infraestructure, because you do it from the app and it checks data validation. On the other hand, plain data in infraestructure could contain errors that wouldn't be detected.

choquero70
  • 4,470
  • 2
  • 28
  • 48