CSCI-383 Object-Oriented Programming & Design Lecture 3.

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.
OOP - Object Oriented Programming Object Oriented Programming is an approach to programming that was developed to make large programs easier to manage.
OBJECT ORIENTED PROGRAMMING M Taimoor Khan
Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
UMBC 1 Static and Dynamic Behavior CMSC 432 Shon Vick.
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
2-1 © Prentice Hall, 2007 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
Programming Language Paradigms: summary. Object-oriented programming Objects are the fundamental building blocks of a program. Interaction is structured.
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Object-Oriented Thinking Chapter 1, Object-Oriented Programming in Java, Timothy Budd, 1998 ICS102 Semester
1 Basic Object-Oriented Concepts  Object-Oriented Paradigm What is an Object?  What is a Class?  Constructing Objects from a class Problem Solving in.
Object-oriented Programming Concepts
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
Sharif University of Technology Session # 7.  Contents  Systems Analysis and Design  Planning the approach  Asking questions and collecting data 
INTRODUCTION TO JAVA PROGRAMMING Chapter 1. What is Computer Programming?
1 INTRODUCTION TO OOP Objective: Know the difference between functional programming and OOP Know basic terminology in OOP Know the importance of OOP Know.
Introduction to Object-oriented Programming Introduction to Object-oriented Programming CMPS 2143.
CSCI-383 Object-Oriented Programming & Design Lecture 15.
Object Oriented Programming
CSCI-383 Object-Oriented Programming & Design Lecture 2.
CSCI-383 Object-Oriented Programming & Design Lecture 4.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
An Object-Oriented Approach to Programming Logic and Design
CSCI-383 Object-Oriented Programming & Design Lecture 9.
CONCEPTS OF OBJECT ORIENTED PROGRAMMING. Topics To Be Discussed………………………. Objects Classes Data Abstraction and Encapsulation Inheritance Polymorphism.
1 CS 456 Software Engineering. 2 Contents 3 Chapter 1: Introduction.
Intro to Architecture – Page 1 of 22CSCI 4717 – Computer Architecture CSCI 4717/5717 Computer Architecture Topic: Introduction Reading: Chapter 1.
Object Oriented Programming with JAVA Arash N. Kia AlZahra University Definitions – Part 1.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
Object-Oriented (Real World Case) Object-Oriented Analysis CIM2566 Bavy LI.
CSSE501 Object-Oriented Development. Chapter 11: Static and Dynamic Behavior  In this chapter we will examine the differences between static and dynamic.
1 OBJECT-ORIENTED THINKING Ziya Karakaya Atılım University Tel: (312) / 5345 Faks: (312) E-posta:
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 14 Slide 1 Object-oriented Design.
OBJECT-ORIENTED PROGRAMMING (OOP) WITH C++ Instructor: Dr. Hany H. Ammar Dept. of Electrical and Computer Engineering, WVU.
Abstraction CMPS Abstraction Abstraction mechanisms are techniques to deal with creating, understanding and managing complex systems Abstraction.
Design Model Lecture p6 T120B pavasario sem.
Object-Oriented Programming with Java Lecture 1: Introduction Autumn, 2007.
Learners Support Publications Object Oriented Programming.
Abstraction ADTs, Information Hiding and Encapsulation.
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.
CSCI-383 Object-Oriented Programming & Design Lecture 10.
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.
9-Dec Dec-15  INTRODUCTION.  FEATURES OF OOP.  ORGANIZATION OF DATA & FUNCTION IN OOP.  OOP’S DESIGN.
CSCI 383 Object-Oriented Programming & Design Lecture 3 Martin van Bommel.
OOP (Object Oriented Programming) Lecture 1. Why a new paradigm is needed? Complexity Five attributes of complex systems –Frequently, complexity takes.
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.
Basic Concepts of OOP.  Object-Oriented Programming (OOP) is a type of programming added to php5 that makes building complex, modular and reusable web.
CSCI 383 Object-Oriented Programming & Design Lecture 4 Martin van Bommel.
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Basic Characteristics of Object-Oriented Systems
Sadegh Aliakbary Sharif University of Technology Fall 2010.
CSCI 383 Object-Oriented Programming & Design Lecture 15 Martin van Bommel.
OOP - Object Oriented Programming
Programming paradigms
JAVA By Waqas.
Object-Oriented Analysis and Design
Chapter 1: Object-Oriented Thinking
Object-Oriented Programming
Presentation transcript:

CSCI-383 Object-Oriented Programming & Design Lecture 3

OOP: The General Principle “ An object oriented program is structured as a community of interacting agents called objects. Action is initiated in object oriented programming by the transmission of a message to an agent (an object). The message encodes the request for action and is accompanied by additional information (arguments) needed to carry out the request. The receiver is the agent to which 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. “

OOP: A Way of Viewing the World “Chris wants to send some flowers to his friend Robin who lives in a distant city. Because of the distance, Chris cannot pick up the flowers and bring them to Robin in person. Chris goes down to Fred a local florist and tells him the number and type of flowers he wants together with the address they need to be delivered to. Chris can rest assure that the flowers will be delivered. ”

