Chapter 12 Support for Object oriented Programming.

Slides:



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

Object-Oriented Programming Python. OO Paradigm - Review Three Characteristics of OO Languages –Inheritance It isn’t necessary to build every class from.
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.
Object Oriented Programming Chapter 7 Programming Languages by Ravi Sethi.
ISBN Chapter 12 Support for Object-Oriented Programming.
Object-Oriented Programming
1 Chapter 12 © 2002 by Addison Wesley Longman, Inc Introduction - Categories of languages that support OOP: 1. OOP support is added to an existing.
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.
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.
An Object-Oriented Approach to Programming Logic and Design
CS 403 – Programming Languages Class 25 November 28, 2000.
Object-Oriented Programming Session 9 Course : T Programming Language Concept Year : February 2011.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
OOP and Dynamic Method Binding Chapter 9. Object Oriented Programming Skipping most of this chapter Focus on 9.4, Dynamic method binding – Polymorphism.
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.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
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
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
C++ General Characteristics: - Mixed typing system - Constructors and destructors - Elaborate access controls to class entities.
ISBN Chapter 12 Support for Object-Oriented Programming.
Chapter 12: Support for Object- Oriented Programming Lecture # 18.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Object-Oriented Programming
Support for Object-Oriented Programming
12.1 Introduction - Categories of languages that support OOP:
Support for Object-Oriented Programming
7.1 What Is An Object Object-oriented program - Description or simulation of application Object-oriented programming is done by adopting or extending an.
Support for Object-Oriented Programming
CMP 339/692 Programming Languages Day 24 Tuesday May 1, 2012
OOP What is problem? Solution? OOP
Object Oriented Programming in Java
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Types of Programming Languages
Support for Object-Oriented Programming
Support for Object-Oriented Programming
Java Programming Language
Object-Oriented Programming
Testing with OO OO has several key concepts:
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:

Chapter 12 Support for Object oriented Programming

Categories of languages that support OOP 1. 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)  Scheme (also supports functional programming)

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++). 3. Pure OOP languages Smalltalk

Inheritance 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.

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

Inheritance 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 overriden. There are two kinds of variables in a class: - Class variables - one/class. - Instance variables - one/object.

Inheritance There are two kinds of methods in a class: - Class methods - messages to the class. - Instance methods - messages to objects. Single and Multiple Inheritance: Does the language allow multiple inheritance ? The purpose of multiple inheritance is to allow a new class to inherit from two or more classes. Ambiguity problem is further complicated when the two parent classes both define identically named methods and one or both of them must be overridden in the subclass.

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.

Polymorphism  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.  This polymorphism simplifies the addition of new methods.  A virtual class is one that includes at least one virtual method.  A virtual class cannot be instantiated.

Overview of Smalltalk  Smalltalk is a pure OOP language Everything is an object All computation is through objects sending messages to objects It adopts none of the appearance of imperative languages.  The Smalltalk Environment The first complete GUI system

Overview of Smalltalk A complete system for software development. All of the system source code is available to the user, who can modify it if he/she wants. Introduction to Smalltalk:  Expressions Four kinds: 1.Literals (numbers, strings, and keywords) 2.Variable names (all variables are references) 3.Message expressions. 4.Block expressions

Overview of Smalltalk  Message expressions Two parts: the receiver object and the message itself. The message part specifies the method and possibly some parameters. Replies to messages are objects  Messages can be of three forms: 1.Unary (no parameters) e.g., myAngle sin (sends a message to the sin method of the myAngle object).

Overview of Smalltalk 2. Binary (one parameter, an object) e.g., (sends the message “+ 17” to the object 12; the object parameter is “17” and the method is “+”)

Assignments Simplest Form: name1 <- name2 -It is simply a pointer assignment -RHS can be a message expression e.g., index <- index + 1.

Large-Scale Features of Smalltalk  Type Checking and Polymorphism  All bindings of messages to methods is dynamic. - The process is to search the object to which the message is sent for the method; if not found, search the superclass, etc.  Because all variables are typeless, methods are all polymorphic

 Inheritance  All subclasses are subtypes (nothing can be hidden).  All inheritance is implementation inheritance  No multiple inheritance  Methods can be redefined, but the two are not related.

Dynamic Binding The dynamic binding of messages to methods in Smalltalk operates as follows: A message to an object causes a search of the class to which the object belongs for a corresponding method. If the search fails, it is continued in the superclass of that class, and so forth, up to the system class, Object, which has no superclass. Object is the root of the class derivation tree on which every class is a node.

he only type checking in Smalltalk is dynamic, and the only type error occurs when a message is sent to an object that has no matching method, either locally or through inheritance. Smalltalk variables are not typed; any name can be bound to any object. As a direct result, Smalltalk supports dynamic polymorphism.

Evaluation in Smalltalk Smalltalk is a small language, although the Smalltalk system is large. The syntax of the language is simple and highly regular. In the case of Smalltalk, that concept is that all programming can be done employing only a class hierarchy built using inheritance, objects, and message passing.