官术网_书友最值得收藏!

Having a single point of entry to the module

init.pp should be the single entry point for the module. In this way, someone reviewing the documentation in particular, as well as the code in init.pp, can have a complete overview of the module's behavior.

If you've used encapsulation effectively and used descriptive class names, you can get a very good sense just by looking at init.pp of how the module actually manages the software.

Modules that have configurable parameters should be configurable in a single way and in this single place. The only exception to this would be, for example, a module such as the Apache module, where one or more virtual directories are also configurable.

Ideally, you can use your module with a simple include statement, as follows:

include mymodule

You can also use it with the use of a class declaration, as follows:

class {'mymodule':
myparam => false,
}

The Apache virtual directory style of configuring a number of defined types would be the third way to use your new module:

mymodule::mydefine {‘define1':
myotherparam => false,
}

The anti-pattern to this recommendation would be to have a number of classes other than init.pp and your defined types with parameters expecting to be set.

主站蜘蛛池模板: 铁岭县| 株洲县| 永州市| 通辽市| 舞阳县| 威海市| 抚州市| 太康县| 阜平县| 广西| 堆龙德庆县| 合阳县| 汤阴县| 浮山县| 阳江市| 宣化县| 云梦县| 泾源县| 株洲市| 通州区| 崇明县| 衡东县| 道孚县| 东阿县| 阳春市| 仲巴县| 望都县| 石楼县| 海林市| 溧阳市| 无为县| 汉川市| 阳信县| 吴川市| 陆河县| 庆城县| 福海县| 红原县| 青龙| 吉隆县| 安龙县|