Libraries
Contents
General
What is a library?
A library is a collection of functionality that is exported by an interface. The implementation of the library is not exported so that the library can be changed without affecting users of the library as long as the interface is compatible.
What is in a library?
A library has classes that are available to users and may also have classes that are only in the library for implementation purposes and are therefore not available to the user of the library. A library normally also has dependencies on other libraries and may have externals and pre/post compile tasks. It is also possible to specify several options for the use of a library. E.g. it is possible to disable warnings or set a certain assertion level.
Name clashes and conflicts
As libraries are designed and created independent of each other it is possible that two libraries have classes in them which have the same name. As long as the classes with the name clash are only in the implementation part of the library (and therefore not exported) the user of the library does not have to do anything as there is no conflict for him. If the name clash is in the interface part of the two libraries the user of the libraries has to deal with them. There are several possible solutions.
Prefixing
He can prefix one (or both of the libraries) in his system.
Renaming
Renaming is very similar to Prefixing, the only difference is that instead of adding a prefix to all classes, only one (or a few) classes receive a different name.
Explicit dependencies
In some situations it is also possible to solve the conflict by explicitly specifying the dependencies. For instance if library A is only used in Cluster my_cluster and Library B is only used in Cluster my_other_cluster. In this case we can specify that cluster my_cluster only depends on library A (and base) and cluster my_other_cluster only depends on library B (and base).
Testing and Debugging of a library
It is possible to add testing and debugging code to a library by adding additional targets (that inherit from the library target). This targets can then be used to debug and test the library and make the library a fully self contained component.
Examples
EiffelBase
EiffelBase is the most often used library as almost every system and library uses it. Base consists of one recursive cluster which is exported. In .NET mode base also uses some assemblies for its implementation (of which the contents are not exported). Base does not have any externals or dependencies on other libraries.
Graphic
A platform independent graphic library could look something like this: One exported interface cluster that describes the interface of this library. One not exported implementation cluster for each supported platform. For example on windows this implementation could make use of the WEL library and on Macintosh it could do all the implementation directly and may use C externals. There could also be a target that builds a sample application with to debug various things of the library. One additional target could also build a system that uses and tests all available graphical elements of the library. The developer of the library can use the addition targets for testing and debugging, the user of the library would not know about them and would also not know about the implementation clusters.