1 OBJECT-ORIENTED THINKING Ziya Karakaya Atılım University Tel: (312) 460 20 20 / 5345 Faks: (312) 460 2037 E-posta:

Slides:



Advertisements
Similar presentations
Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.
Advertisements

Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
1 OBJECT-ORIENTED CONCEPTS. 2 What is an object?  An object is a software entity that mirrors the real world in some way.  A software object in OOP.
Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:
OOP - Object Oriented Programming Object Oriented Programming is an approach to programming that was developed to make large programs easier to manage.
Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
Classes & Objects Computer Science I Last updated 9/30/10.
Classes and Object- Oriented... tMyn1 Classes and Object-Oriented Programming The essence of object-oriented programming is that you write programs in.
Object-Oriented Analysis and Design
Introduction To System Analysis and Design
Programming Language Paradigms: summary. Object-oriented programming Objects are the fundamental building blocks of a program. Interaction is structured.
Object-Oriented Thinking Chapter 1, Object-Oriented Programming in Java, Timothy Budd, 1998 ICS102 Semester
Lecture 2 Object Concepts I Object Oriented Analysis and Design K268 SENG2100 Pat Browne
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
Object Oriented Concepts. Movement toward Objects Instead of data-oriented or process-oriented Analysis, many firms are now moving to object-oriented.
C++ fundamentals.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
Introduction to Object-oriented Programming Introduction to Object-oriented Programming CMPS 2143.
BACS 287 Basics of Object-Oriented Programming 1.
The chapter will address the following questions:
Object Oriented Programming
Introduction To System Analysis and design
OO Analysis and Design CMPS OOA/OOD Cursory explanation of OOP emphasizes ▫ Syntax  classes, inheritance, message passing, virtual, static Most.
Object Oriented Software Development
CSCI-383 Object-Oriented Programming & Design Lecture 2.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
O BJECT O RIENTATION F UNDAMENTALS Prepared by: Gunjan Chhabra.
An Object-Oriented Approach to Programming Logic and Design
Object Oriented Concepts & Principles Ingrid Kirschning & Gerardo Ayala.
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.
CHAPTER ONE Problem Solving and the Object- Oriented Paradigm.
Object Oriented Programming with JAVA Arash N. Kia AlZahra University Definitions – Part 1.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
Unified Modeling Language, Version 2.0
Introduction To System Analysis and Design
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Object-Oriented (Real World Case) Object-Oriented Analysis CIM2566 Bavy LI.
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.
Object Oriented Programming Principles Lecturer: Kalamullah Ramli Electrical Engineering Dept. University of Indonesia Session-3.
CSSE501 Object-Oriented Development. Chapter 11: Static and Dynamic Behavior  In this chapter we will examine the differences between static and dynamic.
CSCI-383 Object-Oriented Programming & Design Lecture 3.
Ceg860 (Prasad)L1SQ1 Software Quality Object-Oriented Programming Paradigm.
Chapter 12 Support for Object oriented Programming.
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
ITEC 3220A Using and Designing Database Systems Instructor: Prof Z. Yang Course Website: 3220a.htm
Object-Oriented Programming with Java Lecture 1: Introduction Autumn, 2007.
ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020.
Learners Support Publications Object Oriented Programming.
Chapter 1: OO Thinking Not just learn Java, but also understand why it is the way it is Learn the OO worldview.
1 CMIS301 O-O Thinking Understanding O-O Programming by T Budd.
Salman Marvasti Sharif University of Technology Winter 2015.
Object-Oriented Programming © 2013 Goodrich, Tamassia, Goldwasser1Object-Oriented Programming.
CSCI 383 Object-Oriented Programming & Design Lecture 3 Martin van Bommel.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
Introduction to Computers Lesson 13A. home Computer Program A set of instructions or statements, also called code, to be carried out by the computer’s.
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
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.
Slide 1 Unified Modeling Language, Version 2.0 Object-Oriented SAD.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
OOP - Object Oriented Programming
Programming paradigms
The Movement To Objects
OOP What is problem? Solution? OOP
Chapter 1: Object-Oriented Thinking
Computer Programming.
ITEC 3220A Using and Designing Database Systems
Presentation transcript:

1 OBJECT-ORIENTED THINKING Ziya Karakaya Atılım University Tel: (312) / 5345 Faks: (312) E-posta:

2 Object-Oriented Paradigm ä Paradigm: “example” or “model”. ä Paradigm sentence would help you remember how to conjugate a verb in a foreign language ä A model is an example that helps you understand how the world works

3 Illustration of OOP Concepts : Sending Flowers to a Friend ä Suppose I wish to send flowers to a friend, Sally, who lives in a city many miles away. ä What should I do?

4 Agents and Communities ä Solution: Find an appropriate agent, namely Flora, and pass to her a message containing my request ä It is the responsibility of Flora to satisfy my request ä There is some method – some algorithm or some set of operations – used to satisfy my request ä This information, i.e., details, is usually hidden from my inspection.

5 The community of agents helping me Sally’s Florist Flora Me Delivery Person Sally Flower Arranger Wholesaler Grower Gardener

6 An Observation ä An object-oriented program is structured as a community of interacting agents, called objects. ä Each object has a role to play. ä Each object provides a service, or performs an action, that is used by other members of the community.

