Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 2: Dealing with Objects I.

Slides:



Advertisements
Similar presentations
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 5.
Advertisements

Eiffel: Analysis, Design and Programming Bertrand Meyer (Nadia Polikarpova) Chair of Software Engineering.
2 nd Microsoft Rotor Workshop, Pisa, April 23-25, SCOOPLI for.NET: a library for concurrent object-oriented programming Volkan Arslan, Piotr Nienaltowski.
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 Lecture 3: Dealing with Objects II.
The Web Warrior Guide to Web Design Technologies
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
7M701 1 Software Engineering Object-oriented Design Sommerville, Ian (2001) Software Engineering, 6 th edition: Chapter 12 )
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 2: Dealing with Objects I.
Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session 2 23 September 2008.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 6: Object Creation.
Chair of Software Engineering 1 Introduction to Programming Bertrand Meyer Exercise Session 3 29 September 2008.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 4: The Interface of a Class.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 4: The Interface of a Class.
Software Requirements
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 9: Abstraction.
Fall 2007CS 2251 Software Engineering Intro. Fall 2007CS 2252 Topics Software challenge Life-cycle models Design Issues Documentation Abstraction.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 6: Object Creation.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 10.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Guide To UNIX Using Linux Third Edition
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 9: Abstraction.
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
CSCI-383 Object-Oriented Programming & Design Lecture 15.
Basic Concepts The Unified Modeling Language (UML) SYSC System Analysis and Design.
A First Program Using C#
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Java Classes, Interfaces, and Types 1.
CS2110: SW Development Methods Design of methods (functions) Class design – CRC cards – UML class and sequence diagrams Software Design.
High-Level Programming Languages: C++
1/19 Component Design On-demand Learning Series Software Engineering of Web Application - Principles of Good Component Design Hunan University, Software.
1 A Student Guide to Object- Orientated Systems Chapter 4 Objects and Classes: the basic concepts.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Java Language and SW Dev’t
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Fall 2012 Lecture 8: File I/O; Introduction to classes.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
Kal Bugrara, Ph.DSoftware Engineering Northeastern University Fundamentals Of Software Engineering Lecture V.
Lecture 11 Data Structures, Algorithms & Complexity Introduction Dr Kevin Casey BSc, MSc, PhD GRIFFITH COLLEGE DUBLIN.
Chapter 4 Introduction to Classes, Objects, Methods and strings
Introduction to Visual Basic Programming. Introduction Simple Program: Printing a Line of Text Another Simple Program: Adding Integers Memory Concepts.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
OBJECT ORIENTED AND FUNCTION ORIENTED DESIGN 1 Chapter 6.
Salman Marvasti Sharif University of Technology Winter 2015.
An Introduction to Forms. The Major Steps of a MicroSoft Access Database  Tables  Queries  Forms  Macros  Reports  Modules On our road map, we are.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
Chapter 5 System Modeling. What is System modeling? System modeling is the process of developing abstract models of a system, with each model presenting.
OO in Context Lecture 13: Dolores Zage. Confused about OO Not alone, there is much confusion about OO many programs are claimed to be OO but are not really.
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
Today… Style, Cont. – Naming Things! Methods and Functions Aside - Python Help System Punctuation Winter 2016CISC101 - Prof. McLeod1.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 1 An Introduction to Visual Basic.NET and Program Design.
Engineered for Tomorrow Unit:8-Idioms Engineered for Tomorrow sharmila V Dept of CSE.
IS 350 Course Introduction. Slide 2 Objectives Identify the steps performed in the software development life cycle Describe selected tools used to design.
Programming paradigms
Computer Programming.
Unit-1 Introduction to Java
Einführung in die Programmierung Introduction to Programming Prof. Dr
CS313T Advanced Programming language
Presentation transcript:

Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 2: Dealing with Objects I

2 Our first program! Display a map of Paris Spotlight position of Louvre museum Highlight line 8 of the metro Animate a predefined route

3 class PREVIEW inherit TOURISM feature explore -- Show city info and route. do -- “To be filled in (by you!)” end Class: a software machine A class text The class name

4 Traffic library convention Traffic classes have names of the form TRAFFIC_ ACTUAL_CLASS_NAME In these slides and in the book, for brevity, I omit the TRAFFIC_ part of the name But you will need it to find the classes in the software

5 Another convention For long names, use underscores “_” TRAFFIC_STATION Station_Paradeplatz -- or: Station_Parade_Platz We do not use “CamelCase”: AShortButHardToDeCipherName but underscores (sometimes called “Pascal_case”): A_significantly_longer_but_still_perfectly_clear_name

6 class PREVIEW inherit TOURISM feature explore -- Show city info and route. do -- “To be filled in (by you!)” end Software machine Extend existing class Operations Feature name Comment Keywords have a special role: class, inherit, feature, do, end. Feature declaration Pseudocode A class text

7 Magic? Class TOURISM is part of the supporting software It helps you learn by using predefined facilities (“magic”) Little by little pieces of the magic will be removed At the end, the magic will be gone

8 class PREVIEW inherit TOURISM feature explore -- Show city info and route. do Paris  display Louvre  spotlight Line8  highlight Route1  animate end Filling in the feature body

9 Program formatting Between adjacent elements: break: one or more spaces, “tabs”, “carriage returns” All kinds of break are equivalent Typographical variations (boldface, italics, colors) do not affect the effect (semantics) of programs class PREVIEW inherit TOURISM feature explore -- Show city info -- and route. do Paris  display Louvre  spotlight Line8  highlight Route1  animate end Breaks

