Steps to Generate Eiffel Code Using With Class CASE Tool
by Richard Felsinger, RCF Associates, 960 Scottland Dr,
Mt Pleasant, SC 29464 803-881-3648 (voice and fax) 
71162.755@compuserve.com

The With Class CASE tool provides the capability to create object-oriented diagrams, specifications, and reports.  With Class has a script language to create code generation scripts for various languages such as Eiffel.  The following are the steps to create diagrams, specifications, and Eiffel code.

Step 1: Customize With Class for Eiffel - Familiarize yourself with the With Class CASE tool. When With Class is not running update the wc2.ini for the basic Eiffel types and defaults as follows:
[TYPES] Type1=INTEGER, Type2=REAL, Type3=DOUBLE, Type4=BOOLEAN, Type5=CHARACTER, Type6=STRING, Type7=ARRAY,
[DEFAULTS] Type=INTEGER, ReturnType=    .  Replace the C++ types with Eiffel types.  This is to customize With Class for Eiffel.

Step 2: Create the Class Diagram - In With Class, create a class diagram using the Rumbaugh OMT or other O-O diagram notation.  Create several classes, enter the class name, attribute names, operation (routine) names for each class.  Connect the classes with a relation for inheritance, aggregation, and association.  For the aggregation and association relationships, enter a traversal path name.

Step 3: Create the Specifications - In With Class, create the class, attribute, and operation specifications with Eiffel specific information.  In the class specification enter the following:
-CLASS_USER1 - enter deferred if the class is an abstract class, e.g. deferred or enter Indexing statements,
-CLASS_USER2 - enter the generic type if the class is a generic class, e.g. [T],
-CLASS_USER3 - enter the inherit clause for a single superclass, e.g. deferred  rename  select.
-CLASS_INVARIANT - enter the complete invariant statements, e.g. invariant okGasQuantity: gasQuantity >= 0
You must enter compilabe Eiffel statements into -CLASS_USER1, -CLASS_USER2, -CLASS_USER3, -CLASS_INVARIANT.
-CLASS_LIBRARY_BASE_CLASS - enter the library superclass, e.g. STORABLE
If the class only has a library superclass enter following: inherit STORABLE 

In the attribute specification, enter the attribute type as an Eiffel type: BOOLEAN, CHARACTER, INTEGER, REAL, DOUBLE,
ARRAY, STRING.

In the operation specification, enter the following:
- enter operation parameters in the form operation_type operation_name, e.g. INTEGER aNumber.  Then use the keyword -PASCAL_OPERATION_PARAMETERS to print the parameters in Eiffel form.
- enter a valid Eiffel type or class in -OPERATION_RETURN_TYPE (remove default void)
- enter one of the following in -OPERATION_TRANSFORMATION: do, deferred, or external.
- enter a precondition in -OPERATION_PRECONDITION including require, e.g.  require okSpeed: aSpeed < 99
- enter a postcondition in -OPERATION_POSTCONDITION including ensure, e.g. ensure okNewSpeed: equal (speed, aSpeed)
- enter a rescue in -OPERATION_EXCEPTION_NAME including rescue, e.g.  rescue speed := 0

Step 4: Generate Eiffel Code - In With Class generate Eiffel code based upon the class diagram and specifications.  Select the Eiffel code generation script, e.g. EIFFEL1.SCT.

Step 5: In your Eiffel environment, create the ACE file and the system class.  You must manually update the generated code as follows:
- for deferred classes manually delete the generated creation clause and creation routines
- if a class has multiple superclasses, manually update the inherit clause to ensure redefined routines are with the correct superclass
- for objects of generic classes, manually enter the actual generic parameter in the variable declaration, e.g.   myCollection: GENERIC_COLLECTION[INTEGER]
- manually update the feature export, e.g. feature {TRIANGLE}
- manually enter unique constants, e.g. red, yellow, blue : INTEGER is unique 

The following are several guidelines to use With Class to generate Eiffel code.

1.  Creating Classes - Ensure that you enter compilable Eiffel in the text specification boxes.  Enter the Eiffel keywords for variant, require, ensure, rescue, etc.

2.  Creating Abstract Classes - Put "Abstract Class" as text next to each abstract class on the class diagram.  Enter deferred in the class specification user 1 box.  Enter deferred in the operation transformation box.  In the subclass enter the deferred statement, e.g. deferred registerOperation.  After you generate code, you must delete the generated creation statements and routines.

3.  Creating Generic Classes - On the class diagram enter the generic class name without the generic formal parameter.  Put the generic formal parameter as text next to the class on the class diagram.  In the class specification enter the generic formal parameter in the user 2 box, e.g. [T].  

The Eiffel scripts provided in With Class provides a starting point to create enhanced Eiffel code generation scripts.

