如何在visual studio中重构大型项目 [英] How to refactor large projects in visual studio

查看:37
本文介绍了如何在visual studio中重构大型项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我总是遇到一个问题,即我在 Visual Studio (2008) 中的项目变成了巨大的怪物,并且所有东西通常都被投入到 Web 应用程序项目中.我从查看一些开源内容中了解到,他们往往在一个解决方案中有多个项目,每个项目都有自己的职责.

I always run into a problem where my projects in Visual Studio (2008) become huge monstrosities and everything is generally thrown into a Web Application project. I know from checking out some open source stuff that they tend to have multiple projects within a solution, each with their own responsibilities.

有人对如何重构它有任何建议吗?单独的项目与 Web 项目的一部分应该是什么?你能给我指点关于这个主题的任何参考资料,还是只是你随着时间的推移而习惯的?

Does anyone have any advice for how to refactor this out? What should be in a separate project vs. part of the web project? Can you point me to any reference materials on the subject, or is it just something you become accustomed to with time?

推荐答案

将您的项目干净利落地组织到命名空间中.命名空间不能太大,也不能太小.使每个命名空间都有一个公共接口"(即一组公共类),并且不要从其他命名空间访问该命名空间的内部实现细节.不同的命名空间通常处理应用程序的不同部分,例如您将拥有与 UI、业务逻辑、帮助程序功能等相关的命名空间.框架设计指南 对如何设计命名空间有一些很好的建议.

Organize your project cleanly into namespaces. Namespaces should not be too big, not too small. Make each namespace have a public "interface" (i.e. a set of public classes) and don't access internal implementation details of the namespace from other namespaces. Different namespaces usually address different parts of an application, e.g. you'll have namespaces related to UI, business logic, helper functionality, etc. The Framework Design Guidelines have some good suggestions how to design namespaces.

当您觉得您的项目变得太大时,只需确定彼此明显相关的命名空间集并将它们移至单独的项目.由于其他命名空间已经只是使用了移动命名空间的公共接口,因此将命名空间重构为新项目只是一个文件移动操作.

When you feel that your project grows too large, simply identify sets of namespaces that are clearly related to each other and move them to separate projects. Since other namespaces already just use the public interface of the moved namespaces, refactoring the namespaces into new projects is merely a file-move-operation.

这篇关于如何在visual studio中重构大型项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