1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 22: Object-Oriented Programming COMP 144 Programming Language Concepts Spring 2002.

Slides:



Advertisements
Similar presentations
OBJECT ORIENTED PROGRAMMING M Taimoor Khan
Advertisements

1 Object-Oriented Programming (Section ) CSCI 431 Programming Languages Fall 2003 A compilation of material developed by Felix Hernandez-Campos.
Unified Modeling Language
Chapter 12: Support for Object-Oriented Programming
1 Data Abstraction and Object Orientation. 2 Chapter 9: Data Abstraction and Object Orientation 9.1 Encapsulation and Inheritance 9.2 Initialization and.
Object-Oriented PHP (1)
1 CS1001 Lecture Overview Homework 3 Homework 3 Project/Paper Project/Paper Object Oriented Design Object Oriented Design.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 23: Object Lifetime and Garbage Collection COMP 144 Programming Language Concepts.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 24: Dynamic Binding COMP 144 Programming Language Concepts Spring 2002 Felix Hernandez-Campos.
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
Inheritance and Polymorphism CS351 – Programming Paradigms.
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
Object Oriented Programming
Introduction to Object-oriented Programming Introduction to Object-oriented Programming CMPS 2143.
CSCI-383 Object-Oriented Programming & Design Lecture 15.
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.
Design Patterns OOD. Course topics Design Principles UML –Class Diagrams –Sequence Diagrams Design Patterns C#,.NET (all the course examples) Design Principles.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
OOPs Object oriented programming. Based on ADT principles  Representation of type and operations in a single unit  Available for other units to create.
CISC6795: Spring Object-Oriented Programming: Polymorphism.
CS 403 – Programming Languages Class 25 November 28, 2000.
1 Chapter 10: Data Abstraction and Object Orientation Aaron Bloomfield CS 415 Fall 2005.
1 Java Inheritance. 2 Inheritance On the surface, inheritance is a code re-use issue. –we can extend code that is already written in a manageable manner.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
Database Management System Prepared by Dr. Ahmed El-Ragal Reviewed & Presented By Mr. Mahmoud Rafeek Alfarra College Of Science & Technology Khan younis.
Unified Modeling Language, Version 2.0
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Programming Languages and Paradigms Object-Oriented Programming.
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 in the Java programming language J. W. Rider.
OOP Class Lawrence D’Antonio Lecture 3 An Overview of C++
1 COMP313A Programming Languages Object Oriented Progamming Languages (3)
OOP: Encapsulation,Abstraction & Polymorphism. What is Encapsulation Described as a protective barrier that prevents the code and data being randomly.
Chapter 12 Support for Object oriented Programming.
Object-Oriented Data Modeling
Lecture 10 Concepts of Programming Languages Arne Kutzner Hanyang University / Seoul Korea.
CS451 - Lecture 2 1 CS451 Lecture 2: Introduction to Object Orientation Yugi Lee STB #555 (816) * Acknowledgement:
Session 24 Chapter 12: Polymorphism. Polymorphism polymorphism comes from the Greek root for “many forms” polymorphism is about how we can use different.
Chapter 12 Support for Object-Oriented Programming.
Object-Oriented Programming Chapter Chapter
(1) ICS 313: Programming Language Theory Chapter 12: Object Oriented Programming.
OOPs Object oriented programming. Abstract data types  Representationof type and operations in a single unit  Available for other units to create variables.
ISBN Object-Oriented Programming Chapter Chapter
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.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Basic Concepts of OOP.  Object-Oriented Programming (OOP) is a type of programming added to php5 that makes building complex, modular and reusable web.
Java Inheritance in Java. Inheritance Inheritance is a mechanism in which one object acquires all the properties and behaviors of parent object. The idea.
1 Lecture 23: Dynamic Binding (Section ) CSCI 431 Programming Languages Fall 2002 A compilation of material developed by Felix Hernandez-Campos.
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)
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
C++ General Characteristics: - Mixed typing system - Constructors and destructors - Elaborate access controls to class entities.
CSCE 240 – Intro to Software Engineering Lecture 3.
ISBN Chapter 12 Support for Object-Oriented Programming.
Object Oriented Programming in Java Habib Rostami Lecture 2.
Chapter 12: Support for Object- Oriented Programming Lecture # 18.
CSCI 383 Object-Oriented Programming & Design Lecture 15 Martin van Bommel.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Object-Oriented Programming
Types of Programming Languages
Object Oriented Analysis and Design
Chapter 20 Object-Oriented Analysis and Design
More Object-Oriented Programming
Support for Object-Oriented Programming
Object-Oriented Programming
Inheritance and Polymorphism
Object-Oriented PHP (1)
Lecture 10 Concepts of Programming Languages
Presentation transcript:

