-14a - The method Principles in the Eiffel method
Abstraction Information hiding Seamlessness Reversibility Design by Contract Open-Closed principle Single choice principle Single model principle Uniform access principle Command-query separation principle Option-operand separation principle Style matters Principles in the Eiffel method
Abstraction Information hiding Seamlessness Reversibility Design by Contract Open-Closed principle Single choice principle Single model principle Uniform access principle Command-query separation principle Option-operand separation principle Style matters Abstraction: an object as machine
start item index forth put_right before after A list
before after
item
“Iowa" 1 count Cursor back forth
start finish
index Principles in the Eiffel method
Abstraction Information hiding Seamlessness Reversibility Design by Contract Open-Closed principle Single choice principle Single model principle Uniform access principle Command-query separation principle Option-operand separation principle Style matters An object is a machine An object has an interface
start item index forth put_right before after An object has an implementation
start item index forth put_right before after Information hiding
start item index forth put_right before after Principles in the Eiffel method
Abstraction Information hiding Seamlessness Reversibility Design by Contract Open-Closed principle Single choice principle Single model principle Uniform access principle Command-query separation principle Option-operand separation principle Style matters Seamlessness
Use single notation and set of tools throughout the process Principle: Text-graphics equivalence At the source of object technology
Kristen Nygaard (Oslo, 1967)
To program is to understand Principles in the Eiffel method
Abstraction Information hiding Seamlessness Reversibility Design by Contract Open-Closed principle Single choice principle Single model principle Uniform access principle Command-query separation principle Option-operand separation principle Style matters Reversibility
S S
D I
V
G Principles in the Eiffel method
Abstraction Information hiding Seamlessness Reversibility Design by Contract Open-Closed principle Single choice principle Single model principle Uniform access principle Command-query separation principle Option-operand separation principle Style matters Principles in the Eiffel method
Abstraction Information hiding Seamlessness Reversibility Design by Contract Open-Closed principle Single choice principle Single model principle Uniform access principle Command-query separation principle Option-operand separation principle Style matters Principles in the Eiffel method
Abstraction Information hiding Seamlessness Reversibility Design by Contract Open-Closed principle Single choice principle Single model principle Uniform access principle Command-query separation principle Option-operand separation principle Style matters Principles in the Eiffel method
Abstraction Information hiding Seamlessness Reversibility Design by Contract Open-Closed principle Single choice principle Single model principle Uniform access principle Command-query separation principle Option-operand separation principle Style matters Single-model principle
All the information about a system should be in the system‘s text
Automatic tools extract various views:
¾ Interface ¾ Implementation ¾ Inheritance structure ¾ Client-supplier structure ¾ Operations (features) ¾ etc. Principles in the Eiffel method
Abstraction Information hiding Seamlessness Reversibility Design by Contract Open-Closed principle Single choice principle Single model principle Uniform access principle Command-query separation principle Option-operand separation principle Style matters Uniform access principle
It doesn‘t matter to the client whether you look up or compute
A call such as
ibm_company.yearly_average
could use an attribute or a function Uniform Access yearly_average = valuations_over_year.average
(A1) valuations_over_year
valuations_over_year (A2) yearly_average Principles in the Eiffel method
Abstraction Information hiding Seamlessness Reversibility Design by Contract Open-Closed principle Single choice principle Single model principle Uniform access principle Command-query separation principle Option-operand separation principle Style matters Command-query separation
Asking a question shouldn‘t change the answer! Principles in the Eiffel method
Abstraction Information hiding Seamlessness Reversibility Design by Contract Open-Closed principle Single choice principle Single model principle Uniform access principle Command-query separation principle Option-operand separation principle Style matters Principles in the Eiffel method
Abstraction Information hiding Seamlessness Reversibility Design by Contract Open-Closed principle Single choice principle Single model principle Uniform access principle Command-query separation principle Option-operand separation principle Style matters -14b - Conclusion Eiffel
Method
Language
Environment
Component libraries
Quality-centered culture The next step: Trusted Components
Reusable components with guaranteed properties and guaranteed quality
¾ Low road: Component Quality Model, Component Certification Center
¾ High road: Components with correctness proofs Gustave Eiffel, 1885
Must it be assumed that because we are engineers beauty is not our concern, and that while we make our constructions robust and durable we do not also strive to make them elegant?
Is it not true that the genuine conditions of strength always comply with the secret conditions of harmony?
The first principle of architectural esthetics is that the essential lines of a monument must be determined by a perfect adaptation to its purpose. Gustave Eiffel, 1887 From his response in Le Temps to a petition by members of the literary and artistic Establishment protesting his project of elevating a tower of iron in Paris Summary
Bring every one of your development days to the level of your best days -14c - Supplements Concurrency: the SCOOP model
General-purpose Multi-threading, Web services, distribution, multiprogramming... Simplifies concurrent programming Based on Design by Contract ideas From C/C++ into Eiffel
CECIL library (C-Eiffel Common Interface Library) From C: create objects, call features on them
Watch out: the Eiffel Garbage Collector moves objects! CECIL example: object creation
#include eif_setup.h" #include "eif_eiffel.h“ main (int argc,char **argv,char **envp) {EIF_TYPE_ID tid; EIF_OBJECT my_obj; EIF_INITIALIZE(failure) /* Eiffel runtime initialization*/ tid = eif_type_id ("OBJECT"); if (tid == EIF_NO_TYPE) eif_panic ("No type id."); my_obj = eif_create (tid); Deregister ... Code using my_obj ... from GC! eif_wean (my_obj); /* When no longer needed */ EIF_DISPOSE_ALL /* Reclaim Eiffel memory */ } Cecil example: calling a feature
Cecil equivalent of Eiffel code c1.copy (c2) with c1,c2: MY_TYPE
EIF_OBJECT c1, c2; EIF_PROCEDURE ep; EIF_TYPE_ID tid; ... tid = eif_type_id (“MY_TYPE"); ep = eif_procedure ("copy", tid); (ep) (eif_access(c1), eif_access(c2)); } Cecil: adopting Eiffel objects
If you are going to need an Eiffel object obj after the current function has returned, call
my_obj = eif_adopt (obj);
then use my_obj (through eif_access) rather than obj.
When done:
eif_wean (my_obj); References
Object-Oriented Software Construction, 2nd edition Prentice Hall, 1997
Eiffel: The Language Prentice Hall, 1992
http://www.eiffel.com