chapter 3 object specification languages prof. hyoung-joo kim ([email protected]) oopsla lab....

25
Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim ([email protected]) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ.

Upload: marjory-kennedy

Post on 04-Jan-2016

218 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

Chapter 3

Object Specification Languages

Prof. Hyoung-Joo Kim ([email protected])

OOPSLA Lab.Dept. of Computer Engineering

Seoul National Univ.

Page 2: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 2

Contents

• 3.1 Introduction

• 3.2 Object Definition Language

• 3.3 Object Interchange Format

Page 3: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 3

3.1 Introduction

• Specification Language– used to represent ODMG-compliant object database management s

ystems

– used to define the schema, operations, and state of object database

– facilitate the portability of database across ODMG-compliant implementation

– provide a step toward the interoperability of ODBMs

– ODL : Object Definition Language

– OIF : Object Interchange Format

Page 4: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 4

3.2 Object Definition Language(ODL)(1)

• Definition– a specification language of interfaces to object type

• ODL development principles– all semantic constructs of ODMG model

– specification language(not full programming language)

– programming language independence

– OMG IDL(Interface Definition Language) compatibility

– practical & short time implementable

Page 5: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 5

3.2 Object Definition Language(ODL)(2)

• ODL mapping to other languages

STEP/Express SQL3 Other

Language-Independent ODL

Java C++ SQL3 Smalltalk Other

Page 6: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 6

3.2.1 Specification(1)

• Type definition– achieve by specifying its interface or by its class in ODL

<interface> ::= <interface_dcl> | <forward_dcl>

<interface_dcl> ::= <interface_header> { [ <interface_body> ] }

<forward_dcl> ::= interface <identifier>

<interface_header> ::= interface <identifier> [<inheritance_spec>]

<class> ::= <class_header>{<interface_body>}

<class_header> ::= class <identifier>

[ extends <scopedName> ]

[ <inheritance_spec> ]

[ <type_property_list> ]

Page 7: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 7

3.2.1 Specification(2)

• Type characteristics– supertype information,

– extent naming,

– specification of keys

– simple example for the class definition

class Professor

( extent professors )

{

properties

operations

};

Page 8: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 8

3.2.1 Specification(3)

• Instance properties– be specified in attributes and relationships specifications

<interface_body> ::= <export> | <export> <interface_body>

<export> ::= <type_dcl> ;

| <const_dcl> ;

| <except_dcl> ;

| <attr_dcl> ;

| <rel_dcl> ;

| <op_dcl> ;

Page 9: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 9

3.2.1 Specification(4)

• Attributes specification– example

class Professor( extent professors )

{

attribute string name;

attribute unsigned short faculty_id[6];

attribute long soc_sec_no[10];

attribute set<string> degrees;

relationships

operations

};

Page 10: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 10

3.2.1 Specification(5)

• Relationships– define a traversal path for relationship

– include designation of the target type and information about the inverse traversal path

class Professor

( extent professors ){ relationship set<Student> advises

inverse Student::advisor;

relationship set<TA> teaching_assistants

inverse TA::works_for;

relationship Department department

inverse Department::faculty;

operation}

Page 11: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 11

3.2.2 An Example in ODL(1)

Salary

EmployeeCourse

TA ProfessorStudent-IF

Student Section

Has_prerequisites

Is_prerequisiteshas_sections

is_section_of

takes

is_taken_by

has_TA

assists

is_taught_by

teaches

extends

is-a

many-to-many

one-to-many

one-to-one

Legend :

Page 12: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 12

3.2.2 An Example in ODL(2)

• Course typeclass Course

( extent courses ){ attribute string name;

attribute string number;

relationship list<Section> has_sections

inverse Section::is_section_of;

relationship Set<Course> has_prerequisites

inverse Course::is_prerequisite_for;

relationship Set<Course> is_prerequisite_for

inverse Course::has_prerequisites;

boolean offer(in unsigned short semester) raises(already_offered)

boolean drop(in unsigned short semester) raises(not_offered)

}

Page 13: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 13

3.2.2 An Example in ODL(3)

• Section typeclass Section

( extent sections )

{

attribute string number;

relationship Professor is_taught_by

inverse Professor::teaches;

relationship TA has_TA

inverse TA::assists;

relationship Course is_section_of

inverse Course::has_sections;

relationship set<Student> is_taken_by

inverse Student::takes;

};

