Question

This is my first try at implementing the Onion Architecture.

enter image description here

AppService -> folder for the abstractions for the entire Application
Business -> Business logic using the abstractions in the Core project
DataService -> folder for abstractions that are implemented in the DataAccess project
Model -> Entities used by the application
WebService -> folder for abstractions that are implemented in the WebAccess project
  1. Are the folder above placed correct?
  2. Is the place for the DependencyResolution project in the Domain folder?
  3. Should each of the projects in the Infrastructure contain a DependencyRegistrar file that registers the interfaces in the Core project with the implementation in the project it's included in?
  4. Should the WebApi project be placed in Presentation->Api? Is it a presentation?
  5. Should I place all unit tests for each project in the 'Tests' folder?

Thanks in advance.

Was it helpful?

Solution

  1. Your folder structure generally seems fine. Personally, I go for a more modular approach where folders in your core project are actually individual projects in mine, but this is just my preference.
  2. Dependency Resolution isn't part of your domain and it isn't really infrastructure either (at least in my opinion). It's a concept in and of itself.
  3. The DependencyRegistrars seem unnecessary. It's the responsibility of Dependency Resolution to map abstractions to implementations.
  4. My immediate reaction would be no, but in the past I have done single page applications where I have used MVC and WebApi in the same project. Thus together they would make the client. If each mobile client has its own backend, I would put those projects in the same folder as the client. Otherwise, I would consider a top-level "backend" or "services" solution folder to put them in if they are shared between multiple different clients.
  5. I think it makes more sense for each project and their tests to live next to each other so navigating from one to the other or vice-versa is easy (i.e. not having to scroll up and down the solution).

So apart from Dependency Resolution living in Domain and the DependencyRegistrars, it seems fine. The specifics are down to what you think is best.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top