1 Case Study: Meta Classes  Class representation in memory  Class variables and class methods  Meta Classes  3 Level System  4 Level System  5 Level.

Slides:



Advertisements
Similar presentations
More on Classes Inheritance and Polymorphism
Advertisements

1 Object Orientation James Brucker. 2 Smalltalk  Ahead of its time: consistent design and rich library.  Dynamic (like Lisp): variables have no specified.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
CS ExCo Advanced in Topics Object-Oriented Programming.
OOP - Object Oriented Programming Object Oriented Programming is an approach to programming that was developed to make large programs easier to manage.
Chapter 12: Support for Object-Oriented Programming
Session 07: C# OOP 4 Review of: Inheritance and Polymorphism. Static and dynamic type of an object. Abstract Classes. Interfaces. FEN AK - IT:
Object-Oriented PHP (1)
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
ISBN Chapter 12 Support for Object-Oriented Programming.
Dynamic Object-Oriented Programming with Smalltalk 1. Introduction Prof. O. Nierstrasz Summer Semester 2006.
Principles of Object-Oriented Software Development Object-oriented programming languages.
1 Chapter 12 © 2002 by Addison Wesley Longman, Inc Introduction - Categories of languages that support OOP: 1. OOP support is added to an existing.
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
ISBN Chapter 12 Support for Object- Oriented Programming.
Sharif University of Technology Session # 7.  Contents  Systems Analysis and Design  Planning the approach  Asking questions and collecting data 
Self: The Power of Simplicity David Ungar and Randall B. Smith Presenter: Jonathan Aldrich
UML Class Diagrams: Basic Concepts. Objects –The purpose of class modeling is to describe objects. –An object is a concept, abstraction or thing that.
Object Oriented Software Development
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
Polymorphism. Introduction ‘one name multiple forms’ Implemented using overloaded functions and operators Early binding or static binding or static linking.
DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model.
OOPs Object oriented programming. Based on ADT principles  Representation of type and operations in a single unit  Available for other units to create.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
CONCEPTS OF OBJECT ORIENTED PROGRAMMING. Topics To Be Discussed………………………. Objects Classes Data Abstraction and Encapsulation Inheritance Polymorphism.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Static and Dynamic Behavior CMPS Power of OOP Derives from the ability of objects to change their behavior dynamically at run time. Static – refers.
CS 403 – Programming Languages Class 25 November 28, 2000.
School of Computer Science & Information Technology G6DICP - Lecture 22 The Theory of Object Oriented Programming.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
CSE 425: Object-Oriented Programming I Object-Oriented Programming A design method as well as a programming paradigm –For example, CRC cards, noun-verb.
Introduction to Object Oriented Programming CMSC 331.
CSSE501 Object-Oriented Development. Chapter 11: Static and Dynamic Behavior  In this chapter we will examine the differences between static and dynamic.
CSC480 Software Engineering Lecture 11 September 30, 2002.
Object-Oriented Programming. An object is anything that can be represented by data in a computer’s memory and manipulated by a computer program.
Chapter 12 Support for Object oriented Programming.
Objects & Dynamic Dispatch CSE 413 Autumn Plan We’ve learned a great deal about functional and object-oriented programming Now,  Look at semantics.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Definition of Object - Oriented Language.. Object-oriented programming (OOP) is a programming language model organized around "objects" rather than "actions"
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
Object Oriented Software Development
ITEC 3220A Using and Designing Database Systems Instructor: Prof Z. Yang Course Website: 3220a.htm
ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020.
Overview The Basics – Python classes and objects Procedural vs OO Programming Entity modelling Operations / methods Program flow OOP Concepts and user-defined.
OBJECT ORIENTED AND FUNCTION ORIENTED DESIGN 1 Chapter 6.
Lecture 10 Concepts of Programming Languages Arne Kutzner Hanyang University / Seoul Korea.
Salman Marvasti Sharif University of Technology Winter 2015.
Chapter 12 Support for Object-Oriented Programming.
Object-Oriented Programming Chapter Chapter
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
(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.
CPS Inheritance and the Yahtzee program l In version of Yahtzee given previously, scorecard.h held information about every score-card entry, e.g.,
ISBN Object-Oriented Programming Chapter Chapter
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Object-Oriented Programming “The Rest of the Story”, CS 4450 – Chapter 16.
Lecture 2 Intro. To Software Engineering and Object-Oriented Programming (2/2)
CSCI-383 Object-Oriented Programming & Design Lecture 17.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
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.
CSE 413 Programming Languages & Implementation Hal Perkins Autumn 2012 Multiple Inheritance, Interfaces, Mixins 1.
Type Checking and Type Inference
Types of Programming Languages
UML Class Diagrams: Basic Concepts
Support for Object-Oriented Programming in Ada 95
Support for Object-Oriented Programming
ITEC 3220A Using and Designing Database Systems
Presentation transcript:

1 Case Study: Meta Classes  Class representation in memory  Class variables and class methods  Meta Classes  3 Level System  4 Level System  5 Level System  1 Level System  Infinite Levels System

2 Class Representation in Memory? A class is defined in the source code, so why should it be represented in the runtime environment? Answer: Dynamic Binding! The actual method bound to a message is determined at run time based on the type (class) of an object. There must be a link between the object and its methods. Since these links are the same for all objects of the same class, it makes sense to share the representation. Schematic diagram, common to all OO languages: Class Rep Method 1 Method 2 Object Method n Msg Methods Table

3 A Class as an Object? Dynamic binding implies that classes must have some memory representation. Why not as an object? Answer: Let's go for it! Each object o has a pointer to its class object c which is the object representing the class to which o belongs.

4Metaclasses Meta-: Beyond; transcending; more comprehensive; e.g., as in metalinguistics. Class: generates instances. Metaclass: a class whose instances are classes. Terminal Instance: cannot be instantiated further. Main Text Book Reference: G.Masini et al. Object-Oriented Languages, APIC series, No.34

5 Taxonomy of Metaclass Systems 1-Level System: Objects only Each object describes itself No need for classes: objects are “instantiated” or “inherited” from other objects Example: Self, Javascript 2-Level System: Objects, Classes Objects: described by classes Classes: need no description--do not exist in run-time. Not first- class objects: Not instances of classes Not created by constructors Cannot receive messages Examples: Eiffel 3-Level System: Objects, Classes, Metaclass Objects: described by classes Classes: described by the metaclass The Metaclass: describes itself Examples: Smalltalk-76, Little-Smalltalk

6 oop The 3 Level System

7 One Metaclass Structure Simple and elegant model: courtesy of Smalltalk-76, the first language to introduce the metaclass concept. Later adopted by Little-Smalltalk The Class metaclass: The only metaclass in the system Instance of itself Avoids the infinite regress of the instantiation relationship Inherits from Object Holds behaviour common to all class objects: How to add methods How to instantiate a class Holds structure common to all class objects: Super class Instance variables List of methods Uniform behaviour and structure of all classes: Different classes cannot have different new methods The new defined in class Class calls new defined in the object’s class

8 oop The 1 Level System

9 Principles of the 1 Level Sysem In a 1-level system, each object describes itself. An object is a essentially a map from names (strings) to either values or methods Very flexible, but static type checking is hard No distinction between objects and classes Every object is the class of itself Instantiation of a new object: Take an existing object and clone it.

10 Class Variables and Class Methods If a class is an object, then it makes sense to ask what are the variables and methods of that object. Simple answer (LST approach): Class Methods: Constructor! Send a message to the class, requesting it to create a new instance. Class Variables: Data structure defining the structure of instances. Data structure determining the protocol/implementation of instances. No per-class variables The more sophisticated answer: Smalltalk-80 (a 5 level system): Class specific variables Class specific methods

11 oop A 4 Level System

12 Properties of the 4 Level System Each object: is an instance of a class Each class: is an instance of a metaclass May have its own singleton metaclass May share a metaclass with other classes May use the default metaclass Meta Object Each metaclass: is an instance of a meta-metaclass. One meta-metaclass: Instance of itself Inherits from Object (or Class)‏ Examples: (with minor variations)‏ LOOPS: Lisp Object and data Oriented Programming System ObjVlisp: OBJect Virtual extension of LISP A model more than a real language

13 oop Infinite Object-Class Regression  3-KRS: an infinite number of levels system Objects: instances of “metaobjects” (aka classes). Classes: instances of metaclasses. Metaclasses: instances of meta-metaclasses. Meta-metaclasses: instances of meta-meta- metaclasses.... For each object X, there is a meta-object  X Lazy creation of meta-objects enables the system to work in a finite world.

14 oop A 5 Level System Three Kinds of Entities: Objects Classes: each class X has an object X describing it. Integer Object Class: the class of all class objects Metaclass: the class of all metaclass objects Metaclasses: the object X describing class X is an instance of a singleton metaclass: “X class” describing it. Integer class: the class of “Integer” Class class: the class of “Class” Metaclass Class: the class of “Metaclass” The metaclass “Novel class” is also the result of evaluating the Smalltalk expression: Novel class The metaclass “Novel class” is also the result of evaluating the Smalltalk expression: Novel class

15 oop Inheritance in the 5 Level System A metaclass object “X class”: is an instance of “Metaclass” inherits from “Class” Class: an abstract class parent of all “X class” objects Metaclasses hierarchy: X inherits from Y “X class” inherits from “Y class”