../../_images/Revised.png

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
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
        ...
        <external_libraries>
            <external_library>
                name="lib1"
                <path></path>
                <code_instruction_folder></code_instruction_folder>
                <snippets_folder></snippets_folder>
                <features_folder></features_folder>
                <function_library></function_library>
            </externalLibrary>

            <external_library name="lib2">
                <path></path>
                <code_instruction_folder></code_instruction_folder>
                <snippets_folder></snippets_folder>
            </external_library>
        </external_libraries>

        ...
</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