Stéphane Ducasse6.1 Essential Concepts Why OO? What is OO? What are the benefits? What are the KEY concepts? Basis for all the lectures.

Slides:



Advertisements
Similar presentations
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Advertisements

©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
Stéphane Ducasse2.1 OOP? What is OOP? Why? OOP in a nutshell.
1 CIS601: Object-Oriented Programming in C++ Note: CIS 601 notes were originally developed by H. Zhu for NJIT DL Program. The notes were subsequently revised.
Object-Oriented Analysis and Design
Chapter 1 Object-Oriented System Development
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
Object-Oriented PHP (1)
7M701 1 Software Engineering Object-oriented Design Sommerville, Ian (2001) Software Engineering, 6 th edition: Chapter 12 )
Object-Oriented Databases v OO systems associated with – graphical user interface (GUI) – powerful modeling techniques – advanced data management capabilities.
Object Oriented System Development with VB .NET
OBJECT ORIENTED ANALYSIS & DESIGN Vassilka Kirova Department of Computer & Information Science NJIT.
Object-Oriented Databases
Object-oriented Programming Concepts
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 1 Introduction to Object-Oriented Programming and Software Development.
Visual Basic Introduction IDS 306 from Shelly, Cashman & Repede Microsoft Visual Basic 5: Complete Concepts and Techniques.
1 Introduction to C++ Programming Concept Basic C++ C++ Extension from C.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 1 Introduction to Object-Oriented Programming and Software Development.
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
C++ fundamentals.
BACS 287 Basics of Object-Oriented Programming 1.
Introduction To System Analysis and design
UFCEUS-20-2 : Web Programming Lecture 5 : Object Oriented PHP (1)
Programming Languages and Paradigms Object-Oriented Programming.
Introduction to Object-oriented programming and software development Lecture 1.
BCS 2143 Introduction to Object Oriented and Software Development.
Objects and Components. The adaptive organization The competitive environment of businesses continuously changing, and the pace of that change is increasing.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
CONCEPTS OF OBJECT ORIENTED PROGRAMMING. Topics To Be Discussed………………………. Objects Classes Data Abstraction and Encapsulation Inheritance Polymorphism.
CS 403 – Programming Languages Class 25 November 28, 2000.
Unified Modeling Language, Version 2.0
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer.
Inheritance - Polymorphism ITI 1121 Nour El Kadri.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
S.Ducasse Stéphane Ducasse 1 Object-Oriented Programming.
S.Ducasse Stéphane Ducasse savoie.fr e/ e/ 1 Inheritance Semantics and Method Lookup.
What is Object-Oriented?  Organization of software as a collection of discreet objects that incorporate both data structure and behavior.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020.
Learners Support Publications Object Oriented Programming.
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
CSC 131 Fall 2006 Lecture # 6 Object-Oriented Concepts.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
CS451 - Lecture 2 1 CS451 Lecture 2: Introduction to Object Orientation Yugi Lee STB #555 (816) * Acknowledgement:
9-Dec Dec-15  INTRODUCTION.  FEATURES OF OOP.  ORGANIZATION OF DATA & FUNCTION IN OOP.  OOP’S DESIGN.
S.Ducasse Stéphane Ducasse 1 Essential OO Concepts Stéphane Ducasse.
1 Unified Modeling Language, Version 2.0 Chapter 2.
Lecture 2: Review of Object Orientation. © Lethbridge/La ganière 2005 Chapter 2: Review of Object Orientation What is Object Orientation? Procedural.
1 CSE Programming in C++. 2 Overview Sign roster list Syllabus and Course Policies Introduction to C++ About Lab 1 Fill Questionnaire.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
COP 4331 – OOD&P Lecture 7 Object Concepts. What is an Object Programming language definition: An instance of a class Design perspective is different.
Lecture 2 Intro. To Software Engineering and Object-Oriented Programming (2/2)
Basic Characteristics of Object-Oriented Systems
Sadegh Aliakbary Sharif University of Technology Fall 2010.
ISBN Chapter 12 Support for Object-Oriented Programming.
Slide 1 Unified Modeling Language, Version 2.0 Object-Oriented SAD.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
OOP What is problem? Solution? OOP
Introduction to Object-oriented Program Design
Object-oriented Design in Processing
Object-oriented Design in Processing
Object-oriented Design in Processing
Object-Oriented PHP (1)
Object-Oriented Programming
Object-oriented Design in Processing
Presentation transcript:

Stéphane Ducasse6.1 Essential Concepts Why OO? What is OO? What are the benefits? What are the KEY concepts? Basis for all the lectures

Stéphane Ducasse6.2 Object-Orientation Is a paradigm not a technology Reflects, simulates the real world Thinks in terms of organization Tries to –Handle complexity –Enhance reusability –Minimize maintenance cost

Stéphane Ducasse6.3 Evolution Procedures Structured Programming Fourth Generation Languages Object-Oriented Programming ???

Stéphane Ducasse6.4 Traditional ViewPoint Focuses upon procedures Functionality is vested in procedures Data exists solely to be operated upon by procedures Procedures know about the structure of data Requires large number of procedures and procedure names

Stéphane Ducasse6.5 Data and Procedures

