 2009 Qing Li Introduction to Object Orientation Background: Background:  [behaviorally] object-oriented databases (OODBs) = OO Concepts + Persistency.

Slides:



Advertisements
Similar presentations
Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.
Advertisements

OO databases 1 Object Oriented databases. OO databases 2 Developing OODBMS - motivation motivation more and more application areas require systems that.
Chapter 10: Designing Databases
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
1 OBJECT-ORIENTED CONCEPTS. 2 What is an object?  An object is a software entity that mirrors the real world in some way.  A software object in OOP.
Object-Oriented Databases v OO systems associated with – graphical user interface (GUI) – powerful modeling techniques – advanced data management capabilities.
Chapter Object-Oriented Practices. Agenda Object-Oriented Concepts Terminology Object-Oriented Modeling Tips Object-Oriented Data Models and DBMSs.
Object Oriented System Development with VB .NET
Stéphane Ducasse6.1 Essential Concepts Why OO? What is OO? What are the benefits? What are the KEY concepts? Basis for all the lectures.
Object-Oriented Databases
1 Introduction to C++ Programming Concept Basic C++ C++ Extension from C.
Lecture 13: Object- Oriented Concepts Anita S. Malik Adapted from Schach (2004) Chapter 7.
Object Oriented Databases - Overview
July 13, 2015ADBS: OODB1 Concepts for Object-Oriented Databases Chapter 20.
Abstract Data Types and Encapsulation Concepts
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
C++ fundamentals.
Chapter 4 Object and Object-Relational Databases (Part ½: Object-Oriented Concepts) Lecturer: H.Ben Othmen Department of Computer Science, Umm Al-Qura.
EER vs. UML Terminology EER Diagram Entity Type Entity Attribute
OOP Languages: Java vs C++
Comparison of OO Programming Languages © Jason Voegele, 2003.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Chapter 24 Introduction to Object DBMSs Prepared by Kai Huang CS157B Prof Sin-Min Lee.
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.
11 1 Object oriented DB (not in book) Database Systems: Design, Implementation, & Management, 6 th Edition, Rob & Coronel Learning objectives: What.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
CS 403 – Programming Languages Class 25 November 28, 2000.
1 Chapter 10: Data Abstraction and Object Orientation Aaron Bloomfield CS 415 Fall 2005.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
11 1 Chapter 11 Object Oriented Databases Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
CSE 425: Object-Oriented Programming I Object-Oriented Programming A design method as well as a programming paradigm –For example, CRC cards, noun-verb.
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.
1 Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill Chapter 2: Object Basics Object-Oriented Systems Development Using the Unified Modeling.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
Chapter 12 Support for Object oriented Programming.
1 CS457 Object-Oriented Databases Chapters as reference.
ITEC 3220A Using and Designing Database Systems Instructor: Prof Z. Yang Course Website: 3220a.htm
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020.
OODBMS: Introduction and Logical Database Design
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.
Lecture 10 Concepts of Programming Languages Arne Kutzner Hanyang University / Seoul Korea.
CS451 - Lecture 2 1 CS451 Lecture 2: Introduction to Object Orientation Yugi Lee STB #555 (816) * Acknowledgement:
Object-Oriented Programming Chapter Chapter
ADT data abstraction. Abstraction  representation of concepts by their relevant features only  programming has two major categories of abstraction process.
ISBN Object-Oriented Programming Chapter Chapter
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.
The Object-Oriented Database System Manifesto Malcolm Atkinson, François Bancilhon, David deWitt, Klaus Dittrich, David Maier, Stanley Zdonik DOOD'89,
Chapter 20 Concepts for Object-Oriented Databases Copyright © 2004 Pearson Education, Inc.
A Survey of Object-Oriented Concept Oscar Nierstrasz.
1 10 Systems Analysis and Design in a Changing World, 2 nd Edition, Satzinger, Jackson, & Burd Chapter 10 Designing Databases.
ISBN Chapter 12 Support for Object-Oriented Programming.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
11.1 The Concept of Abstraction
Types of Programming Languages
Chapter 12 Outline Overview of Object Database Concepts
Names, Binding, and Scope
ISC321 Database Systems I Chapter 10: Object and Object-Relational Databases: Concepts, Models, Languages, and Standards Spring 2015 Dr. Abdullah Almutairi.
Support for Object-Oriented Programming
ITEC 3220A Using and Designing Database Systems
Lecture 10 Concepts of Programming Languages
C++ Object Oriented 1.
11.1 The Concept of Abstraction
Chapter 11 Abstraction - The concept of abstraction is fundamental in
Presentation transcript:

 2009 Qing Li Introduction to Object Orientation Background: Background:  [behaviorally] object-oriented databases (OODBs) = OO Concepts + Persistency + Transaction support  history & evolution of object orientation: > “Begin … End” blocks in Algol 60 (first attempt at providing encapsulation/protection within a PL) > “Object” in Simula-67 (took the block concept one step further towards data encapsulation) > “Object”, “Class”, “Inheritance” in Smalltalk (further towards data encapsulation & abstraction; ‘70s) > theory of ADT (abstract data type) began to be developed in late ‘70s (eg, Ada)

 2009 Qing Li Introduction to Object Orientation  history & evolution of object orientation (cont’d): > DB languages emerged to support data abstraction & inheritance (eg, Taxis) from semantic modeling > Concepts began to merge towards a unified concept strucutre -- object today! (early ‘80s --> ) E.g., Smalltalk-80, C++, Objective-C, CommonLisp,… Gemstone, Orion, Vbase, Ontos, ObjectStore,... Object Orientation Object Orientation (1) three most fundamental/essential concepts: - abstract data typing (encapsulation) - inheritance - object identity

 2009 Qing Li Introduction to Object Orientation Object Orientation (cont’d) Object Orientation (cont’d) (2) Advantages of object orientation: * better concepts and tools to model and represent the real world as closely as possible (=> model of reality!) * OO languages provide expressive programming and/or manipulation primitives (=> behavior modeling!) * better reusability & extensibility => reduce the time/cost of development * enhanced maintainability & improved reliability (eg, changes can be localized to the implementation of one or more classes) * better performance for complex applications

 2009 Qing Li Introduction to Object Orientation Object Orientation (cont’d) Object Orientation (cont’d) (3) Approaches to OO Programming: a) Novel languages: most radical approach Eg, Smalltalk; Eiffel; Trellis/Owl b) Language Extensions: less controversial approach Eg., C++; Objective-C; Flavors; Object Pascal; … c) Object-oriented style: as an enforced discipline Eg., in C to enforce ADT discipline to simulate other OO features

 2009 Qing Li Introduction to Object Orientation OO Systems vs. Conventional ones OO Systems vs. Conventional ones   In Conventional Languages/Systems: Programs: collections of procedures/subroutines that pass parameters Procedure: manipulate its parameters, possibly return a value => the execution units (procedures) are the central focus!   In OO Systems/Languages: the universe: a collection of independent objects communicating through message-passing objects: the active entities; procedures (messages): passive entities => the data (ie, objects) are the central focus!

 2009 Qing Li Introduction to Object Orientation Features of Object Orientation Features of Object Orientation  Abstract Data Type (ADT) > ADT: defines a set of similar objects with an associated collection of operators > Three criteria for a PL to support ADTs: a) object classes: every datum (object) belongs to an ADT (the object’s class) b) information hiding: - object only accessible through the external interface routines/operations defined by its ADT - its internal implementation details, data structures, and storage elements are not visible outside c) completeness: all required operations are defined. Left to the user!

 2009 Qing Li Introduction to Object Orientation  Abstract Data Type (cont’d)  Object Class: incorporates the definition of the structure as well as the operations of the ADTs Instances: elements pertaining to the collection of objects described by a class Minimally, a class definition should include: a) the name of the class b) the external interface (ie, operations for manipulating its instances; typically have a target object & some arguments) c) the internal representation (ie, instance variables) d) the internal implementation of the interface

 2009 Qing Li Introduction to Object Orientation  Object Class (cont’d) 1) Instance Variables: to capture the internal representation of an object of the class * declaration: Name: string Address: string Revenue: dollar Employees: SetOf Employee Subsidiaries: SetOf Company … Note: there are typeless PLs like Smalltalk, LISP, APL ( where x can be bound to integer 5, and later to a string ‘xy’ within the same session/program). “type constraints” (checked at compile time for typed DB PL)

 2009 Qing Li Introduction to Object Orientation  Object Class 1) Instance Variables (cont’d) * Operator “overloading”: E.g., in PASCAL, “+” can be used for integers as well as for floats! 2) Object Creation: done through invoking a “new” operator on the class E.g. in Eiffel: IBM:= new(Company, “IBM”, “111 success street, New York”) in C++: IBM = new Company (“IBM”, “111 success street, New York”)

 2009 Qing Li Introduction to Object Orientation  Object Class 2) Object Creation (cont’d) Note: instance variables are initialized either at object creation time (via “new”), or subsequently through calling specific operators E.g., Set-Revenues(IBM, $5,000,000,000) … 3) Methods & Messages 3.1) invoking an operation involves: a) the target object b) the name of the operator c) the argument of the operation d) calling the code that implement the operator, binding the parameters to the actual arguments

 2009 Qing Li Introduction to Object Orientation  Object Class 3) Methods & Messages (cont’d) E.g., in Smalltalk, a message looks like below: GM(AddSubsidiary: Hughes) in C++: GM.AddSubsidiary(Hughes) in Eiffel: AddSubsidiary(GM, Hughes)  very similar to invoke procedures! (Difference: binding is done at run time, depending on the class of the target object!! ) A message (to GM): (i) a selector (ii) one/more arguments The selector (name of a “method”) AddSubsidiary(C: Company, NewSubsj: Company) C.Subsidiary[TotalSubsj]:= NewSubsi TotalSubsi := TotalSubsi + 1

 2009 Qing Li Introduction to Object Orientation  Object Class 3) Methods & Messages (cont’d) On Dynamic Binding (“late binding”): the system will bind at run-time a selector to the particular method (procedure) that implement it, based on the recipient object’s class. Motivations: 1) the same message or method name could be used by different classes (overloading!) 2) a variable’s object class might not be known till runtime (eg, in typeless languages) Advantages: flexibility & extensibility (the cost is the performance penalty!)

 2009 Qing Li Introduction to Object Orientation  Object Class 3) Methods & Messages (cont’d) On Dynamic Binding (“late binding”): E.g., there is a stack of heterogeneous objects, and we want to print every entry in the stack in OOPL in conventional PLs: for i:= 1 to Top for i:= 1 to Top do do Print(Stack[i]) case Stack[i].type integer: PrintInteger( Stack[i].object) float: PrintFloat( Stack[i].object) string: … Boolean: … If a new type X is added, then the OOPL system can be extended without affecting the code, whereas the other would need to add PrintX and recompile the while thing!

 2009 Qing Li Introduction to Object Orientation  Object Class (cont’d) 4) Constraints to help enforce correctness/completeness of ADT Two approaches: a) Constraints on objects and their instance variables E.g., Student.age > 15 b) Pre- and Post-conditions of methods (as supported in, eg., Eiffle)

 2009 Qing Li Introduction to Object Orientation  Inheritance Hierarchy  the 2nd powerful concept of OOPL and systems  similar concept found in semantic networks (Minsky’68) and semantic data models  useful in organizing/structuring information, and facilitating reusablity (rather than designing everything from scratch) E.g. Company Commercial Company Non-profit Organization superclass subclass

 2009 Qing Li Introduction to Object Orientation  Inheritance Hierarchy (cont’d)  subclass and superclass relations are “transitive”  there is the notion of inheritance applicable  two main aspects of inheritance: 1) structural (instance variables) 2) behavioral (methods) 1) Inheriting Instance Variables - common in AI (KR) and semantic data models - subclsses “inherit” their superclass’ instance variables - different ways to achieve the goal of inheritance:

 2009 Qing Li Introduction to Object Orientation 1) Inheriting Instance Variables (cont’d) * in Smalltalk: visible directly & completely! Problem: violates both uniformity & encapsulation (eg, suppose A changes its “Subsidiaries” from an array to a list of company, then B’s evaluate-profit method has to be modified!) A B

 2009 Qing Li Introduction to Object Orientation 1) Inheriting Instance Variables (cont’d) * in CommonObjects & Encore: invisible completely! * more general approach: (eg, in C++, Trellis/Owl) - Public (any client can access) - Private (no client can access) - protected (subclass’ clients can access) A B Instance variables in the hierarchy are independent from each other

 2009 Qing Li Introduction to Object Orientation 2) Inheriting Methods - unique to OO languages and systems - methods defined for a class are inherited by its subclasses E.g. Window Bordered Window Text Window move-window() resize-window() retate-window() edit-font() reset-size() edit-font() edit-size()

 2009 Qing Li Introduction to Object Orientation 2) Inheriting Methods (cont’d) - a subclass can “over-ride” an inherited method E.g. Where: Evaluate-profit(FC: ForeignCommercial) return (CommercialCompany.evaluate-profit(FC)- ForeignTax(FC)) Commercial Company Foreign Commercial evaluate-profit()

 2009 Qing Li Introduction to Object Orientation 2) Inheriting Methods (cont’d) - multiple inheritance: combine several classes to produce “conglomerate classes” E.g. Person EmployeeStudent StudentWorkerManager

 2009 Qing Li Introduction to Object Orientation 2) Inheriting Methods - multiple inheritance (cont’d): Suppose Employee : {name, age, salary, rank, dept} Student : {name, age, GPA, program, advisor} then StudentWorker: {name, age, salary, rank, dept, GPA, program, advisor} What happen when there is a “conflict” (ie, different methods/instance variables have the same name)? Eg., assume both student & employee had a method called “bonus” (with totally different semantics), which bonus method should apply to StudentWorker?

 2009 Qing Li Introduction to Object Orientation Meta Classes - Are classes instances of other classes? - If Yes, what is the class describing them, and where does the transitive closure end? E.g., in Smalltalk: * classes are instances of their metaclasses which are created by the system (the user distinguishes between class methods/attributes from instance methods/attributes) * all metaclasses are instances of METACLASS; * METACLASS is an instance of CLASS which is an instance of OBJECT ( the root!)

 2009 Qing Li Introduction to Object Orientation  Object Identity  the 3rd powerful concept of OO systems Definition: an identity is a handle which distinguishes one object (entity) from another  the idea: within a complete OO system, each object will be given an identity (Oid) permanently, immaterial of the object’s structural or state transitions  necessity: without Oids, it is a) awkward (if not impossible) to assign self- contained objects to instance variables b) impossible to make the same object a component of multiple objects

 2009 Qing Li Introduction to Object Orientation  Object Identity (cont’d)  Conventional programming language’s way: - use variable names to distinguish objects  mixes addressability and identity! - practical limitations: no way to test if x and y refer to the same object (ie, x==y), as opposed to x=y (assignment). Supported in Smalltalk External to object (a way to access; typically through pointers or virtual addresses) Internal to object (to represent the individuality; should be independent of how it is accessed!)

 2009 Qing Li Introduction to Object Orientation  Object Identity (cont’d)  Conventional DB Approach: - uses record keys to distinguish objects  confuses identity and data values (obj. state)! - practical problems: a) modifying key attributes? b) non-uniformity: Eg, Compaq uses emp# as key attribute IBM uses ss# as key attribute a merge of Compaq and IBM  one of these keys to change!

 2009 Qing Li Introduction to Object Orientation  Object Identity  Conventional DB Approach (cont’d) c) unnatural join: Eg, Employee Company EmpName ss# salary CompName Name Budget Location Query: “find for all employees the Employee name and the location that employee works in”. In SQL: SELECT Employee.EmpName, Company.Location FROM Employee, Company WHERE Employee.CompName = Company.Name; But if two companies have the same name?

 2009 Qing Li Introduction to Object Orientation  Conventional DB Approach c) unnatural join (cont’d) (in most cases, what the user wants is the actual company object (tuple), instead of the CompName!) Part of the reason: due to normalization which loses the semantic connections amongst the objects  relational systems have to use additional facilities such as foreign key constraints to recapture the lost semantics!! What about relax the normalization constraints?  nested relations (or, Non-1NF relations) allowed, so as to support a more direct & intuitive representation

 2009 Qing Li Introduction to Object Orientation But, non-1NF models only provide a partial solution… E.g. Person Name age address spouse Education Degree Univ. Year John parker st. Mary MSc MIT 1981 PhD CMU 1986 Mary parker st. John BBA USC 1985 MBA USC 1987 Children Parent Child Cage John Tim 5 Mary Tim 5 John Jane 3 Mary Jane 3 Note: children still need to be represented separately, since each child pertains to both parents

 2009 Qing Li Introduction to Object Orientation What’s missing? the ability to share objects (to refer to objects directly and completely) Answer: Oid ! * preserve identity throughout object evolution: evolve - strong support of identity is important for temporal data models (where objects can evolve!) - Oid can serve as the common thread that ties together the historial versions of an object Some Oid operations: - merge / coerce - copy: shallow vs. deep