你如何组织的C#代码中的文件吗? [英] How do you organize C# code in to files?

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

问题描述

在C#中,创造什么类型的问题,他们应该有什么样的成员,什么命名空间应该追究他们,是面向对象设计的问题。他们不是我感兴趣的这里的问题。

In C#, the questions of what types to create, what members they should have, and what namespaces should hold them, are questions of OO design. They are not the questions I'm interested in here.

相反,我要问你是如何存储这些磁盘文物。下面是一些例子规则:

Instead, I want to ask how you store these in disk artifacts. Here are some example rules:


  • 把所有程序集的类型的一个源文件。谁做了这方面的一个朋友说:文件是一个阿尔希阿克代码组织的工具,今天我用ClassView中和关闭,以定义浏览我的代码。

  • Put all of an assembly's types in a single source file. One friend who did this said "files are an archiac code organization tool; today I use classview and Collapse to Definitions to browse my code".

把所有的代码在一个集会。使部署和放大器;版本简单。

Put all your code in one assembly. Makes deployment & versioning simpler.

目录结构反映了命名空间结构。

Directory structure reflects namespace structure.

每个空间都有自己的组装。

Each namespace gets its own assembly.

每个类型的云在自己组装。 (列为一个极端的例子。)

Each type goes in its own assembly. (Listed as an extreme example.)

每个类型都有自己的源文件。

Each type gets its own source file.

每个成员都有自己的文件;每种类型都有自己的目录。 (列为一个极端的例子。)

Each member gets its own file; each type gets its own directory. (Listed as an extreme example.)

推荐答案

不管你做什么,只是请始终做到这一点。我不相信有任何一个单一的答案(虽然有一些错误的)。但是,只要确保你忠于你的形式,这将是你的继任者(S)很容易找东西的关键。

Whatever you do, just PLEASE do it consistently. I don't believe there is any one single answer (though there are a few wrong ones). But just make sure you stay true to your form as this will be the key for your successor(s) to find things easily.

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

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