简体   繁体   English

有界上下文的具体化是什么? (C#/.NET)

[英]What is the materialization of Bounded Context? (C# / .NET)

I have a bit of a hard time understanding of how is Bounded Context materialized in c# / .net core?我对如何在 c#/.net 核心中实现有界上下文有一点困难? Is it a project (assembly), folder, class or none of the above?它是项目(程序集)、文件夹、类还是以上都不是?

I see in microservices architecture that some advocate for Bounded Context corresponding to one microservice and that makes sense to me.我在微服务架构中看到有些人提倡与一个微服务相对应的限界上下文,这对我来说很有意义。 On the other hand, i have a hard time getting it outside of microservices world.另一方面,我很难将其排除在微服务世界之外。

So, in typical monolith - what does it materialize into?那么,在典型的单体应用中——它具体化为什么?

Bounded context it is only about lexical boundaries.有界上下文仅与词汇边界有关。 Even in microservices, one bounded context can contains several microservices (but not the other way around).即使在微服务中,一个有界上下文也可以包含多个微服务(但反过来不行)。 So it depends on you.所以这取决于你。 Eg In monolith it could be just one project, but it could be several projects in one folder.例如,在单体应用中,它可能只是一个项目,但也可能是一个文件夹中的多个项目。

So the most flexible answer would be several projects in one folder

If you have no special deployment requirements I would say everything that allows you to restrict visibility.如果您没有特殊的部署要求,我会说所有允许您限制可见性的内容。 In the java world that would probably be a package (if not a Java9+ module).在 Java 世界中,这可能是一个包(如果不是 Java9+ 模块)。 That way you can ensure that nothing "internal" leaks the BC and public implementations designed to be consumed somewhere else can be marked that way.通过这种方式,您可以确保没有任何“内部”泄漏 BC,并且可以以这种方式标记旨在在其他地方使用的公共实现。

If you have special deployment requirements (BC x should be deployable independent of others if there is no backwards breakage) you could consider modularizing to have every BC correspond to one artifact (.jar or .dll or whatever).如果您有特殊的部署要求(如果没有向后损坏,BC x 应该可以独立于其他部署),您可以考虑模块化以使每个 BC 对应一个工件(.jar 或 .dll 或其他)。 This is kind of a microservicy approach but within a monolithic development environment.这是一种微服务方法,但在单体开发环境中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM