Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session 5 6 October 2008.

Slides:



Advertisements
Similar presentations
Slide 1 Insert your own content. Slide 2 Insert your own content.
Advertisements

0 - 0.
Modelling Features as Statecharts Pourya Shaker and Joanne M. Atlee.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 5.
Eiffel: Analysis, Design and Programming Bertrand Meyer (Nadia Polikarpova) Chair of Software Engineering.
Technieken van de Software Architectuur, VUB ‘98-’99, Part 11 Object Orientation Review.
8 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Using Explicit Cursors.
The IF function Bernard Liengme. Objectives To know how to: Construct a condition using the comparison operators =, >=, >, ; Construct a formula using.
Modelling uncertainty in 3APL Johan Kwisthout Master Thesis
Fakultät für informatik informatik 12 technische universität dortmund Lab 3: Scheduling Solution - Session 10 - Heiko Falk TU Dortmund Informatik 12 Germany.
Chapter 9 Interactive Multimedia Authoring with Flash Introduction to Programming 1.
More on Processing User Input BCIS 3680 Enterprise Programming.
Control Structures Ranga Rodrigo. Control Structures in Brief C++ or JavaEiffel if-elseif-elseif-else-end caseinspect for, while, do-whilefrom-until-loop-end.
1 Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 13.
Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Exercise Session 1: Eiffel Introduction.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 7: References and Assignment.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer Lecture 3: Abstract Data Types.
Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session November 2008.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 6.
Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session 4 30 September 2008.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 5.
Chair of Software Engineering ATOT - Lecture 12, 12 May Advanced Topics in Object Technology Bertrand Meyer.
Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session 3 29 September 2008.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 3.
Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session 1 22 September 2009.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 4: The Interface of a Class.
Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session 6 7 October 2008.
Chair of Software Engineering OOSC - Lecture 4 1 Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 4: The Interface of a Class.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 4.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 18: Undo/Redo.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 7: References and Assignment.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 4.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 3.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 10.
Chair of Software Engineering 1 Introduction to Programming Exercise Session Week 10 M. Piccioni 24/25 November 2008.
Eiffel Language and Design by Contract Contract –An agreement between the client and the supplier Characteristics –Expects some benefits and is prepared.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 5.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 7.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 9.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 10.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 9: Abstraction.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 3.
Introduction to Python Basics of the Language. Install Python Find the most recent distribution for your computer at:
Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session October 2008.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 5.
Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session October 2008.
Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session October 2008.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 5.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 4.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Professor: Dr. Shu-Ching Chen TA: Hsin-Yu Ha Stored Procedure used in PosgreSQL.
Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session October 2008.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 3.
Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session October 2008.
Professor: Dr. Shu-Ching Chen TA: Hsin-Yu Ha Function, Trigger used in PosgreSQL.
Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session October 2008.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Design by Contract Jim Fawcett CSE784 – Software Studio
Design by Contract Jim Fawcett CSE784 – Software Studio
Einführung in die Programmierung Introduction to Programming Prof. Dr
Stored Procedure used in PosgreSQL
The following slides contain advanced material and are optional.
Introduction to JUnit CS 4501 / 6501 Software Testing
Einführung in die Programmierung Introduction to Programming Prof. Dr
Einführung in die Programmierung Introduction to Programming Prof. Dr
Einführung in die Programmierung Introduction to Programming Prof. Dr
Einführung in die Programmierung Introduction to Programming Prof. Dr
Einführung in die Programmierung Introduction to Programming Prof. Dr
Presentation transcript:

Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session 5 6 October 2008

Chair of Software Engineering 2 Assignments  Deadline for assignment 3 on Thursday

Chair of Software Engineering 3 Today’s learning goals  Declaring the type of an object  Reading class interfaces and understanding feature calls

Chair of Software Engineering Declaring the type of an object  The type of any object you use in your program must be declared somewhere  Where can such declarations appear in a program?  in feature declarations:  argument types  return type for queries  in the local clauses of routines where you declare any objects that only the routine needs and knows

Chair of Software Engineering 5 Queries and commands Command: Query (attribute): Query (function): commandname (a1: T1; a2, a3: T2) is -- Comment require … do … ensure … end attributename: TYPE -- Comment functionname (a1: T1; a2, a3: T2): TYPE is -- Comment require … do … ensure … end optional mandatory

Chair of Software Engineering 6 Feature declaration vs. feature call Feature declaration feature_name_1 (arg1: A; arg2: B; …) is -- Comment do … end feature_name_2 (arg1: C; arg2: D; …): SOME_RETURN_TYPE is -- Comment do … end Feature call object1.feature_name_1 (a1, b1) object2 := object3.feature_name_2 (c1, d1) The underlined entities denote objects The red entities are type names

Chair of Software Engineering 7 Objects or classes? (example) ‏ class game... feature -- Access map_name: string -- Name of the map to be loaded for the game last_player: player -- Last player that moved... (continued on next slide) ‏ Hands-On

Chair of Software Engineering 8 Objects or classes? (example) ‏... feature -- Status report is_occupied (a_location: traffic_place): boolean is -- Check if `a_location' is occupied by some flat hunter. require a_location_exists: a_location /= Void local old_cursor: cursor do Result := False -- Remember old cursor position. old_cursor := players.cursor... Hands-On

Chair of Software Engineering 9 Objects or classes? (example) ‏ -- Loop over all players to check if one occupies -- `a_location'. from players.start -- do not consider estate agent, hence skip the first -- entry in `players'. players.forth until players.after or Result loop if players.item.location = a_location then Result := True end players.forth end -- Restore old cursor position. players.go_to(old_cursor) end Hands-On

Chair of Software Engineering 10 Objects or classes?  Terms “class” and “type” used interchangeably for now  Queries (attributes and functions) have a return type. However, when executing the query, you get an object.  You call features on objects.  Arguments given to a routine are objects, they all have certain types.  Local variables declared in a routine are objects, but they all have certain types.  Result and Current are objects.  Inheritance is a relation defined between classes.

Chair of Software Engineering 11 Queries and commands Command: Query (attribute): Query (function): commandname (a1: T1; a2, a3: T2) is -- Comment require … do … ensure … end attributename: TYPE -- Comment functionname (a1: T1; a2, a3: T2): TYPE is -- Comment require … do … ensure … end optional mandatory

Chair of Software Engineering 12 Query or command? (example) ‏ class GAME... feature -- Access map_name: STRING -- Name of the map to be loaded for the game last_player: PLAYER -- Last player that moved... (continued on next slide) ‏ Hands-On

Chair of Software Engineering 13 Query or command? (example)... feature -- Status report is_occupied (a_location: TRAFFIC_PLACE): BOOLEAN is -- Check if `a_location' is occupied by some flat hunter. require a_location_exists: a_location /= Void local old_cursor: CURSOR do Result := False -- Remember old cursor position. old_cursor := players.cursor... Hands-On

Chair of Software Engineering 14 Query or command? (example) -- Loop over all players to check if one occupies -- `a_location'. from players.start -- do not consider estate agent, hence skip the first -- entry in `players'. players.forth until players.after or Result loop if players.item.location = a_location then Result := True end players.forth end -- Restore old cursor position. players.go_to(old_cursor) end Hands-On