CS 403 – Programming Languages Class 25 November 28, 2000.

Slides:



Advertisements
Similar presentations
Object-Oriented Programming Session 9 Course : T Programming Language Concept Year : February 2011.
Advertisements

MT311 (Oct 2007) Java Application Development Object-Oriented Programming Languages Tutorial 8.
ISBN Chapter 12 Support for Object-Oriented Programming.
Software Productivity
Chapter 12 Support for Object-Oriented Programming.
Chapter 12: Support for Object-Oriented Programming
Object-Oriented Programming CS 3360 Spring 2012 Sec , Adapted from Addison Wesley’s lecture notes (Copyright © 2004 Pearson Addison.
Session 07: C# OOP 4 Review of: Inheritance and Polymorphism. Static and dynamic type of an object. Abstract Classes. Interfaces. FEN AK - IT:
ISBN Chapter 12 Support for Object-Oriented Programming.
Object-Oriented Programming
1 Evan Korth New York University Inheritance and Polymorphism Professor Evan Korth New York University.
1 Evan Korth New York University Inheritance and Polymorphism Professor Evan Korth New York University.
1 Chapter 12 © 2002 by Addison Wesley Longman, Inc Introduction - Categories of languages that support OOP: 1. OOP support is added to an existing.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
© 2006 Pearson Addison-Wesley. All rights reserved9 A-1 Chapter 9 Advanced Java Topics CS102 Sections 51 and 52 Marc Smith and Jim Ten Eyck Spring 2007.
CS 330 Programming Languages 12 / 09 / 2008 Instructor: Michael Eckmann.
Inheritance and Polymorphism CS351 – Programming Paradigms.
ISBN Chapter 12 Support for Object- Oriented Programming.
CS 355 – PROGRAMMING LANGUAGES Dr. X. Copyright © 2012 Addison-Wesley. All rights reserved.1-2 Chapter 12 Topics Introduction Object-Oriented Programming.
Support for Object-Oriented Programming
Chapter 12 Support for Object-Oriented Programming.
CPS 506 Comparative Programming Languages
1 Chapter 11 Abstract Data Types and Encapsulation Constructs.
ISBN Chapter 12 Support for Object-Oriented Programming.
Chapter 11 and 12: Abstract Data Types and Encapsulation Constructs; Support for Object Orientation Lesson 11.
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.
Object-Oriented Programming Session 9 Course : T Programming Language Concept Year : February 2011.
Object-oriented programming: C++ class A { private: …… // can be accessd by A protected: …… // can be accessed by A and // its derived classes public:
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
 OOPLs  Help companies reduce complexity  Increase competition in open markets  Speeds up development  Improves maintenance, resusability, modifiability.
April 30, ICE 1341 – Programming Languages (Lecture #18) In-Young Ko Programming Languages (ICE 1341) Lecture #18 Programming Languages (ICE 1341)
Introduction to Object Oriented Programming CMSC 331.
Chapter 12 Support for Object oriented Programming.
Chapter 12 Support for Object-Oriented Programming.
ISBN Chapter 12 Support for Object-Oriented Programming.
Chapter 12 Support for Object-Oriented Programming.
1 Abstract Data Types & Object Orientation Abstract Data Types (ADT) Concepts –Data Abstraction –ADT in PLs –Encapsulation Object Orientation –Principal.
ISBN Chapter 12 Support for Object-Oriented Programming.
Lecture 10 Concepts of Programming Languages Arne Kutzner Hanyang University / Seoul Korea.
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.
1 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 11 Categories of languages that support OOP: 1. OOP support is added to an existing language.
ISBN Object-Oriented Programming Chapter Chapter
C++ General Characteristics: - Mixed typing system - Constructors and destructors - Elaborate access controls to class entities.
ISBN Chapter 12 Support for Object-Oriented Programming.
Object Oriented Programming CMSC 331. Concept of Abstraction “An abstraction is a view or representation of an entity that includes only the attributes.
Chapter 12: Support for Object- Oriented Programming Lecture # 18.
CSCI 383 Object-Oriented Programming & Design Lecture 15 Martin van Bommel.
Support for Object-Oriented Programming
12.1 Introduction - Categories of languages that support OOP:
Support for Object-Oriented Programming
Support for Object-Oriented Programming
CMP 339/692 Programming Languages Day 24 Tuesday May 1, 2012
Types of Programming Languages
Support for Object-Oriented Programming
Support for Object-Oriented Programming
Advanced Java Topics Chapter 9
Object-Oriented Programming
Support for Object-Oriented Programming
Support for Object-Oriented Programming
Object-Oriented Programming
Support for Object-Oriented Programming
Support for Object-Oriented Programming
Lecture 10 Concepts of Programming Languages
Chapter 12 Categories of languages that support OOP:
Presentation transcript:

CS 403 – Programming Languages Class 25 November 28, 2000

Announcements CS 438 Computer Networks offered spring TR 2:00-3:15 Taught by Sibu Ray Engineering Career Services: If you plan to interview for full time jobs or internships this spring, you must register in 130 MIB. An orientation session is required. May, Aug or Dec 2001 graduates should register now. Many companies only come once/year!

Announcement: EE 116 lab Card swipe is supposed to go active tomorrow. Students must be on the “official CS list” to get access. Current list includes all students in CS 403, 415, 457 and 491. EE 121 will be activated soon, but the lab is for CS graduate students.

Languages categories that support OOP OOP support is added to an existing language C++ (also supports procedural and data-oriented programming) Ada 95 (also supports procedural and data- oriented programming) CLOS (also supports functional programming) Scheme (also supports functional programming)

Languages categories that support OOP (2) Support OOP, but have the same appearance and use the basic structure of earlier imperative languages Eiffel (not based directly on any previous language) Java (based on C++) Pure OOP languages Smalltalk

Paradigm Evolution 1. Procedural s-1970s (procedural abstraction) 2. Data-Oriented - early 1980s (data-oriented) 3. OOP - late 1980s (Inheritance and dynamic binding)

Origins of Inheritance Observations of the mid-late 1980s: Productivity increases can come from reuse ADTs are difficult to reuse--never quite right All ADTs are independent and at the same level Inheritance solves both--reuse ADTs after minor changes and define classes in a hierarchy

OOP Definitions ADTs are called classes. Class instances are called objects. A class that inherits is a derived class or a subclass. The class from which another class inherits is a parent class or superclass. Subprograms that define operations on objects are called methods. The entire collection of methods of an object is called its message protocol or message interface. –Messages have two parts--a method name and the destination object. –In the simplest case, a class inherits all of the entities of its parent.

Inheritance and OOP Inheritance can be complicated by access controls to encapsulated entities. A class can hide entities from its subclasses. A class can hide entities from its clients. Besides inheriting methods as is, a class can modify an inherited method. The new one overrides the inherited one. The method in the parent is overridden.

Variables in a class There are two kinds of variables in a class: 1.Class variables - one/class 2.Instance variables - one/object There are two kinds of methods in a class: 1.Class methods - messages to the class 2.Instance methods - messages to objects

Inheritance Issues Single vs. Multiple Inheritance Disadvantage of inheritance for reuse: Creates interdependencies among classes that complicate maintenance.

Polymorphism in OOPLs A polymorphic variable can be defined in a class that is able to reference (or point to) objects of the class and objects of any of its descendants. When a class hierarchy includes classes that override methods and such methods are called through a polymorphic variable, the binding to the correct method MUST be dynamic.

Polymorphism in OOPLs (2) This polymorphism simplifies the addition of new methods. A virtual method is one that does not include a definition (it only defines a protocol). A virtual class is one that includes at least one virtual method. A virtual class cannot be instantiated.

Design Issues for OOPLs 1.The Exclusivity of Objects 2.Are Subclasses Subtypes? 3.Implementation and Interface Inheritance 4.Type Checking and Polymorphism 5.Single and Multiple Inheritance 6.Allocation and Deallocation of Objects 7.Dynamic and Static Binding

1. The Exclusivity of Objects a. Everything is an object Advantage - elegance and purity Disadvantage - slow operations on simple objects (e.g., float) b. Add objects to a complete typing system Advantage - fast operations on simple objects Disadvantage - results in a confusing type system c. Include an imperative-style typing system for primitives but make everything else objects Advantage - fast operations on simple objects and a relatively small typing system Disadvantage - still some confusion because of the two type systems

2. Are Subclasses Subtypes? Does an is-a relationship hold between a parent class object and an object of the subclass?

3. Implementation and Interface Inheritance If only the interface of the parent class is visible to the subclass, it is interface inheritance. –Disadvantage - can result in inefficiencies If both the interface and the implementation of the parent class is visible to the subclass, it is implementation inheritance. –Disadvantage - changes to the parent class require recompilation of subclasses, and sometimes even modification of subclasses.

4. Type Checking and Polymorphism Polymorphism may require dynamic type checking of parameters and the return value. –Dynamic type checking is costly and delays error detection. If overriding methods are restricted to having the same parameter types and return type, the checking can be static.

5. Single and Multiple Inheritance Disadvantage of multiple inheritance: Language and implementation complexity Potential inefficiency - dynamic binding costs more with multiple inheritance (but not much) Advantage: Sometimes it is extremely convenient and valuable.

6. Allocation and Deallocation of Objects From where are objects allocated? If they all live in the heap, references to them are uniform. Is deallocation explicit or implicit?

7. Dynamic and Static Binding Should ALL binding of messages to methods be dynamic?

OO Languages Smalltalk C++ Java Ada Eiffel