[英]Abstract Factory Pattern in Onion Architecture
Good morning, My question is about Visual Studio project/catalog structure.早上好,我的问题是关于 Visual Studio 项目/目录结构的。 I'm creating a simple project and I want to adopt Onion Architecture there.我正在创建一个简单的项目,我想在那里采用 Onion Architecture。 I have few layers (projects): MyProject.Domain (with Enums, Entites, Interfaces), MyProject.API , MyProject.Infrastructure.DependecyResolution , MyProject.Client.WPF我有几个层(项目): MyProject.Domain (带有枚举、实体、接口)、 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 )?在我的 Visual Studio 解决方案中,我应该将工厂的接口和实现(将创建这些产品)放在哪里?
My question is: Is Factory interface or Factory concrete implementation part of Domain in Onion Arch.?我的问题是:工厂接口或工厂具体实现是 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.这个问题更多的是关于良好的编程实践,保持 Visual Studio 解决方案干净整洁。
There isn't a single correct answer. 没有一个正确的答案。 Maybe you can create a folder 'core' where you put all of your core code. 也许您可以创建一个文件夹“ core”,在其中放置所有核心代码。 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. 仅在其中创建一个“ interfaces”文件夹是没有错的,通常会看到一个名为“ entities”的文件夹,其中包含各种数据类。
My question is: Is Factory interface or Factory concrete implementation part of Domain in Onion Arch.? 我的问题是:在Onion Arch中,Factory接口或Factory具体实现是Domain的一部分吗?
I'm not an expert in Onion Architecture philosophy, but there are a few arguments to put the Factories in the same package as the products: 我不是Onion Architecture哲学的专家,但是有一些争论可以将工厂与产品放在同一包装中:
my idea is make Ifactories folder in domain project in core of software,but bring implementation of them in upper layers我的想法是在软件核心的域项目中创建 Ifactories 文件夹,但在上层实现它们
benefit of bring interfaces in core is upper layers can use them在核心中引入接口的好处是上层可以使用它们
benefit of bring implementation in upper layers is encapsulating implementation在上层实现的好处是封装实现
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.