Page 14: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 14

3.3 Object Interchange Format(OIF)

• Definition– a specification language used to dump and load the current state of

an object DB to or from a file or set of files

• OIF development principles– support all object database state compliant to the ODMG object m

odel

– specification language for persistent object and their states

– design according to related standards as STEP or ANSI

– no keywords

Page 15: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 15

3.3.1 Object Database States

• Items used to characterize the state of all objects– object identifiers

– type bindings

– attribute values

– links to other objects

Page 16: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 16

3.3.2 Basic Structure

• An OIF file contains object definitions• Object tag names

– specified with object identifier

– unique in the OIF files(s)

– visible within the entire set of OIF files

– no forward declarations

– cyclic usage of tag names

Page 17: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 17

• Simple example• Jack Person{}

• Physical clustering– definition

• Paul (jack) Engineering{}

– meaning• create a new persistent instance of the class Engineer “physically

near” the object referenced by the identifier Jack

• “physically near” are implementation dependent

tag name

3.3.3 Object Definitions

Page 18: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 18

3.3.4 Attribute Value Initialization(1)

• Simple exampleinterface Person {

attribute string Name;

attribute unsigned short Age;

};

Sally Person{Name “Sally”, Age 11} or Sally Person{Age 11, Name “Sally”}

• Short initialization formatSally Person{“Sally” 11}

• Copy initializationMcBain(McPerth) Company{McPerth}

• Boolean literalinitialization with boolean literal TRUE or FALSE

Page 19: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 19

struct PhoneNumber { unsigned short CountryCode; unsigned short AreaCode; unsigned short PersonCode;};

struct Address { string Street; string City; PhoneNumber Phone;};

interface Person { attribute string Name; attribute Address PersonAddres;};

3.3.4 Attribute Value Initialization(2)

• Character literals• Integer literals• Float literals• String literals• Initialization of structured type

Page 20: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 20

Sarah Person{Name “Sarah”, PersonAddress {Street “Willow Road”, City ‘Palo Alto”, Phone {CountryCode 1, AreaCode 415, PersonCode 1234}}}

T1 Sample{Values{450, 23, 270, 22}}

T1 Sample{Values{[0] 450, [1] 23, [2] 270, [3] 22}}

=

3.3.4 Attribute Value Initialization(3)

• Initialization of multidimensional attributesinterface Sample {

attribute unsigned short Values[1000];

}

Page 21: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 21

Interface Professor: Person { attribute set<string> Degrees;};

Feynman Professor{Degrees{“Masters”,“PhD”}}

Interface PolygonSet{ attribute array<float> polygonRefPoints[10];};

P2 PolygonSet{PolygonRefPoints{[0]{[0] 9.7, [1] 8.988,..}, …….. [10]{[0] 22.0, [1] 60.1, …}}};

3.3.4 Attribute Value Initialization(4)

• Initialization of collections

Page 22: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 22

3.3.5 Link Definitions(1)

• Cardinality “One” relationshipsinterface Person {

relationship Company Employer

inverse Company::Employees;

};

Jack Person{Employer McPerth}

• Cardinality “Many” relationshipsinterface Company {

relationship set<Person> Employees

inverse Person::Employer;

};

McPerth Company{Employees{Jack, Joe, Jim}}

Page 23: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 23

Interface Person { relationship Employer inverse Company::Employees; relationship Property inverse Company::Owner;};

Interface Company { relationship set<Person> Employees inverse Person::Employer; relationship Person Owner inverse Person::Property;};

Jack Person{Employer McPerth}McPerth Company{Owner Jack}

3.3.5 Link Definitions(2)

• Cycles

Page 24: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 24

interface Node { relationship set<Node> Pred inverse Node::Succ; relationship set<Node> Succ inverse Node::Pred;};

A Node{Pred {B}}E NodeB Node{Pred{E}, Succ{C}}C Node{Pred{A}, Succ{F}}F Node

< ODL definition > < Declaration in OIF >

3.3.6 Data Migration

• Forward declarations– visible within the entire set of OIF files

– appear at arbitrary locations within the files

Page 25: Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim (hjk@oopsla.snu.ac.kr) OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ

SNU OOPSLA Lab. 25

3.3.7 Command Line Utilities

• Dump database– dump a database

– command• odbdump <database name>

• Load database– load a database

– command• odbload <database name> <file1>….<filen>