📄 eiffel.txt
字号:
Steps to Generate Eiffel Code Using With Class CASE Tool
The purpose of this paper is to describe how to generate Eiffel code from class diagrams, state diagrams, and object interaction diagrams. These scripts are "getting started" scripts that must be updated for your development environment.
These scripts are "getting started" scripts that must be updated for your development environment.
1. Generating Eiffel from Class Diagrams
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.
These scripts are "getting started" scripts that must be updated for your development environment.
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.
- Creating Classes - Ensure that you enter compilable Eiffel in the text specification boxes. Enter the Eiffel keywords for variant, require, ensure, rescue, etc.
- 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.
- 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.
2. Generating Eiffel from State Diagrams - Must update for Eiffel
State Diagram: DEL1STA.OMT and DEL2STA.OMT for Pascal
Script Files: DELSTAT1.SCT and DELSTAT2.SCT create Pascal classes - Update for Eiffel.
Main File: Update to invoke "process (turnOn)" and "process (turnOff)".
The following are the general steps to test out the Eiffel code generation scripts:
- Create a directory for the state .omt files, script files, and Eiffel files, e.g. WCSTATE.
- Copy the appropriate files into each directory, e.g. copy st*.*.
- In With Class open a state diagram, e.g. DEL1STAT.OMT.
- Select "Utilities - Generate State Code/Report" to generate a text report. Enter a report file name, e.g. RPTSTATE.TXT. Select a state report script, e.g. RPTSTATE.SCT, DDSTATE.SCT, or TABSTATE.SCT. After report generation, select "File - Edit File" to examine the generated report.
- Select "Utilities - Generate State Code/Report" to generate Eiffel code.
- Enter the file name, e.g. CONTROLS.E
- Select the code generation script, e.g. DELSTAT1.SCT or DELSTAT2.SCT - must update for Eiffel.
- Select "Edit - Edit File" and open CONTROLS.E for review.
- In your Eiffel environment, create a project.
- Compile and run the program.
- Go back to With Class and update the state diagram with new states, events, conditions, and actions and repeat the entire process.
3. Eiffel - Creating Message Sequence Tables from Object Interaction Diagrams
Object Interaction Diagram: CAROBJ.OMT
Script File: TABOBMSG.SCT
The following are the general steps to generate the message sequence table and then update ANSI Ada code with messages.
- Open the object interaction diagram, e.g. CAROBJ.OMT.
- Select "Utilities - Generate Object Code/Report".
- Enter a report name, e.g. TABMSG.TXT.
- Browse and select the message sequence table script, e.g. TABOBMSG.SCT to generate the message sequence table.
- Cut and paste messages from the message sequence table into you ANSI Eiffel code.
- As required update the object interaction diagram and the message sequence script (TABOBMSG.SCT) and repeat the process.
4. I request your recommended changes to these Eiffel code generation scripts. Question - What additional With Class script variables or additional dialog boxes, text boxes, or check boxes are required to fully support Eiffel. Please submit new Eiffel scripts. Request comments and improvements scripts: Richard Felsinger 960 Scottland Dr, Mt Pleasant, SC 29464 e-mail 71162.755@compuserve.com telephone 803-881-3648.
5. Many thanks, Richard Felsinger, RCF Associates, 960 Scottland Dr, Mt Pleasant, SC 29464 803-881-3648 (voice and fax)
71162.755@compuserve.com
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -