C#命名空间和组件最佳实践 [英] C# Namespaces and Assemblies Best Practice

查看:144
本文介绍了C#命名空间和组件最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C#:是否有任何指引,最佳实践,当涉及到分割的解决方案成名称空间和组件?应该命名空间通常被嵌套,在顶级域名空间的最低电平和基本类?如果有一般是一个名字空间的一个集会?是他们的陷阱有一个组件一个名字空间或多个名称空间的多个组件。是否有任何编译时/运行时间为多个组件或超大型装配处罚?


解决方案

C# :是否有任何指引,最佳实践,当涉及到分割的解决方案成名称空间和组件?




有关命名空间的指导方针,请阅读框架设计指南。



有关组件:一个组件被定义在.NET自描述可交付功能的最小独立单位进行版本控制。是否有你的软件,你打算出货或版本相互独立的部分?然后,他们应该在不同的组件。




如果名称在顶级域名空间通常被嵌套,最低的水平,基础类空间?




不一定,无



命名空间应该被设计为使得它为便于用户发现和了解包含在这些命名空间的类型。也许你应该问你的用户他们的想法。




如果有一般是一个名字空间的一个集会?




不一定,没有。




是他们的陷阱有一个组件一个名字空间或多个名称空间的多个组件。




没有什么特别,没有。




是否有任何编译时/运行时间为多个组件或超大型装配处罚?




这并不是说我知道的。


C#: are there any guidelines, best practices when it comes to dividing a solution up into name-spaces and assemblies? Should name spaces normally be nested, with the most low level and fundamental classes in the top level name space? Should there generally be one name-space to one assembly? Are their any pitfalls to having multiple assemblies in one name-space or multiple name-spaces in one assembly. Are there any compile time/ run time penalties for multiple assemblies or very large assemblies?

解决方案

C#: are there any guidelines, best practices when it comes to dividing a solution up into name-spaces and assemblies?

For guidelines for namespaces, read the framework design guidelines.

For assemblies: an assembly is by definition the smallest independently versionable unit of self-describing shippable functionality in .NET. Are there parts of your software that you intend to ship or version independently of each other? Then they should be in different assemblies.

Should name spaces normally be nested, with the most low level and fundamental classes in the top level name space?

Not necessarily, no.

Namespaces should be designed so that it is easy for users to discover and understand the types contained in those namespaces. Maybe you should ask your users what they think.

Should there generally be one name-space to one assembly?

Not necessarily, no.

Are their any pitfalls to having multiple assemblies in one name-space or multiple name-spaces in one assembly.

Not particularly, no.

Are there any compile time / run time penalties for multiple assemblies or very large assemblies?

Not that I'm aware of.

这篇关于C#命名空间和组件最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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