简体   繁体   English

在将应用程序拆分为Visual Studio中的多个解决方案之前,应该考虑哪些注意事项?

[英]Which considerations should I make before splitting an application into several solutions in Visual Studio?

In the past, my projects has grown to be hard to manage, especially when I have to revisit after a few years to redo or make significant update to one part without having to redo everything. 过去,我的项目变得越来越难以管理,特别是当我几年后不得不重新访问以重做或对某个部分进行重大更新而不必重做所有内容时。 This time I'm focusing hard on making it easy and possible to make a "pluggable" application design to allow me to revisit and redo one part without touching everything. 这次,我将重点放在简化和实现“可插拔”应用程序设计上,以使我能够重新访问和重做一个零件而不会碰到任何东西。

I'm thinking of this structure: 我在想这种结构:

应用程序结构

So what I want is to be able to work on Bounded Context 2 and expand that with a lot of new functionality the coming month/years while Bounded Context 1 is left as is. 所以我想要的是能够在Bounded Context 2上工作,并在接下来的月份/年中使用很多新功能扩展它,而Bounded Context 1保持不变。 I will also work on the UI, especially the parts concerning Bounded Context 2. I would also like to give users the ability to work with bounded context 2 from other devices. 我还将在UI上进行工作,尤其是有关Bounded Context 2的部分。我还希望使用户能够使用其他设备上的bounded context 2。

Preferably even the web technologies used in the UI of bounded context 2 will be updated since this is our primary area of focus and is used the most, so it might even be smart to put that in its own UI project for web and have a "landing" site that gives common functionality like managing users and let users log in. 最好甚至更新有界上下文2的UI中使用的Web技术,因为这是我们关注的主要领域,并且使用最广泛,因此将其放在自己的Web UI项目中甚至拥有一个“登陆”网站,该网站提供了诸如管理用户并允许用户登录等常用功能。

Right now I'm thinking of seperating all of this into seperate Solutions in Visual Studio to ease management. 现在,我正在考虑将所有这些都分离到Visual Studio中的单独解决方案中,以简化管理。 But I could make a folder for each in one solution and put everything there. 但是我可以为每个解决方案创建一个文件夹,然后将所有内容放到那里。

My question is what is the recommended way of doing this, and what should I consider before seperating into different solutions ? 我的问题是建议这样做的方法是什么,在分离为不同的解决方案之前应该考虑什么?

Are there any best practices of how to manage this? 是否有任何最佳实践来管理此问题? Anyone with experience of what works and not? 有经验的人有用吗?

Btw: since this is divided by bounded contexts there will need to be communication between parts of the system, although no direct dependency (ie context 1 manages and maintains business logic for registering employees that again are needed in context 2). 顺便说一句:由于这是由有限的上下文划分的,因此系统的各个部分之间需要进行通信,尽管没有直接的依赖关系(例如,上下文1管理和维护用于注册员工的业务逻辑,而上下文2再次需要)。

Update I realize some more information is needed. 更新我意识到需要更多信息。

There are more bounded contexts than these two. 有比这两者更多的有限上下文。 None of them are really like a department, ie Employee Managment is the context managers are in when they need to organize/archive information related to managing others, and also get reminders on important events. 他们中没有一个真的像部门一样,即员工管理是上下文管理者在需要组织/存档与管理其他人有关的信息并获得重要事件提醒时所处的环境。 Purchasing is the context employees are in when they purchase goods for a department and do inventory, there might be 20-40 organizational departments that use this. 采购是员工在为某个部门购买商品并进行库存时所处的环境,可能有20-40个组织部门使用此资源。 I'm considering if "reporting" is a seperate bounded context (though without very much interesting logic and behavior). 我正在考虑“报告”是否是一个单独的有界上下文(尽管没有非常有趣的逻辑和行为)。 These tend to start small providing basic functionality, then grow with time as more functionality is added and people "discover" new needs. 这些通常从一开始就提供基本功能开始,然后随着时间的增长而增加,随着更多功能的添加和人们“发现”新需求。 They are updated separately, and I hope some of them will grow into larger systems in time even though they start solving rather basic needs. 它们是分别进行更新的,我希望其中一些即使它们开始解决相当基本的需求,也会及时成长为更大的系统。