Stéphane Ducasse6.6 What is OOP? An application is a collection of interacting entities (objects) Objects are characterised by behaviour and state Inter-object behaviour needs to be coordinated Inter-object communication is the key to coordination

Stéphane Ducasse6.7 Object-Oriented Viewpoint An application is a set of objects interacting by sending messages The functionality of an object is described by its methods, it’s data is stored in private variables An object’s functionality can be invoked by sending a message Everything is an object

Stéphane Ducasse6.8 Data/Messages/Methods Data Messages Methods

Stéphane Ducasse6.9 What vs How What: Messages –Specify what behavior objects are to perform –Details of how are left up to the receiver –State information only accessed via messages How: Methods –Specify how operation is to be performed –Must have access to (contain or be passed) data –Need detailed knowledge of data –Can manipulate data directly Data Methods Messages

Stéphane Ducasse6.10 Message Sent to receiver object: receiver-object message A message may include parameters necessary for performing the action In Smalltalk, a message-send always returns a result (an object) Only way to communicate with an object and have it perform actions pt h w aRectangle aClient … aRectangle area … area

Stéphane Ducasse6.11 Method Defines how to respond to a message Selected via method lookup technique Has name that is the same as message name Is a sequence of executable statements Returns an object as its result of execution pt h w area aRectangle area ^ h * w aClient … aRectangle area … area

Stéphane Ducasse6.12 Object Encapsulation Technique for –Creating objects with encapsulated state/behaviour –Hiding implementation details –Protecting the state information of objects –Communicating/accessing via a uniform interface Puts objects in control Facilitates modularity, code reuse and maintenance External perspective vs. Internal perspective Whatvs. How Message vs. Method

Stéphane Ducasse6.13 Encapsulation at Work pt h w area aRectangle area ^ h * w aClient … aRectangle area … area aRectangle area d := (pt2-pt1). ^ d x * d y aClient … aRectangle area … pt1 pt2

Stéphane Ducasse6.14 Objects Unique identity Private state Shared behavior among other similar objects

Stéphane Ducasse6.15 Class: Factory of Objects Reuse behavior => Factor into class Class: “Factory” object for creating new objects of the same kind Template for objects that share common characteristics generates

Stéphane Ducasse6.16 Class: Mold of Objects **Describe** state but not value of all the instances of the class –Position, width and height for rectangles **Define** behavior of all instances of the class area ^ width * height Rectangle position width height area translatedBy: aPoint

Stéphane Ducasse6.17 Instances A particular occurrence of an object defined by a class Each instance has its own value for the instance variables All instances of a class share the same methods Rectangle position width height area translatedBy: aPoint instance of

Stéphane Ducasse6.18 How to Share Specification? Do not want to rewrite everything! Often times want small changes Class hierarchies for sharing of definitions Each class defines or refines the definition of its ancestors => inheritance

Stéphane Ducasse6.19 Example GraphicalObject Turtle ColoredTurtle Window ScheduledWindow

Stéphane Ducasse6.20 Inheritance New classes –Can add state and behavior –Can specialize ancestor behavior –Can use ancestor’s behavior and state –Can hide ancestor’s behavior Direct ancestor = superclass Direct descendant = subclass

Stéphane Ducasse6.21 Comparable Quantity Hierarchy

Stéphane Ducasse6.22 Polymorphism Same message can be sent to different objects Different receivers react differently (different methods) –aWindow open –aScheduledWindow open –aColoredWindow open –aRectangle area –aCircle area

Stéphane Ducasse6.23 Late binding: “Let’s the Receiver decides” Mapping of messages to methods deferred until run-time (dynamic binding) Allows for rapid incremental development without the need to recompile (in Smalltalk) Most traditionl languages do this at compile time (static binding)

Stéphane Ducasse6.24 Procedural Solution for a List of Graphical Objects tArea element = Circle then tArea := tArea + element.circleArea. element = Rectangle then tArea := tArea + element.rectangleArea … Intersect, color, rotate translate….

Stéphane Ducasse6.25 In Java for example public static long sumShapes(Shape shapes[]) { long sum = 0; for (int i=0; i<shapes.length; i++) { switch (shapes[i].kind()) { // a class constant case Shape.CIRCLE: sum += shapes[i].circleArea(); break; case Shape.RECTANGLE: sum += shapes[i].rectangleArea(); break;... // more cases } return sum; }

Stéphane Ducasse6.26 Problems of the Procedural Solution Adding a kind of graphical element => Change all the methods area, intersect, rotate, translate… => Always have to check what is the data I manipulate

Stéphane Ducasse6.27 Object-Oriented Solution Circle>>area ^ Float pi * r * r Rectangle>>area ^ width * height XXX>>area elements do: [:each | tArea := tArea + each area]

Stéphane Ducasse6.28 Advantage Adding a new graphical object does not require to change the list operations I do not have know the kind of objects I’m manipulating as soon as they all share a common interface

Stéphane Ducasse6.29 Recap OOP see the world as interacting objects Objects –have their own state –Share the behavior among similar objects Classes: Factory of objects –Define behavior of objects –Describe the structure of objects –Share specification via hierarchies

Stéphane Ducasse6.30 Recap OOP is based on –Encapsulating data and procedures –Inheritance –Polymorphism –Late Binding OOP promotes –Modularity –Reuse