Home > Erlang-rules > 3.1尽可能地减少模块函数的导出

3.1尽可能地减少模块函数的导出

3 SW Engineering Principles
3.软件设计原则

SW:软件
Engineering :开发/设计
Principles:原则/法则

3.1 Export as few functions as possible from a module
3.1尽可能地减少模块函数的导出

Modules are the basic code structuring entity in Erlang. A module can contain a large number of functions but only functions which are included in the export list of the module can be called from outside the module.

structuring:组织
entity: 单个/单元

模块,是Erlang组织程序结构的最基本单元。一个模块可以包含大量的函数但是只有那些放在导出列表里的函数,可以在模块外部被其他模块调用。

Seen from the outside the complexity of a module depends upon the number of functions which are exported from the module. A module which exports one or two functions is usually easier to understand than a module which exports dozens of functions.

complexity:复杂性/复杂的事物
depend upon:依赖/取决于

seen from the outside:从表面上看
dozens of:几十/许多

从表面上看,一个模块的复杂程度,取决于其所导出的函数数量。一个只导出了一两个函数的模块,通常要比一个导出了几十个函数的模块好理解得多。

Modules where the ratio of exported/non-exported functions is low are desirable in that a user of the module only needs to understand the functionality of the functions which are exported from the module.

radio:比例
are desirable in :用…来描述

模块中已导出的函数与未导出的函数数量的比值比较小时,意味着该模块的使用者仅需要理解这个模块所导出的函数的功能即可。

In addition, the writer or maintainer of the code in the module can change the internal structure of the module in any appropriate manner provided the external interface remains unchanged.

In addition:另外
appropriate :适当地
manner :方式

另外,模块代码作者或维护者可以通过任何适当的方式改变内部设计,而提供给外部调用的的接口仍然保持不变。

POSTED ON 2010年08月10日, , ,

Leave a Reply

Trackbacks:0

Listed below are links to weblogs that reference
3.1尽可能地减少模块函数的导出 from Flexsns-关注富互联网
TOP