So, you have bunch of code and want to work on some part of the code without loading projects related to other parts. 因此,您有一堆代码,并且想要在代码的某些部分上工作而不加载与其他部分相关的项目 Then yes, you can have each part as a separate visual studio solution . 是的,您可以将每个部分作为单独的Visual Studio 解决方案

Key point is that VS solution is just a [.sln] file describing which projects are grouped by this solution. 关键是VS解决方案只是[.sln]文件,用于描述该解决方案将哪些项目分组。 Don't make separate copies of projects for this purpose only. 不要仅为此目的单独制作项目副本。 You must maintain all projects just once (one copy for each), and then create separate solutions and include projects which you think are related to this solution (this part of the code). 您必须维护所有项目一次(每个副本一个),然后创建单独的解决方案,并包括您认为与该解决方案相关的项目(代码的这一部分)。

eg you might decide that "Employee Management" is a solution consisting of only 3 (out of whole bunch of 40) projects. 例如,您可能认为“雇员管理”是一个仅包含3个项目(总共40个项目)的解决方案。 Then you go ahead and create a solution which contains those three projects. 然后,继续创建包含这三个项目的解决方案。 Probably you will end up having separate smaller solutions which is convenient to work in separation from others. 可能最终您将获得单独的较小解决方案,这些解决方案很容易与其他解决方案分离。

You may as well consider having one big solution consisting of all projects in it (again, each project has only one instance, but can be a part of several solutions ). 您也可以考虑使用一个包含所有项目的大型解决方案(同样, 每个项目只有一个实例,但是可以成为多个解决方案的一部分 )。 This kind of big solution may be useful for major operations such as Build/Release preparation. 这种大解决方案可能对诸如构建/发布准备之类的主要操作很有用。

What I suspect is that you are trying to exaggerate the importance of a solution. 我怀疑您正在夸大解决方案的重要性。 In reality, all the code you have is one huge unity because they reference each other and cannot be built probably without [re-]compiling others. 实际上,您拥有的所有代码都是一个巨大的统一体,因为它们彼此引用,并且可能无法[重新]编译其他代码而无法构建。 Even though you may try to come up with the solution structure which somehow corresponds to your business needs, still it seems to be another direction of a problem which is not related to solutions. 尽管您可能尝试提出某种程度上与您的业务需求相对应的解决方案结构,但这似乎仍然是与解决方案无关的问题的另一个方向。 That may be something like solving a problem of dividing into assemblies, dynamic loading and extensibility, etc. 这可能类似于解决拆分程序集,动态加载和可扩展性等问题。

Conclusion: split code into solutions depending on the convenience you want to achieve when working with the source code, because that's simply dividing the source into sub-parts, nothing more. 结论:根据您在使用源代码时要获得的便利,将代码分为解决方案 ,因为这只是将源代码分为多个子部分,仅此而已。

EDIT/Addition: 编辑/添加:

You may as well decide to split the solution into independent solutions, but that's something different. 您也可以决定将解决方案分为独立的解决方案,但这是不同的。 That would mean the solution projects may only reference the output (dll, exe) files of other projects in other solutions. 这意味着解决方案项目只能引用其他解决方案中其他项目的输出(dll,exe)文件。 That could be done when each solution treats another just like a 3-rd party code (no direct project references, but only output referencing). 当每个解决方案都像第三方代码一样对待另一个解决方案时,可以做到这一点(没有直接的项目引用,而只有输出引用)。

I think when deciding if you should have multiple solutions, the answer is really do you envision one (or more) of the assemblies that make up your bounded context being used in other different applications, which will expose some of all of the exact same use cases your bounded context manages. 我认为,在决定是否应该有多个解决方案时,答案是真的要设想一个(或多个)组成有限上下文的程序集在其他不同应用程序中使用,这将公开所有完全相同的用法您的受限上下文管理的情况。 If that's the case, then a separate solution makes sense. 如果真是这样,那么一个单独的解决方案才有意义。 But if all your UI layers are conceptually the same application released at the same time, then I'd keep it in one solution, unless you have so many projects that Visual Studio becomes unusable. 但是,如果您的所有UI层在概念上都是在同一时间发布的同一应用程序,那么除非您有太多的项目使Visual Studio无法使用,否则我将其保留在一个解决方案中。