7 Messages and Methods ä Action is initiated in OOP by the transmission of a message to an agent (an object) responsible for the action. ä The message encodes the request for an action and is accompanied by any additional information (arguments) needed to carry out the request. ä The receiver is the object to whom the message is sent. If the receiver accepts the message, it accepts the responsibility to carry out the indicated action. ä In response to a message, the receiver will perform some method to satisfy the request.

8 Information Hiding Principle ä The client sending the request need not know the actual means by which the request will be honored. ä An important part of the OOP is the development of reusable components ä “thrusting” others

9 Message Passing vs. Procedure Calling ä PC: there is no designated receiver ä MP: Interpretation of the message is dependent on the receiver and can vary with different receivers ä Usually, the specific receiver for any given message will not be known until run time, so the determination of which method to invoke cannot be made until then. ä late binding – between a message and the code fragment (method) used to respond to the message. ä vs. compile-time or link-time binding in PC.

10ResponsibilitiesResponsibilities ä Describe behavior in terms of responsibilities ä increases level of abstraction ä greater independence between objects, a critical factor in solving complex problems ä Protocol: The entire collection of responsibilities associated with an object

11 ä “Ask not what you can do to your data structures, but what your data structures can do for you”

12 Classes and Instances ä We can use the term Florist to represent the category (or class) of all florists. ä I am able to make certain assumptions because I have information about florists in general, and I expect that Flora, being an instance of this category, will fit the general pattern.

13 ä All objects are instances of a class ä The method invoked by an object in response to a message is determined by the class of the receiver ä All objects of a given class use the same method in response to similar messages.

14 Class Hierarchies - Inheritance ä I have more information about Flora – not necessarily because she is a florist but because she is a shopkeeper. ä One way to think about how I have organized my knowledge of Flora is in terms of a hierarchy of categories:

15 The categories surrounding Flora Flora Material Object Animal Mammal Human Shopkeeper Florist

16 A class hierarchy of various material objects Material Object Animal Mammal Human Shopkeeper Florist Flora ArtistDentist Painter LizAdam Dog Flash Platypus Phyl Plant Flower Carnation Sally’s Flowers More abstract classes are listed near the top of the tree More specific classes and individuals are listed near the bottom.

17 ä The principle that knowledge of a more general category is also applicable to a more specific category is called inheritance.  The class Florist will inherit attributes of the class (or category) Shopkeeper. ä Classes can be organized into a hierarchical inheritance structure. ä A child class (or subclass) will inherit attributes from a parent class higher in the hierarchy. An abstract parent class is a class for which there are no direct instances; it is used only to create subclasses.

18 Method Binding, Overriding, and Exceptions  Exceptions to a general rule: Consider Phyl the Platypus ä Phyl gives birth to live offspring yet Phyl lays eggs. ä The information contained in a subclass can override information inherited from a parent class ä Most often, implementations of this approach take the form of a method in the subclass having the same name as the method in the parent class, ä combined with a rule stating how to conduct the search for a method to match a specific message.

19 Searching for the appropriate response ä The search for a method to invoke in response to a given message begins with the class of the receiver. ä If no appropriate method is found, the search conducted in the parent class of this class. ä The search continues up the parent class chain until either a method is found or the parent class chain is exhausted. ä In the former case, the method is executed; in the latter case, an error message is issued. ä If methods with the same name can be found higher in the class hierarchy, the method executed is said to override the inherited behavior.

20 ä That my wife, Liz and my florist Flora will respond to my message by different methods is an example of one form of Polymorphism. ä That I do not, need not, know exactly what method Flora will use to honor my message is an example of information hiding.

21 Kay's Description of Object- Oriented Programming ä Object-oriented programming is based on the principle of recursive design. 1.Everything is an object 2.Objects perform computation by making requests of each other through the passing of messages 3.Every object has it's own memory, which consists of other objects. 4.Every object is an instance of a class. A class groups similar objects. 5.The class is the repository for behavior associated with an object 6.Classes are organized into singly-rooted tree structure, called an inheritance hierarchy.

22 Recursive Design

23 Computation as Simulation ä Traditional model describing the behavior of a computer executing a program is a process-state or pigeonhole model. ä The computer is a data manager, following some pattern of instructions, wandering through memory, and publishing the results back into other slots. ä By examining the values in the slots, we can determine the state of the machine or the results produced by a computation.

24 Imperative Programming ä Imperative programming is the ``traditional'' model of computation. ä State ä Variables ä Assignment ä Loops ä A processing unit is separate from memory, and ``acts'' upon memory.

25 Visualization of Imperative Programming Sometimes called the ``pigeon-hole'' model of computation.

26 ä In contrast, in OO framework we never mention memory addresses, variables, assignments, or any of the conventional programming terms. ä We speak of objects, messages, responsibility for some action. ä Instead of a bit-grinding processor... plungering data structures, we have a universe of well- behaved objects that courteously ask each other to carry out their various desires.

27 ä Similar to discrete event simulation ä user creates computer models of the various elements of the simulation ä describes how they will interact with one another ä sets them moving ä In OOP, computation is a simulation.

28 The Power of Metaphor ä “Unlike the usual programming method – writing software one line at a time – NeXT’s “object- oriented” system offers larger building blocks that developers can quickly assemble the way a kid builds faces on Mr. Potato Head.” ä Easier to teach OOP concepts to computer novices than to computer professionals. ä Programming is as like the task of “training” the universe of agents to interact smoothly with each other, each providing a certain small and well- defined service to the others, each contributing to the effective execution of the whole.