简体   繁体   English

Visual Studio大型解决方案

[英]Visual Studio Large Solution

I've got a solution for my webapplication with almost 12 projects and 3 websites. 我为我的Web应用程序提供了一个解决方案,其中包含近12个项目和3个网站。 There are some projects that I use for multiple websites like MyProject.BE / MyProject.BLL / MyProject.DAL / MyProject.Controls projects. 我有一些用于多个网站的项目,例如MyProject.BE / MyProject.BLL / MyProject.DAL / MyProject.Controls项目。

My question is, is it good to have multiple projects for BE/BLL/DAL/Controls, of is it better to create 1 project with folders for the BE/BLL/DAL layers? 我的问题是,为BE / BLL / DAL / Controls拥有多个项目是否很好,是否最好为BE / BLL / DAL层创建1个带有文件夹的项目?

The question of "large" is a relative one. “大”的问题是一个相对的问题。 In software development it is mostly a question of how good your PC is. 在软件开发中,主要是您的PC的性能问题。 If you can compile and run 100 projects in 1 second then 100 projects in a solution is "small". 如果您可以在一秒钟内编译并运行100个项目,那么解决方案中的100个项目将“很小”。 So it is really a question of what works for you. 因此,这实际上是一个对您有用的问题。

My current work solution has about 130 projects in it. 我当前的工作解决方案中包含约130个项目。 Yep, we could break it out but we have got some impressive boxes that can handle this so the cost of having 130 projects is moderate to low and advantages are bigger that the costs. 是的,我们可以突破,但是我们有一些令人印象深刻的盒子可以处理这个问题,因此拥有130个项目的成本适中至较低,而优势则要大于成本。

Having all of the projects in one solution is the go if you can compile, run, & test them all quickly. 如果您可以快速编译,运行和测试所有项目,则可以将所有项目都集成在一个解决方案中。 Darn ... that then starts the conversation onto what is "quick" and that is a style question. Darn ...然后开始对话,讨论“ quick”是什么,这是一个风格问题。 If you compile and run tests often (every minute or faster) then quick is seconds. 如果您经常(每分钟或更快)编译和运行测试,那么快速就是几秒钟。 If you compile and run every hour or so then minutes would be okay. 如果您每小时编译一次,那么几分钟就可以了。

Answer: "Do what works for you". 答:“做对您有用的事情”。

Note: Consider solution folders. 注意:考虑解决方案文件夹。

I think it is indeed better to have multiple projects. 我认为拥有多个项目确实更好。 If, for instance you need to build a WinForms UI that will use some of the existing classes in your BE and DAL layers all you need to do is reference those projects from the WinForms project. 例如,如果您需要构建一个WinForms UI,该UI将使用BE和DAL层中的某些现有类,那么您需要做的就是从WinForms项目中引用那些项目。

As far as I have understoodyour question, you are referring to how-to-organize-a-solution rather than how-do-I-make-compiling-the-code faster or how-to-make-VS-open-my-code-quicker, right? 据我了解您的问题,您指的是如何组织解决方案,而不是我如何更快地编写代码或如何使VS打开我的代码,代码查询器,对吗?

If so, I would say, break down your classes within the solution into multiple projects with names that make it clear what purpose they have. 如果是这样,我想说的是,将解决方案中的类分解为多个项目,这些项目的名称应清楚说明其目的。 You already started an approach like that with the "BE/BLL/DAL/Controls" example you gave. 您已经使用示例“ BE / BLL / DAL / Controls”开始了类似的方法。

Having designated project give you lots of flexibility for how your solution architecture. 指定项目可以为您的解决方案体系结构提供很大的灵活性。 Think about how much your solution may grow over time and for how long it may live in future. 考虑一下您的解决方案随着时间的推移会增长多少,以及未来可能会使用多长时间。 Think about how you will deploy it to the end users and - more importantly - how you will deploy updates. 考虑如何将其部署到最终用户,更重要的是,考虑如何部署更新。 All these considerations should influence your decision how far you will go into details. 所有这些考虑因素都将影响您做出详细决定的决策。

Analyse your code and check if there is potential to apply time-proven design patterns like Single Responsibility pattern. 分析您的代码,并检查是否有可能应用经过时间验证的设计模式,例如“单一职责”模式。

Is it a short-term short-lived tool that runs a few times during development and never again? 它是一种短期的,短期的工具,在开发过程中会运行几次,并且永远不会再次运行吗? Then it would not be worth much effort. 那就不值得付出很多努力了。 Is it a tool or application that will need to be maintained a few years? 它是需要维护几年的工具还是应用程序? Then go and make sue that the SRP pattern is carefully implemented. 然后,请确保已认真实施了SRP模式。

I recommend this book by Microsoft Press: Building Enterprise Applications with Windows Presentation Foundation and the Model View ViewModel Pattern 我推荐Microsoft出版社出版的这本书: 使用Windows Presentation Foundation和Model View ViewModel Pattern构建企业应用程序

This gives you some suggestions, recommendations and basics of how to build a good project structure. 这为您提供了有关如何构建良好的项目结构的一些建议,建议和基础。

Another suggestion of how a solution might be structured is in this SO thread: Mvvm Applications And location of Business layer 关于如何构造解决方案的另一个建议是在以下SO线程中: Mvvm应用程序和业务层的位置

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

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