如何使用c# .NET 4实现DDD

时间:2022-03-18 05:05:37

As I'm typing this, I'm realizing that it's very hard to explain. My apologies if it's indiscernible. My end goal is to have someone with more experience look at how I'm structuring my solution and provide feedback on whether or not it is an acceptable setup.

当我输入这个时,我意识到这很难解释。如果无法辨认,我向你道歉。我的最终目标是让有更多经验的人看看我是如何构建我的解决方案的,并就它是否是可接受的设置提供反馈。

I currently manage several small support projects that are loosely related to one another. They are all over the board. I want to create a unified INTERNAL-WEB application to manage these projects. I've managed to group everything conceptually into three domains. SHIPPING, EXTERNAL-WEB, INTERNAL-WEB. From a business perspective, SHIPPING sends WIDGETs to CUSTOMERs which then connect to EXTERNAL-WEB. The problem is that SHIPPING's definition of WIDGET and CUSTOMER is different than the EXTERNAL-WEB definition, so I need to break these two apart.

我目前管理着几个小的支持项目,它们彼此之间关系不大。它们都在黑板上。我希望创建一个统一的内部web应用程序来管理这些项目。我已经成功地将所有概念归纳为三个领域。航运、外部web、内部web。从业务的角度来看,SHIPPING将小部件发送给客户,然后连接到外部web。问题是,SHIPPING对小部件和客户的定义与外部web定义不同,因此我需要将两者分开。

After some thinking, I've come to the conclusion that the best way to organize this in VS2010 is to create a solution and then nest multiple projects within the solution. I'm envisioning a layout like the following.

经过一些思考,我得出了这样的结论:在VS2010中组织这个问题的最佳方式是创建一个解决方案,然后在解决方案中嵌套多个项目。我设想的布局如下所示。

SOLUTION
---SOLUTION.SHIPPING.Domain             (Classes)
---SOLUTION.SHIPPING.Infrastructure     (Classes)
---SOLUTION.EXTERNAL-WEB.Domain         (Classes)
---SOLUTION.EXTERNAL-WEB.Infrastructure (Classes)
---SOLUTION.INTERNAL-WEB.Domain         (Classes)
---SOLUTION.INTERNAL-WEB.Infrastructure (Classes)
---SOLUTION.WebUI                       (MVC3 Project)

I'll have to add additional projects for context maps and anti-corruption layers to allow communication between domains, but this is the basic layout.

我必须为上下文映射和反腐败层添加额外的项目,以允许域之间的通信,但这是基本的布局。

Is this smart or is it stupid?

这是聪明的还是愚蠢的?

Thanks, Greg

谢谢,格雷格

1 个解决方案

#1


2  

How you have configured your solution has nothing to do with DDD and won't effect the success of your project. Good code that is organized badly is much better than bad code that is organized well.

您如何配置您的解决方案与DDD无关,也不会影响项目的成功。组织不良的好代码要比组织良好的坏代码好得多。

Projects have a productivity and complexity cost associated with them. Right now you are agonizing over details which don't really matter.

项目具有与之相关的生产力和复杂性成本。现在你在纠结于那些无关紧要的细节。

More projects also equals slower compile times which increases context shifting. Try reading a book and pausing for 30 seconds every page.

更多的项目也意味着更慢的编译时间,这会增加上下文的转换。试着读一本书,每一页停顿30秒。

New projects should be created for either deployment or code sharing purposes. Good reasons include if the domain is shared between two front or if you have a monstrous deployment strategy ( 1000s of machines ) and megabytes still matter.

应该为部署或代码共享创建新的项目。很好的理由包括,如果域是在两个前端之间共享的,或者您有一个巨大的部署策略(1000台机器)和兆字节仍然很重要。

Once you simplify the rules for new projects the decisions start to be made naturally as the codebase matures and new requirements pops up. You are essentially making physical decisions at the last possible moment. This is good. Don't BUFD this when you have features and code to write!

一旦你简化了新项目的规则,就会随着代码库的成熟和新的需求的出现而自然地做出决定。你本质上是在最后时刻做物理决定。这是很好的。当您有要编写的特性和代码时,不要这样做!


Not sure why this question is tagged MVC but the MVC codebase is pretty lean with only 1 main project. Compiles fast and is really easy to navigate around.

不知道为什么这个问题被标记为MVC,但是MVC代码库非常精简,只有一个主项目。编译速度很快,而且非常容易浏览。

#1


2  

How you have configured your solution has nothing to do with DDD and won't effect the success of your project. Good code that is organized badly is much better than bad code that is organized well.

您如何配置您的解决方案与DDD无关,也不会影响项目的成功。组织不良的好代码要比组织良好的坏代码好得多。

Projects have a productivity and complexity cost associated with them. Right now you are agonizing over details which don't really matter.

项目具有与之相关的生产力和复杂性成本。现在你在纠结于那些无关紧要的细节。

More projects also equals slower compile times which increases context shifting. Try reading a book and pausing for 30 seconds every page.

更多的项目也意味着更慢的编译时间,这会增加上下文的转换。试着读一本书,每一页停顿30秒。

New projects should be created for either deployment or code sharing purposes. Good reasons include if the domain is shared between two front or if you have a monstrous deployment strategy ( 1000s of machines ) and megabytes still matter.

应该为部署或代码共享创建新的项目。很好的理由包括,如果域是在两个前端之间共享的,或者您有一个巨大的部署策略(1000台机器)和兆字节仍然很重要。

Once you simplify the rules for new projects the decisions start to be made naturally as the codebase matures and new requirements pops up. You are essentially making physical decisions at the last possible moment. This is good. Don't BUFD this when you have features and code to write!

一旦你简化了新项目的规则,就会随着代码库的成熟和新的需求的出现而自然地做出决定。你本质上是在最后时刻做物理决定。这是很好的。当您有要编写的特性和代码时,不要这样做!


Not sure why this question is tagged MVC but the MVC codebase is pretty lean with only 1 main project. Compiles fast and is really easy to navigate around.

不知道为什么这个问题被标记为MVC,但是MVC代码库非常精简,只有一个主项目。编译速度很快,而且非常容易浏览。