Search code examples
c#visual-studiodesign-patternsfactoryabstract-factory

Abstract Factory Pattern in Onion Architecture


Good morning, My question is about Visual Studio project/catalog structure. I'm creating a simple project and I want to adopt Onion Architecture there. I have few layers (projects): MyProject.Domain (with Enums, Entites, Interfaces), MyProject.API, MyProject.Infrastructure.DependecyResolution, MyProject.Client.WPF

I want to use Abstract Factory Pattern. I have factory class, and few product classes.

My "product's" interfaces are in Domain->Interfaces, my "product's" implementations are in Domain->Entites. Where in my Visual Studio Solution, should I put interfaces and implementations of Factories (that will create those products)?

My question is: Is Factory interface or Factory concrete implementation part of Domain in Onion Arch.? Or should I create another project for factories? This question is more about good programming practices, maintaining Visual Studio solution clean and tidy.


Solution

  • There isn't a single correct answer. Maybe you can create a folder 'core' where you put all of your core code. There's nothing wrong with just creating an 'interfaces' folder inside this and it's common to see a folder called 'entities' containing the various data classes.