1 Object-Oriented Programming (Section 10.1-10.2) CSCI 431 Programming Languages Fall 2003 A compilation of material developed by Felix Hernandez-Campos.

Slides:



Advertisements
Similar presentations
OBJECT ORIENTED PROGRAMMING M Taimoor Khan
Advertisements

Chapter 12: Support for Object-Oriented Programming
Object-Oriented PHP (1)
ISBN Chapter 11 Abstract Data Types and Encapsulation 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.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 22: Object-Oriented Programming COMP 144 Programming Language Concepts Spring 2002.
Lecture 9 Concepts of Programming Languages
Abstract Data Types and Encapsulation Concepts
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.
CS 355 – PROGRAMMING LANGUAGES Dr. X. Copyright © 2012 Addison-Wesley. All rights reserved.1-2 Chapter 12 Topics Introduction Object-Oriented Programming.
UFCEUS-20-2 : Web Programming Lecture 5 : Object Oriented PHP (1)
Programming Languages and Paradigms Object-Oriented Programming.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
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( 李德成 )
1 Binding Time and Storage Allocation (Section ) CSCI 431 Programming Languages Fall 2003 A modification of slides developed by Felix Hernandez-Campos.
The Evolution of the Object Model OOAD. The Evolution of the Object Model software engineering trends observed The shift in focus from programming-in-the-small.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
1 Chapter 10: Data Abstraction and Object Orientation Aaron Bloomfield CS 415 Fall 2005.
Database Management System Prepared by Dr. Ahmed El-Ragal Reviewed & Presented By Mr. Mahmoud Rafeek Alfarra College Of Science & Technology Khan younis.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
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.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
OOP Class Lawrence D’Antonio Lecture 3 An Overview of C++
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
Chapter 10, Slide 1 ABSTRACT DATA TYPES Based on the fundamental concept of ABSTRACTION:  process abstraction  data abstraction Both provide:  information.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Chapter 12 Support for Object-Oriented Programming.
Object-Oriented Programming Chapter Chapter
ISBN Object-Oriented Programming Chapter Chapter
Copyright © 2005 Elsevier Object-Oriented Programming Control or PROCESS abstraction is a very old idea (subroutines!), though few languages provide it.
1 Chapter 11 © 1998 by Addison Wesley Longman, Inc The Concept of Abstraction - The concept of abstraction is fundamental in programming - Nearly.
1 CS Programming Languages Class 22 November 14, 2000.
1 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 10 Abstraction - The concept of abstraction is fundamental in programming - Nearly all programming.
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.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
1 Lecture 23: Dynamic Binding (Section ) CSCI 431 Programming Languages Fall 2002 A compilation of material developed by Felix Hernandez-Campos.
C++ General Characteristics: - Mixed typing system - Constructors and destructors - Elaborate access controls to class entities.
Copyright © 2009 Elsevier Chapter 9 :: Data Abstraction and Object Orientation Programming Language Pragmatics Michael L. Scott.
1 C++ Classes & Object Oriented Programming Overview & Terminology.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
ISBN Chapter 12 Support for Object-Oriented Programming.
CPS120: Introduction to Computer Science Lecture 16A Object-Oriented Concepts.
Object Oriented Programming in Java Habib Rostami Lecture 2.
CSCI 383 Object-Oriented Programming & Design Lecture 15 Martin van Bommel.
Chapter 11: Abstract Data Types Lecture # 17. Chapter 11 Topics The Concept of Abstraction Advantages of Abstract Data Types Design Issues for Abstract.
CS 3304 Comparative Languages
Abstract Data Types and Encapsulation Concepts
Chapter 9 :: Data Abstraction and Object Orientation
ABSTRACT DATA TYPES Based on the fundamental concept of ABSTRACTION:
Review: Two Programming Paradigms
Object-Oriented Programming & Design Lecture 14 Martin van Bommel
11.1 The Concept of Abstraction
Types of Programming Languages
Copyright © 2009 Elsevier Chapter 9 :: Data Abstraction and Object Orientation Programming Language Pragmatics Michael L. Scott.
Object Oriented Analysis and Design
Chapter 9 :: Data Abstraction and Object Orientation
Abstract Data Types and Encapsulation Concepts
More Object-Oriented Programming
Chapter 9 :: Data Abstraction and Object Orientation
Parameter Passing Actual vs formal parameters
Object-Oriented PHP (1)
Chapter 10 :: Object Orientated Programming
11.1 The Concept of Abstraction
Chapter 11 Abstraction - The concept of abstraction is fundamental in
Presentation transcript:

1 Object-Oriented Programming (Section ) CSCI 431 Programming Languages Fall 2003 A compilation of material developed by Felix Hernandez-Campos and Michael Scott

2 Data Abstraction and Object Orientation Control or process abstraction is a very old idea (subroutines!), though few languages provide it in a truly general form (Scheme comes close).Control or process abstraction is a very old idea (subroutines!), though few languages provide it in a truly general form (Scheme comes close). Data abstraction is somewhat newer, though its roots can be found in Simula67.Data abstraction is somewhat newer, though its roots can be found in Simula67. An Abstract Data Type is one that is defined (from the user’s point of view) in terms of the operations that it supports (i.e. that can be performed upon it) rather than in terms of its structure or implementation.An Abstract Data Type is one that is defined (from the user’s point of view) in terms of the operations that it supports (i.e. that can be performed upon it) rather than in terms of its structure or implementation.

3 Historical Development of Abstraction We’ve talked about data abstraction previously. Recall the historical development of data abstraction mechanisms:We’ve talked about data abstraction previously. Recall the historical development of data abstraction mechanisms: global set of variablesBasic localsFortran staticsFortran, Algol 60, C modulesModula-2, Ada 83 module typesEuclid objectsSmalltalk, C++, Eiffel, Java, Oberon, Modula-3, Ada 95 Oberon, Modula-3, Ada 95

4 Fundamental Concepts in OOP EncapsulationEncapsulation –Data Abstraction –Information hiding InheritanceInheritance –Code reusability –Is-a vs. has-a relationships PolymorphismPolymorphism –Dynamic method binding

5 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

6 Encapsulation Classes, Objects and Methods The unit of encapsulation in an OO PL is a classThe unit of encapsulation in an OO 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

7 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 appeared 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

8 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

9 Visibility Rules Public and Private parts of an object declaration/definition.Public and Private parts of an object declaration/definition. 2 reasons to put things in the declaration2 reasons to put things in the declaration – so programmers can get at them – so the compiler can understand them At the very least the compiler needs to know the size of an object, even though the programmer isn't allowed to get at many or most of the fields (members) that contribute to that size. That's why private fields of an object have to be in the declaration.At the very least the compiler needs to know the size of an object, even though the programmer isn't allowed to get at many or most of the fields (members) that contribute to that size. That's why private fields of an object have to be in the declaration.

10 Access Restrictions C++ distinguishes amongC++ distinguishes among – public – protected – private class members. class members. Public means accessible to anybody.Public means accessible to anybody. Private means just to members of this class.Private means just to members of this class. Protected means to members of this or derived classes.Protected means to members of this or derived classes. A C++ struct is simply a class whose members are public by default.A C++ struct is simply a class whose members are public by default. C++ base classes can also be public, private, or protected. E.g.C++ base classes can also be public, private, or protected. E.g. class circle : public shape {... anybody can convert (assign) a circle* into a shape*

11 C++ List Example

12 C++ Example

13

14

15 Ada 95

16

17