1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 22: Object-Oriented Programming COMP 144 Programming Language Concepts Spring 2002 Felix Hernandez-Campos March 11 The University of North Carolina at Chapel Hill

2 COMP 144 Programming Language Concepts Felix Hernandez-Campos Fundamental Concepts in OOP EncapsulationEncapsulation –Data Abstraction –Information hiding –The notion of class and object InheritanceInheritance –Code reusability –Is-a vs. has-a relationships PolymorphismPolymorphism –Dynamic method binding

3 COMP 144 Programming Language Concepts Felix Hernandez-Campos Encapsulation Data abstraction allow programmers to hide data representation details behind a (comparatively) simple set of operations (an interface)Data abstraction allow programmers to hide data representation details behind a (comparatively) simple set of operations (an interface) What the benefits of data abstraction?What the benefits of data abstraction? –Reduces conceptual load »Programmers need to knows less about the rest of the program –Provides fault containment »Bugs are located in independent components –Provides a significant degree of independence of program components »Separate the roles of different programmer SoftwareEngineeringGoals

4 COMP 144 Programming Language Concepts Felix Hernandez-Campos Encapsulation Classes, Objects and Methods The unit of encapsulation in an O-O PL is a classThe unit of encapsulation in an O-O PL is a class –An abstract data type »The set of values is the set of objects (or instances) Objects can have aObjects can have a –Set of instance attributes (has-a relationship) –Set of instance methods Classes can have aClasses can have a –Set of class attributes –Set of class methods Method calls are known as messages The entire set of methods of an object is known as the message protocol or the message interface of the objectThe entire set of methods of an object is known as the message protocol or the message interface of the object

5 COMP 144 Programming Language Concepts Felix Hernandez-Campos Inheritance Encapsulation improves code reusabilityEncapsulation improves code reusability –Abstract Data Types –Modules –Classes However, it is generally the case that the code a programmer wants to reuse is close but not exactly what the programmer needsHowever, it is generally the case that the code a programmer wants to reuse is close but not exactly what the programmer needs Inheritance provides a mechanism to extend or refine units of encapsulationInheritance provides a mechanism to extend or refine units of encapsulation –By adding or overriding methods –By adding attributes

6 COMP 144 Programming Language Concepts Felix Hernandez-Campos Inheritance Notation Java.awt.Dialog Java.awt.FileDialog Base Class (or Parent Class or Superclass) Derived Class (or Child Class or Subclass) Is-a relationship

7 COMP 144 Programming Language Concepts Felix Hernandez-Campos Polymorphism The is-a relationship supports the development of generic operations that can be applied to objects of a class and all its subclassesThe is-a relationship supports the development of generic operations that can be applied to objects of a class and all its subclasses –This feature is known as polymorphism –E.g. paint() method The binding of messages to method definition is instance-dependent, and it is known as dynamic bindingThe binding of messages to method definition is instance-dependent, and it is known as dynamic binding –It has to be resolved at run-time –Dynamic binding requires the virtual keyword in C++ –Static binding requires the final keyword in Java

8 COMP 144 Programming Language Concepts Felix Hernandez-Campos Encapsulation Modules and Classes The basic unit of OO, the class, is a unit of scopeThe basic unit of OO, the class, is a unit of scope –This idea originated in module-based languages in the mid-70s »E.g. Clu, Modula, Euclid Rules of scope enforce data hidingRules of scope enforce data hiding –Names have to be exported in order to be accessible by other modules –What kind of data hiding mechanisms we have in Java? » –And in Python? » http://

9 COMP 144 Programming Language Concepts Felix Hernandez-Campos Classes and Encapsulation Two Views Module-as-typeModule-as-type –A module is an abstract data type –Standardized constructor and destructor syntax –Object-oriented design is applied everywhere –E.g. Java, Smalltalk, Eiffel, C++, Python Module-as-managerModule-as-manager –A module exports an abstract data type –Create and destroy operations –Object-oriented design is optional (OO as an extension) –E.g. Ada 95, Modula-3, Oberon, CLOS, Perl

10 COMP 144 Programming Language Concepts Felix Hernandez-Campos Ada 95

11 COMP 144 Programming Language Concepts Felix Hernandez-Campos Ada 95

12 COMP 144 Programming Language Concepts Felix Hernandez-Campos Ada 95

13 COMP 144 Programming Language Concepts Felix Hernandez-Campos Reading Assignment ScottScott –Read Ch. 10 intro –Read Sect »Study the list and queue examples –Read Sect »Go through the documents linked in slide 8