I2E: Putting a System Together
We have now studied the constituents of Eiffel software. It remains to see how you can combine these elements into executable systems (the Eiffel concept closest to the traditional notion of program) and libraries.
How do you get an executable system? All you need is to
- Provide a set of classes, called a universe.
- Designate one of these classes as the root class.
- Designate one of its creation procedures as the root procedure.
This defines what it means to execute the system: create one direct instance of the root class (the execution's root object); and call the root procedure on it. That's all.
In any practical case, the root procedure will create other objects, call other routines on them, leading to further creations and calls.
For the system to be valid, it must include all the classes which the root needs directly or indirectly; a class "needs" another if it is one of its heirs or clients.
For a library we don't need to specify a root. If we want to make sure that every class in a library compiles fine we can specify that we want all classes to be the root.
The Eiffel method suggests grouping related classes (typically 5 to 40 classes) into collections called clusters. A universe is then a set of clusters. For example the EiffelBase library is divided into clusters corresponding each to a major category of data structure:
iteration, and so on. You can nest clusters, using for example EiffelBase, with its own subclusters as listed, as a cluster of your system.
How will you specify a universe? Any Eiffel implementation can use its own conventions. EiffelStudio applies a simple policy:
- Store each class in a single file, called its class file, with a name of the form
e. For clarity,
nameshould be the lower-case version of the class name, although this is a style rule, not a requirement.
- Put all the class files of a cluster into a single directory (folder on Windows), called its cluster directory.
- To specify a system, it suffices to provide a list of cluster directories, along with the name of the root class and root procedure. The universe consists of the classes contained in all the class files in the listed cluster directories.
Such a system specification is written in an ecf (eiffel configuration file) which is an xml based file format. It can be created by using the project settings in EiffelStudio.