从Delphi XE2开始,建议为作用域单位命名是什么? [英] What is the recommended naming for scoped units in Delphi XE2 onwards?

查看:85
本文介绍了从Delphi XE2开始,建议为作用域单位命名是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着Delphi XE2的出现,诸如Xml.Internal.AdomCore_4_3System.StrUtils的作用域单位出现了.

With the advent of Delphi XE2 scoped units like Xml.Internal.AdomCore_4_3 or System.StrUtils came in fashion.

我喜欢使用这种描述性名称的功能,但是我对什么是命名约定和首选目录结构感到困惑.

I like the ability to use such descriptive names but I am puzzled what are the naming conventions and preffered directory structure.

  1. 应该是

  1. Should it be

  • com.company.project.Security.Compression.ZLib.pas就像Java中的

System.Security.Compression.ZLib.pas就像.NET中一样

还是其他?

我应该将文件放置在这样的目录结构中吗

Should I place my files in a directory strcuture like this

  • System\Security\Compression\System.Security.Compression.ZLib.pas

还是根文件夹中的System.Security.Compression.ZLib.pas?

看看Embarcadero组织单位的方式,给我留下的印象是,他们只是保留了Delphi 5/6/7/.../XE中的目录结构

Looking at the way Embarcadero organized their units I am left with the impression that they simply kept the directory structure as in Delphi 5/6/7/.../XE

请告知.

推荐答案

我相信每个人都应该确定自己的单位范围. (仅当您是第三方组件供应商时,您才需要这样做-因为您想减少所使用的任何外部单元上的名称冲突.)通过对单元进行范围界定,您将有很长的路要走,以防止单元命名.问题.

I believe that everyone should be scoping their units. (You don't need to do this only if you are a 3rd party component vendor - as you want to reduce name collision on any external units that you utilize.) By scoping your units you are going a very long way to prevent unit naming issues.

我强烈建议您为所有内部创建的单位使用一个全局前缀.您可以使用公司名称的缩写形式,也可以使用全名作为您的首选项.我会推荐一些简单易读的东西.

I'd strongly suggest a global prefix that you will use for all internally-created units. You can use an abbreviated form of your company name, or your full name as its totally your preference. I would recommend simply something readable and easy to type.

如果您处理几个主要项目,则将使用特定于项目的名称,例如Widgets产品/项目的Acme.Widgets.SlicerUtils.pas和Wonkers产品的Acme.Wonkers.WippleFactory.pas.

If you work in a handful of major projects, then project-specific names would follow such as Acme.Widgets.SlicerUtils.pas for the Widgets product/project and Acme.Wonkers.WippleFactory.pas for the Wonkers product.

无论命名如何,这都应与项目版本化和管理源代码的方式密切相关.您希望能够轻松地为Widgets项目的1.2.1.0版设置构建,以包括与该特定构建相关的所有单元. (1.2.1.0窗口小部件可能包括系统库的显式修订版1.5.3.0)所有开发人员都必须易于理解并且对其进行过合理的管理.您应该希望单击操作即可开始Widgets项目的1.2.1.1.

Regardless of the naming, this should strongly correlate to how you versionize your projects and manage your source code. You want to be able to easily setup a build for version 1.2.1.0 of the Widgets project to include all the units related to that specific build. (1.2.1.0 Widgets may include an explicit revision 1.5.3.0 of the System library) This needs to be easily understood by all developers and seemlessly managed. You should desire one-click operations to begin work on 1.2.1.1 of the Widgets project.

一般规则会回答子目录问题,以将版本控制的项目分成各自的子目录.因此,如果您的Acme.System.Security.Compression库与Acme.System.Security.Auth分别受版本控制,那么您将具有root \ System \ Compression子目录结构...但是您更有可能仅拥有Acme. Widgets.System)

The subdirectory question is answered by the general rule to separate version-controlled projects into their own sub directories. So if your Acme.System.Security.Compression library is version controlled separately than Acme.System.Security.Auth, then you'll have a root\System\Compression subdirectory structure...but more likely you'll simply have Acme.Widgets.System)

希望这会有所帮助.

这篇关于从Delphi XE2开始,建议为作用域单位命名是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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