Eiffel Home Page (Web) -- Getting started with Eiffel (local) Eiffel Home PageEiffel Home Page

Previous, UpPrevious sectionUp

14 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

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.

We can generalize these notions to encompass a library rather than an executable system, by accepting NONE as root class. Since NONE inherits from all other classes, it needs all the classes in the universe; compiling with NONE as root will compile all classes. In this case you don't specify a root procedure, and the result is not executable.

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: lists , tables , 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:

It is desirable for clarity, as a style rule, to separate clusters that directly contain classes ("terminal clusters") from those that have subclusters. Cluster directories will then contain class files or cluster subdirectories, but not both.

Here is an example of such a system specification. It's not written in Eiffel, although it definitely has an Eiffel-like flavor. It is called an Ace (Assembly of Classes in Eiffel) and written in the Eiffel-like Lace notation (Language for the Assembly of Classes in Eiffel). The backward slash \ is the Windows path separator; Unix uses a forward slash / for the same purpose (EiffelStudio will accept both on Windows).

With EiffelStudio you don't have to write the Ace yourself; just specify the information interactively through the Preferences dialog and EiffelStudio will generate the Ace. You can also reuse and adapt one of the many example Aces in the delivery.

So you don't need to learn the syntax of Lace, although as the example shows it is straightforward. The Ace first gives the system a name, example , which will also serve as the name of the generated executable. It then specifies the root class, its cluster (optional), and the root procedure. Next, in the default clause, come compilation options; you can specify assertion monitoring, with choices that include none , require (preconditions only, the default), ensure (preconditions and postconditions, as here) and invariant (the previous two plus class invariants). You can also specify various levels of assertion monitoring separately for a cluster, or for a specific class. The precompiled option specifies use of a precompiled library, EiffelBase, at the path given. The Ace ends with a list of clusters, other than those of EiffelBase, specifying for a cluster name, such as my_cluster1 , and the directory where it resides.

The path names in this example use the Windows path separator, a backward slash \ . Unix uses a forward slash / (also acceptable on Windows) for the same purpose.

This Ace is from an example in the delivery. If you compile and execute it, it will create an instance of class CALCULATOR and call its make procedure. This starts a small interactive calculator, illustrating some of the simple mechanisms of EiffelBase.

Previous, UpPrevious sectionUp

Eiffel Home Page (Web) -- Getting started with Eiffel (local)