Package and Library Structuring

1 General Description

A well-designed package structure is one of the most important aspects that influences the complexity, comprehension, and maintainability of large software systems. There are many factors to consider when designing a package, for example the name of the package or the structuring the package into subpackages. Other factors that are important to consider are reusability and encapsulation of the package as well as considering dependencies on other packages.


2 Subpackages and Hierarchical Libraries

The main use of Modelica packages and subpackages is to structure hierarchical model libraries, of which the standard Modelica library is a good example. Below is a small example of a hierarchical package structure which has been extracted and adapted from the Modelica standard library.

The example is a bit misleading since these packages are quite large, normally stored on separate files and directories, and not seen as a piece of code below. See the comments for the fully qualified names of each package or model component.




Public components in hierchical libraries can be accessed through their fully qualified name. See model InertiaUser below.



2.1 Encapsulated Packages and Classes

As emphasized before, the useage of the word "encapsulated" before a package name is good for eliminating the possibility of implicit dependences. However, sometimes it is useful to have encapsulated models where there is no danger of implicit dependences, e.g. application examples that are intended to be self consistent and might be sent around to other users and developers.