Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session 3 29 September 2008.

Similar presentations

Presentation on theme: "Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session 3 29 September 2008."— Presentation transcript:

1 Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session 3 29 September 2008

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

3 Chair of Software Engineering 3 Today’s learning goals  Distinguishing between  commands and queries  feature declaration and feature call  Understanding feature call chains  Getting to know the basics of EiffelStudio

4 Chair of Software Engineering 4 Features, commands and queries Feature: an operation available on a certain class of objects Three kinds:  Command  Query  Creation procedure (seen later)

5 Chair of Software Engineering 5 Defining and classifying features A feature is an operation that programs may apply to certain classes of objects. A feature that accesses an object is a query A feature that may modify an object is a command

6 Chair of Software Engineering 6 Command-query separation principle “Asking a question shouldn’t change the answer” i.e. “query”

7 Chair of Software Engineering 7 Queries  Goal: obtain properties of objects  Always return a value!  Should not modify the object, or any other Examples:  What is the name of a person?  What is the age of a person?  What is the id of a student?  Is a student registered for a particular course?  Are there any places left in a certain course? … other examples?

8 Chair of Software Engineering 8 Commands  Goal: produce a change on an object, or several  Should not return a value Examples:  Register a student to a course  Assign an id to a student  Record the grade a student got in an exam … other examples?

9 Chair of Software Engineering 9 Exercise: query or command?  What is the balance of a bank account?  Withdraw some money from a bank account  Who is the owner of a bank account?  Who are the clients of a bank whose deposits are over 100,000 CHF?  Change the account type of a client  How much money can a client withdraw at a time?  Set a minimum limit for the balance of accounts  Is Steve Jobs a client of Credit Suisse? Hands-On

10 Chair of Software Engineering 10 Query or command? 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

11 Chair of Software Engineering 11 Declaration vs. call Feature declaration feature_name (args_decl) is -- Comment do … end Feature call object.feature_name (args)

12 Chair of Software Engineering 12 An example Feature declaration set_name (a_name: STRING) is -- Set ‘name’ to ‘a_name’. do name := a_name end Feature call a_person.set_name (“Peter”)

13 Chair of Software Engineering 13 Instructions General form of feature call instruction: object1.query1.query2.command (object2.query3.query4, object3) Call chains for targets and arguments: Where are query1, query2, query3 and query4 defined? Where is command defined? targetarguments Hands-On

14 Chair of Software Engineering 14 EiffelStudio  Introduction to the IDE  Debugging  Demo

15 Chair of Software Engineering 15 Documentation  EiffelStudio Help  Guided Tour very good as introduction, to get you started 

16 Chair of Software Engineering 16 Introduction to the IDE  One development window divided into panels:  Editor  Context tool  Clusters pane + others (Features, Favorites, etc.)  Toolbar customization  Pick-and-drop mechanism

17 Chair of Software Engineering 17 The editor  Syntax highlighting  Syntax completion (CTRL+Space)  Class name completion (SHIFT+CTRL+Space)  Smart indenting  Block indent or exdent (TAB and SHIFT+TAB)  Block commenting or uncommenting (CTRL+K and SHIFT+CTRL+K)  Infinite level of Undo/Redo (reset after a save)  Quick search features (first CTRL+F to enter words then F3 and SHIFT+F3)

18 Chair of Software Engineering 18 The compiler  Uses incremental compilation  Supports.NET  Project Settings Tool

19 Chair of Software Engineering 19 Getting started with the debugger  The system must be melted/frozen (finalized systems cannot be debugged)  Click the Run button

20 Chair of Software Engineering 20 Setting breakpoints  Use the flat formats to add breakpoints  Tip: An efficient way of adding breakpoints consists in dropping a feature in the context tool  Click in the margin to enable/disable single breakpoints  Use the toolbar debug buttons to enable or disable all breakpoints globally

21 Chair of Software Engineering 21 Running the application  New display of the Development Window to include debugging information about:  The current object (Object Tool)  The arguments and local variables of the routine being debugged  Once on a breakpoint: possibility to step over / into / out of the next statement  Possibility to interrupt the application at anytime (Pause Application button or SHIFT+CTRL+F5)

Download ppt "Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session 3 29 September 2008."

Similar presentations

Ads by Google