I'd be suprised though if you really are going to have another application making use of the same bounded context though. 但是,如果您真的要使用相同的有界上下文的另一个应用程序,我会感到惊讶。 If you think about it, would you ever want a newer version of the logic deployed ONLY to your web service, but not your windows forms application? 如果您考虑一下,您是否想只将逻辑的较新版本仅部署到Web服务,而不是Windows窗体应用程序? Probably not, as the logic changes may introduce odd problems where the data is not what one of the application expects. 可能不是,因为逻辑更改可能会带来奇怪的问题,即数据不是应用程序所期望的。

What you have sounds like a platform, and all pieces (UI layers) of that platform should be should be running the exact same logic. 您所听到的听起来像是一个平台,该平台的所有部分(UI层)都应该运行完全相同的逻辑。

the solution point of view is not the major problem I guess. 解决方案的观点不是我想的主要问题。 I would choose to organize my projects within folders. 我会选择在文件夹中组织我的项目。 One for each bounded context, and the web UI in another one (it could be thought as a bounded context of its own , if one thinks about it). 一个用于每个有界上下文,一个Web UI在另一个中(如果考虑的话,可以认为是它自己的一个有界上下文)。

You might have some shared kernel , shared by all your bc that you might put in a different folder too. 您可能拥有一些共享的内核,所有bc都共享了该内核,您也可能将其放置在另一个文件夹中。

Usually each bc should be independent ( except for the shared assemblies), and your UI should know only the bc through their interfaces (WCF contract for instance) 通常每个bc应该是独立的(共享程序集除外),并且您的UI应该仅通过其接口知道bc(例如WCF合同)

The global solution might contains every folder and the projects within (MyApplicationName.sln), but you could think of dedicated solution to work only on part of the solution, like MyApplication_BCName with only the bc folder, the shared assemblies and the UI if it fits your needs, and you do not want to have a huge solution to deal with. 全局解决方案可能包含(MyApplicationName.sln)中的每个文件夹和项目,但是您可以想到专用解决方案仅适用于该解决方案的一部分,例如MyApplication_BCName仅具有bc文件夹,共享程序集和UI(如果适用)您的需求,并且您不想拥有一个庞大的解决方案。

Start small, do things as soon as you really need them. 从小处着手,在您真正需要它们时立即做。 Be especially careful of the cross references, the way things are setup in vs is of no importance really. 特别要注意交叉引用,在vs中设置事物的方式实际上并不重要。 If assemblies are loosely coupled then you can rearrange them the way you want anytime later on. 如果装配松散耦合,则以后可以随时按需要重新排列它们。

I am not a first class programmer, I just happened to think that things like this seems to wok well for the latest projects I have been involved with, it might be completely changed in a couple of month (hours..?? ;) ) 我不是一流的程序员,我只是偶然地认为,对于我参与的最新项目,这样的事情似乎可以正常工作,它可能会在几个月(几小时内.. ????)中被完全改变。

暂无
暂无

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

相关问题 在Visual Studio 2013中的不同解决方案中调试多个项目 - Debugging Multiple Projects which are in different solutions in Visual Studio 2013 我可以同时使用Visual Studio for Mac打开两个解决方案吗? - Can I open two solutions with Visual Studio for Mac at the same time? 当我只想要一个时,Visual Studio就会提供多种解决方案 - Visual Studio is opening with multiple solutions when I only want one 在Visual Studio中调试多个解决方案 - Debugging multiple solutions in Visual Studio 确定解决方案配置(Visual Studio) - Determine Solutions Configuration (Visual Studio) 使Visual Studio在'='之前和之后做空格 - Make visual studio do spaces before and after '=' 我可以将在Visual Studio 2012中开发的C#Windows应用程序作为便携式应用程序制作吗? - Can I make an application made as a C# Windows Application developed in Visual Studio 2012 as a portable application? 我用C#开发了一个应用程序,是否可以在没有SQL Server和Visual Studio的另一台PC上运行该应用程序 - I developed an application in C#, is it possible to run this application on another PC which has no SQL Server and Visual Studio 使用NPOI时,应将哪些文件添加到C#中的Visual Studio中 - When using NPOI which files should I add to Visual Studio in C# 在C#中定义Visual Studio COM接口时,应该使用哪些类/方法/参数属性? - When defining a Visual Studio COM interface in C#, which class / method / parameter attributes should I use?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM