5.4.2.7. External libraries

Writing code instructions is all about abstraction: no specifics should be included to make that one piece of code instructions is suitable for multiple entities. Since you’ve decided to go down this road anyway, then why not take it one step further by reusing your code instructions between projects? You can create an external library of code instructions and use that for multiple projects. Consequently refactoring and introducing new functionality in all projects only requires a single change in code instructions. After that, just generate all project files again and you’ll be fully up to date.

Configure an external library

An external library should always have a unique name by which attributes can be determined.

The element external_libraries is a collection of one or more external_library elements. Here is an example of using 2 external libraries:

Listing 5.36 <external libraries/> example
 1        ...
 2        <external_libraries>
 3            <external_library>
 4                name="lib1"
 5                <path></path>
 6                <code_instruction_folder></code_instruction_folder>
 7                <snippets_folder></snippets_folder>
 8                <features_folder></features_folder>
 9                <function_library></function_library>
10            </externalLibrary>
11
12            <external_library name="lib2">
13                <path></path>
14                <code_instruction_folder></code_instruction_folder>
15                <snippets_folder></snippets_folder>
16            </external_library>
17        </external_libraries>
18
19        ...
20</pattern>

We recommend to use a version control system to contain only the library and nothing else, so that you can safely use it with multiple projects.

Attributes

Table 5.45 attributes of <external_library/>

Name

Details

name

Name of the library: required

Sub elements

Table 5.46 sub elements of <external_librariy/>

Name

Details

Number

path

The path tag contains the absolute path to a folder.

1

code_instruction_folder

The code_instruction_folder tag contains the relative path to the code instructions

0 or 1

snippets_folder

The snippetsFolder tag contains the relative path to the snippets

0 or 1

features_folder

Question S

0 or 1

function_library

Question S

0 or more