Chapter 12: Support for Object- Oriented Programming Lecture # 18.

Slides:



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

Chapter 1 OO using C++. Abstract Data Types Before we begin we should know how to accomplish the goal of the program We should know all the input and.
OBJECT ORIENTED PROGRAMMING M Taimoor Khan
CS 211 Inheritance AAA.
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.
Inheritance Polymorphism Briana B. Morrison CSE 1302C Spring 2010.
ISBN Chapter 12 Support for Object-Oriented Programming.
Object-Oriented Programming
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 24: Dynamic Binding COMP 144 Programming Language Concepts Spring 2002 Felix Hernandez-Campos.
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.
Lecture 6: Polymorphism - The fourth pillar of OOP - 1.
CSCI-383 Object-Oriented Programming & Design Lecture 15.
Support for Object-Oriented Programming
Chapter 12 Support for Object-Oriented Programming.
CPS 506 Comparative Programming Languages
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.
ISBN Chapter 12 Support for Object-Oriented Programming.
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
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.
CS 403 – Programming Languages Class 25 November 28, 2000.
Object Oriented Programming: Java Edition By: Samuel Robinson.
Object-Oriented Programming Session 9 Course : T Programming Language Concept Year : February 2011.
OOP and Dynamic Method Binding Chapter 9. Object Oriented Programming Skipping most of this chapter Focus on 9.4, Dynamic method binding – Polymorphism.
Introduction to Object Oriented Programming CMSC 331.
1 COMP313A Programming Languages Object Oriented Progamming Languages (3)
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
1 Lecture 23: Dynamic Binding (Section ) CSCI 431 Programming Languages Fall 2002 A compilation of material developed by Felix Hernandez-Campos.
Lecture 2 Intro. To Software Engineering and Object-Oriented Programming (2/2)
C++ General Characteristics: - Mixed typing system - Constructors and destructors - Elaborate access controls to class entities.
CSCI-383 Object-Oriented Programming & Design Lecture 17.
ISBN Chapter 12 Support for Object-Oriented Programming.
Support for Object-Oriented Programming
Support for Object-Oriented Programming
Support for Object-Oriented Programming
Inheritance and Polymorphism
Object-Oriented Database Management System (ODBMS)
CMP 339/692 Programming Languages Day 24 Tuesday May 1, 2012
OOP What is problem? Solution? OOP
Polymorphism.
Types of Programming Languages
Support for Object-Oriented Programming
Support for Object-Oriented Programming in Ada 95
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
Presentation transcript:

Chapter 12: Support for Object- Oriented Programming Lecture # 18

Chapter 12 Topics Object-Oriented Programming Design Issues for OOP Languages Support for OOP in C# Implementation of Object-Oriented Constructs Chapter 12: Support for Object-Oriented Programming 2

Object-Oriented Programming Abstract data types. Inheritance.  Inheritance is the central theme in OOP and languages that support it. Polymorphism. Chapter 12: Support for Object-Oriented Programming 3

Inheritance Inheritance allows new classes defined in terms of existing ones, i.e., by allowing them to inherit common parts. Inheritance addresses reuse ADTs after minor changes and define classes in a hierarchy. Chapter 12: Support for Object-Oriented Programming 4

Object-Oriented Concepts (cont.) 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. Chapter 12: Support for Object-Oriented Programming 5

Single vs. Multiple Inheritance. One disadvantage of inheritance for reuse:  Creates inter-dependencies among classes that complicate maintenance. Chapter 12: Support for Object-Oriented Programming 6 Object-Oriented Concepts (cont.)

Design Issues for OOP Languages Single and Multiple Inheritance. Object Allocation and DeAllocation. Dynamic and Static Binding. Nested Classes. Chapter 12: Support for Object-Oriented Programming 7

Support for OOP in C# General characteristics:  Support for OOP similar to Java.  Includes both classes and structs.  Classes are similar to Java’s classes.  structs are less powerful stack-dynamic constructs (e.g., no inheritance). Chapter 12: Support for Object-Oriented Programming 8

Support for OOP in C# (cont.) Inheritance  Uses the syntax of C++ for defining classes.  A method inherited from parent class can be replaced in the derived class by marking its definition with new.  The parent class version can still be called explicitly with the prefix base: base.Draw(); Chapter 12: Support for Object-Oriented Programming 9

Support for OOP in C# (cont.) Dynamic binding:  To allow dynamic binding of method calls to methods: The base class method is marked virtual. The corresponding methods in derived classes are marked override.  Abstract methods are marked abstract and must be implemented in all subclasses.  All C# classes are ultimately derived from a single root class, Object. Chapter 12: Support for Object-Oriented Programming 10

Support for OOP in C# (cont.) //Program that introduces virtual method in C# using System; class A { public virtual void Test() { Console.WriteLine("A.Test"); } } class B : A { public override void Test() { Console.WriteLine("B.Test"); } } class Program { static void Main() { A ref1 = new A(); ref1.Test(); A ref2 = new B(); ref2.Test(); } } //Output: A.Test B.Test Chapter 12: Support for Object-Oriented Programming 11

Implementing OO Constructs Two interesting and challenging parts:  Storage structures for instance variables.  Dynamic binding of messages to methods. Chapter 12: Support for Object-Oriented Programming 12