10 Style rule For indentation, use tabs, not spaces Use this property to highlight the structure of the program, particularly through indentation class PREVIEW inherit TOURISM feature explore -- Show city info -- and route. do Paris  display Louvre  spotlight Line8  highlight Route1  animate end Tabs

11 Feature call The fundamental mechanism of program execution: apply a “feature” to an “object” Basic form: your_object. your_feature class PREVIEW inherit TOURISM feature explore -- Show city info -- and route. do Paris  display Louvre  spotlight Line8  highlight Route1  animate end Object (target of the call) Feature of the call

12 Predefined objects Paris, Louvre, Line8, and Route1 are names of predefined objects The objects are defined in class TOURISM from which PREVIEW inherits display, spotlight, highlight and animate are features, applicable to these objects

13 Class name: all upper-case Period in feature call: no space before or after Names of predefined objects: start with upper- case letters New names (for objects you define) start with lower- case letters class PREVIEW inherit TOURISM feature explore -- Show city info -- and route. do Paris  display Louvre  spotlight Line8  highlight Route1  animate end More style rules

14 Object technology We work with objects Our style of programming: Object-Oriented programming Abbreviation: O-O More generally, “Object Technology”: includes O-O databases, O-O analysis, O-O design... Software execution is made of operations on objects — feature calls your_object. your_feature

15 A distinct mode of expression Paris  display next_message  send computer  shut_down telephone  ring Every operation applies to an object (the target of the call)

16 What’s an object? Software notion: machine known through operations applicable to it. Three kinds of object:  “Physical objects”: reflect material objects of the modeled world or system Examples: the Louvre, Paris, a metro car..  “Abstract objects”: describe abstract notions from the modeled world or system Examples: a line, a route...  “Software objects”: represent pure software notions Examples: “data structures” such as arrays or lists A key attraction of object technology is its modeling power: connect software objects to objects of the problem domain (“model”) You should not, however, confuse them In this course, “object” by default means software object

17 Two views of objects Two viewpoints:  1. An object has data, stored in memory.  2. An object is a machine offering operations (features) The connection:  The operations that the machine provides (2) access and modify the object’s data (1). “Bürkliplatz” “Bucheggplatz” 25 5 Start point Tram number Number of stops Endpoint

18 Features: commands and queries Feature: an operation available on a certain class of objects Three kinds:  Command  Query  Creation procedure (seen later)

19 Queries Goal: obtain properties of objects Should not modify the object, or any other Examples, for “route” objects:  What is the origin (first station) of Route1?  What is the end point of Route1?  How many stations does Route1 have?  Which stations does Route1 traverse? “Bürkliplatz” “Bucheggplatz” 25 5

20 Commands Goal: produce a change on an object, or several objects Examples, for “route” objects:  Animate Route1  Append (add at the end) a station to Route1  Prepend (add at the beginning) a station to Route1

21 A command

22 A query

23 The command-query separation principle Asking a question should not change the answer

24 An object is a machine An executing program is a machine It’s made of smaller machines: objects During execution there may be many objects (e.g. millions)

25 An object is a machine A machine, hardware or software, is characterized by the operations (“features”) users may apply prepend animate append count stations first last

26 Two views of objects Two viewpoints:  1. An object has data, stored in memory.  2. An object is a machine offering operations (features: commands and queries) The connection:  The operations that the machine provides (2) access and modify the object’s data (1). “Bürkliplatz” “Bucheggplatz” 25 5 Start point Tram number Number of stops Endpoint

27 Objects: a definition An object is a software machine allowing programs to access and modify a collection of data

28 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

29 Using queries Queries are as important as commands Queries don’t “do” anything, but yield a value, e.g. Route1  origin yields the starting station of Route1 You may work with the return values of queries, e.g. highlight the starting station on the screen

30 Features may have arguments Task:  Show starting point of Route1 on “console” window You need:  Predefined object Console  Feature show applicable to Console  The object Route1  Feature origin returning starting point and applicable to Route1 The new feature call: Console  show (Route1  origin)

31 class PREVIEW inherit TOURISM feature explore -- Show city info, a route, and route’s origin. do Paris  display Louvre  spotlight Line8  highlight Route1  animate end Extending the feature body Console  show ( Route1  origin )

32 Features with arguments some_argument is a value that your_feature needs Example: feature show must know what to show. Same concept as function arguments in maths: cos (x) Features may have several arguments: x  f (a, b, c, d ) -- Separated by commas In well written O-O software, most have 0 or 1 argument your_object  your_feature (some_argument)

33 A distinct mode of expression Paris  display next_message  send computer  shut_down telephone  ring Every operation applies to an object

34 A distinct mode of expression Paris  display next_message  send_to (recipient ) computer  shut_down_after (3 ) telephone  ring_several (10, Loud ) Every operation applies to an object and may take arguments

35 Scaling up One of the toughest issues in learning software is to find solutions that work well both “in the small” and “in the large”. That’s the goal for the techniques we teach in this course.

36 prepend animate append An object has an interface count stations first last

37 prepend animate append count first An object has an implementation count stations first last

38 Information hiding prepend animate append count stations first last

39 The information hiding principle The designer of every module must specify which properties are accessible to clients (public) and which are internal (secret) The programming language must ensure that clients can only use public properties

40 What we have seen so far Basic concepts and constructs of object technology:  Classes (a first view)  Basic program text structure  Objects  Features  Feature call  Feature arguments Methodological principles:  Command-query separation  Information hiding