Presentation is loading. Please wait.

Presentation is loading. Please wait.

Eiffel Naeem Esfahani University of Tehran "Man cannot discover new oceans unless he has the courage to lose sight of the shore." -- Andre Gide.

Similar presentations


Presentation on theme: "Eiffel Naeem Esfahani University of Tehran "Man cannot discover new oceans unless he has the courage to lose sight of the shore." -- Andre Gide."— Presentation transcript:

1 Eiffel Naeem Esfahani University of Tehran "Man cannot discover new oceans unless he has the courage to lose sight of the shore." -- Andre Gide

2 I prefer to have as little as possible to do with Bertrand Meyer -- Bjarne Stroustrup, 1989

3 Overview Introduction & History Design By Contract™ Elements Concepts Syntax and Semantics

4 Introduction & History

5 Bertrand Meyer BS from Ecole polythecnique MS from Stanford University PhD from Univesite du Nancy Professor of Software Engineering at ETH in Zurich 2001

6 Bertrand Meyer Nine years in a large company Three years on the faculty at the University of California, Santa Barbara computer languages, object-oriented system design, architectural reviews, technology assessment

7 History Designed at Eiffel Software in 1985 as an internal tool A modern, OO environment integrating the concepts of modern software engineering There was simply nothing available

8 History First demonstrated in public at the first OOPSLA conference in October of 1986 Release it as a commercial product at the end of 1986 In 1988 in a book by Bertrand Meyer Version 2.3, released in the Summer of 1990

9 History Eiffel 3, was written entirely in Eiffel –Melting Ice Technology for fast recompilation –Fully graphical environment –Considerable advances in libraries –Optimization of the generated code The latest milestones is: Eiffel 5 and EiffelStudio

10 Application Leading to a set of successful industrial projects in the US, Canada, Europe and the Far East Adoption by numerous universities as the primary teaching language

11 Where the Name does come from? Homage to Gustave Eiffel, the man who built the eponymous Tower in Paris The Eiffel Tower was completed on time and within budget Small number of robust, elegant design patterns, combined and varied repeatedly to yield a powerful, efficient structure

12 Where the Name does come from? The Eiffel Tower was initially conceived as a temporary structure and it was able to endure far beyond its original goals What better symbol could there be of the engineering principles behind Eiffel?

13 Design By Contract™

14 Assertions A boolean expression that is evaluated when it is reached during execution If true, execution continues else, execution may halt or an exception Eiffel has support for writing assertion

15 Assertions Preconditions: When a routine is called Postconditions: When a routine returns General assertions: When execution reaches them Class invariants: Maintained by all instances of a class

16 Pre and postconditions Preconditions and postconditions are associated with routines of a class

17 Pre and postconditions The preconditions must be true when the routine is called Postconditions must have been established when the routine terminates

18 Class Invariant Conditions that must be true for all objects of the class at ‘stable’ times When method starts to execute: –Its preconditions are met and the class invariant is satisfied After execution: –The postcondition must be met and the class invariant must be satisfied

19 Class Invariant

20 Elements

21 Classes The basic and only construct in Eiffel The attributes of entities and the operations that entities can perform A class represents all objects of that type

22 Libraries Classes that frequently appear –Reuse EiffelBase: –INTEGER, REAL, STRING, LISTs, ARRAYs Libraries are not defined as part of the Eiffel language

23 Features Each class has a set of features which represent the attributes and routines of a class routines are either procedures or functions; attributes can be fields, constants or functions

24 Features Procedures (Commands) alter the state of the object Functions (Queries) are return an answer to a query about the state of an object This is by convention, rather than being enforced in Eiffel

25 Concepts

26 Inheritance Build new classes out of existing classes, and to reuse features already defined in those classes, you use inheritance Eiffel has multiple inheritance –solves clashing by having a rename clause –Redefinition Inheritance is one of the fundamental mechanisms for reuse Polymorphism

27 Class Syntax

28 Genericity You can reuse like inheritance Genericity is important in making programs type safe without resorting to type casts constrained genericity –allows generic parameters to be constrained allow you to write general algorithmic patterns

29 Objects A name in an Eiffel program is declared as having a type. The declaration x : T Still does not refer to any objects: x is not bound to an object Expressed as the object void. We can see if an object is bound to void by writing x=void Name x can be bound to any object that type conforms to type T

30 Objects Three ways to achieve this binding: Assignment instruction: The assignment x:=y binds x to the object to which y is currently bound A creation instruction: The creation instruction !!x creates a new object of type T,and binds x to it. This is similar to new in C++. Routine call

31 Objects c: C !! c.make An object of type C is created and attached to the reference c !D! c.make An object of type D, where D conforms to C is created and attached to c. If you have a creation routine declared for the class, the creation routine must be called like constructor

32 Objects Creation routines can be called as normal routines Note that the !! syntax is somewhat cryptic, and a recent change to the language has changed this for a create command keyword Eiffel has no delete operator. This is because, as with Java, Eiffel is garbage collected

33 Etc Class variables: variables which do not have one copy per class of objects. The Eiffel equivalent for doing this is once routines Eiffel does not have... –Gotos are not needed, as the Eiffel style is to write small routines –Global variables are a sign of poor structuring use once routines instead –Type casts to make up for a flawed type system –Pointers with their associated problems Code must be structured in classes

34 Syntax and Semantics

35 Some constructs Comments are introduced by -- Grouped entities are terminated by the keyword end, no begin keyword No semicolons, optionally be placed between instructions

36 Style Keywords are shown in bold User named entities in italic Class names are given in uppercase Eiffel is not case sensitive, so it is up to the programmer to follow style conventions. More than one words separate the constituent words with underscore ‘_’

37 Access specifiers Any set of features introduced by the feature keyword can be exported to other specific classes ANY and NONE There is no strict equivalent to private, as Eiffel believes it is not sensible to restrict visibility in subclasses.

38 Access specifiers

39 Basic Types BOOLEAN not, or, and, implies, or else, and then INTEGER +, -, *, //, \\, ˆ,, = REAL +, -, *, /, ˆ,, =

40 Conditional

41 Iterations There is only one form of iteration in Eiffel

42 Procedures

43 Functions The value to be returned result := expression

44 Redefinition

45 Renaming

46 Counter class COUNTER feature -- Access item: INTEGER -- Counter's value. feature -- Element change increment is -- Increase counter by one. do item := item + 1 end decrement is -- Decrease counter by one. do item := item - 1 end reset is -- Reset counter to zero. do item := 0 end end

47 Questions

48 If Time! Native C and C++ Simplicity First release instead prototype Melting ice


Download ppt "Eiffel Naeem Esfahani University of Tehran "Man cannot discover new oceans unless he has the courage to lose sight of the shore." -- Andre Gide."

Similar presentations


Ads by Google