Agents, Responsibility, Messages, Methods  Chris finds an appropriate agent (Fred)  And passes to her a message containing a request  It is the responsibility of Fred to satisfy the request  There is some method -a set of operations- used by Fred to do this  Chris does not need to know the particular method he will use, this information is hidden from inspection

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd Behavior and Interpretation  Although different objects may accept the same message, the actions (behavior) the object will perform will likely be different When Fred would ask his wife Beth to send some flowers to Robin for her birthday she might use a different method than the florist Fred  determination of what behavior to perform may be made at run-time, a form of late binding  The fact that the same name can mean two entirely different operations is one form of polymorphism, a topic we will discuss at length in subsequent chapters

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd Elements of OOP - Recursive Design  Every object has it's own memory, which consists of other objects  Each object is like a miniature computer itself - a specialized processor performing a specific task

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd Non-interference  It is important that objects be allowed to perform their task however they see fit, without unnecessary interactions or interference with other objects “Instead of a bit-grinding processor... plundering data structures, we have a universe of well-behaved objects that courteously ask each other to carry out their various desires” -- Dan Ingalls “Ask not what you can do to your data structures, but ask what your data structures can do for you”

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd Elements of OOP - Classes  Every object is an instance of a class. A class groups similar objects  The class is the repository for behavior associated with an object  The behavior I expect from Fred is determined from a general idea I have of the behavior of Florists  We say Fred is an instance of the class Florist  Behavior is associated with classes, not with individual instances. All objects that are instances of a class use the same method in response to similar messages

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd Hierarchies of Categories  But there is more that I know about Fred than just that he is a Florist. I know he is a ShopKeeper, and a Human, and a Mammal, and a Material Objects, and so on  At each level of abstraction I have certain information recorded. That information is applicable to all lower (more specialized) levels

Elements of OOP - Inheritance  The principle that knowledge of a more general category is also applicable to a more specific category is called inheritance  Classes can be organised into a hierarchical inheritance structure. A child class (or subclass) will inherit attributes from a parent class (super class) higher up in the hierarchy. An abstract parent class is a class for which there are no direct instances, it is only introduced to group subclasses

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd Hierarchies of Categories

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd Class Hierarchies

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd Elements of OOP - Overriding  Subclasses can alter or override information inherited from parent classes: All mammals give birth to live young A platypus is an egg-laying mammal  The search for a method to use in response to a message starts with the receiver’s class and continues up the parent chain. When methods with the same name are available higher in the class hierarchy the method that executes is said to override the inherited behavior  Inheritance combined with overriding are where most of the power of OO originates

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd Problem Solving  Because the OOP view is similar to the way in which people go about solving problems in real life (finding another agent to do the real work!), intuition, ideas, and understanding from everyday experience can be brought to bear on computing  On the other hand, common sense was seldom useful when computers were viewed in the process- state model, since few people solve their everyday problems using pigeon-holes

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd From Newsweek  “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.”

Chapter 2 Abstraction

Coping with Complexity  Is the complexity of a programming project linear in terms of the number of programmers involved? E.g., Can two programmers do in one month what one programmer can do in 2 months ?  Interconnectedness, the dependence of one portion of code on another portion, is responsible for this phenomena  Abstraction mechanisms try to cope with this and object oriented techniques offer yet another step forward

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd Abstraction  What is abstraction? Abstraction is the purposeful suppression, or hiding, of some details of a process or artifact, in order to bring out more clearly other aspects, details, or structure  Think of a model, give an example of a model  Do we need it? Why? Yes, mainly because it helps us to deal with complexity

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd Information Hiding  Information hiding is the purposeful omission of details in the development of an abstract representation  Information hiding is what allows abstraction to control complexity

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd Abstraction in an Atlas  Think of an atlas, and the various different levels of maps A map of the world, contains mountain ranges, large political boundaries A map of a continent, contains all political boundaries, large cities A map of a country, contains more cities, major roads A map of a large city, roads, major structures A map of a portion of a city, buildings, occupants  Each level contains information appropriate to the level of abstraction

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd Levels of Abstraction in OO Programs  At the highest level of abstraction we view a program as a community of interacting objects  Important characteristics here are the lines of communication between the various agents

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd Levels of Abstraction in OO Programs (cont’d)  The next level of abstraction is found in some (but not all) OO languages. A package, Unit or Name Space allows a programmer to surround a collection of objects (a small community in itself) with a layer, and control visibility from outside the module

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd Levels of Abstraction in OO Programs (cont’d)  The next level of abstraction considers the relationship between two individual objects. Typically one is providing a service, and the other is using the service

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd Levels of Abstraction in OO Programs (cont’d)  We can next examine just the person providing a service, independent of the client. We define the nature of the services that are offered, but not how those services are realized

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd Levels of Abstraction in OO Programs (cont’d)  Next we look at the services provided, but from the implementation side public class LinkedList implements Stack... { public void pop () throws EmptyStackException {... }... }  Concern here is with the high level approach to providing the designated service

Adapted From: An Introduction to Object Oriented Programming, 3 rd Edition, by Timothy Budd Levels of Abstraction in OO Programs (cont’d)  Finally, we consider the implementation of each method in isolation public class LinkedList implements Stack... {... public void pop () throws EmptyStackException { if (isEmpty()) throw new EmptyStackException(); removeFirst(); // delete first element of list }... }  Every level is important, and often you move quickly back and forth between levels