如何在VS 2005中组织代码? [英] How to organize code in VS 2005?

查看:127
本文介绍了如何在VS 2005中组织代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢您对先前问题的答复.
我需要咨询您出色的团队,以解决有关项目中代码组织的另一个问题.

实际上,我来自Java Background,在J2EE中,程序包名称和代码文件紧密集成在一起,但是在VS 2005中,我无法获得相同的代码和文件名配置,从而导致代码管理过于复杂.为了说明这种情况,我们在项目中主要有五个实体.这些实体中的每一个都有各种模块,例如Bussiness Object(类似于Java中的POJO的POCO),DataAccess Objects,UI层以及最后的报告模块.在Java中,我们曾经为POJO制作了com.radiant.domain.pojo之类的东西.同样,UI的com.radiant.domain.view等等...但是在VS 2005中我无法获得等效的表单.这在项目中造成了某种混乱.
你能给我些解脱吗?
提前谢谢.
-Satyam

Thanx for the reply of earlier question.
I need to consult your fabulous team for yet another question regarding the code organization in the project.

Actually, I''m from the Java Background, in J2EE, package name and code file are tightly integrated but in VS 2005, i can''t get the same conformation of code and file name which led to too much complexity in code management. To illustrate the case, we have mainly five entities in the project. Each of these entity has various modules like Bussiness Object(POCO just like POJO in Java),DataAccess Objects, UI layer and finally reporting modules. In java we used to make something like com.radiant.domain.pojo for POJO. Similarly, com.radiant.domain.view for UI and so on....But i can''t get the equivalent form in VS 2005. This causing a kindda chaos in the project.
Can u please provide some kind of relief?
Thanks in advance.
-Satyam

推荐答案

另一种方法-解决方案中有多个项目-每个项目都映射到dll(数据层,业务层等).

我看过一些Visual Studio和Eclipse项目,发现它们都可以具有非常相似的结构-因此,我不确定我是否正确理解了您的问题.
Another way - you have multiple projects in a solution - each project maps to a dll (data layer, business layer etc).

I''ve had a look at some Visual studio and Eclipse projects and have noticed both can have very similar structures - so I''m not quite sure I understand your question correctly.


您可以使用名称空间,也可以嵌套名称空间.您可以创建文件夹以将文件(或文件夹)组织到其中.如果愿意,可以使用整个名称空间和类名称来命名文件.您可以嵌套类,也可以将嵌套的类拆分为一个单独的文件(由于使用了部分类).您可以将文件嵌套在其他文件下(但是您必须在记事本中修改.CSPROJ文件).您可以在各种项目之间拆分代码(这些项目都组合成一个解决方案).您也可以将项目放在文件夹中.您可以将某些类设为私有(如果它们是嵌套的)或内部的,这样在使用Intellisense时它们不会出现.您还可以使用对Intellisense隐藏它们的属性来标记类的某些成员.

如您所见,使用Visual Studio(可能还有C#)时,有很多选项可以组织代码.如果您使用的是C ++,尽管我不知道Microsoft是否在C ++中添加了部分类的概念,但您的选择基本相同.哎呀,您甚至可以将C ++,VB和C#放在一个单独的项目中,从而将它们组合在一起.
You can use namespaces, and you can nest namespaces. You can create folders to organize files (or folders) into. You can name files with the entire namespace and class name if you like. You can nest classes and you can split out the nested class into a separate file (thanks to partial classes). You can nest files under other files (but you have to modify the .CSPROJ file in Notepad in order to do that). You can split code between various projects (that are all combined into a single solution). You can also put projects in folders. You can make some classes private (if they are nested) or internal so that they do not show up when using Intellisense. You can also mark certain members of a class with attributes that hide them from Intellisense.

As you can see, there are a whole bunch of options for organizing your code when using Visual Studio (and, presumably, C#). If you are using C++, your options are mostly the same, although I don''t know if Microsoft added the concept of partial classes to C++. Heck, you can even combine C++, VB, and C# in a single solution by putting them in separate projects.


在C#中,我们有
In c# we have namespaces.

The tag for the question you''ve posted here is incorrect.


这篇关于如何在VS 2005中组织代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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