object technology course aim examine the differences between procedural and object-oriented...

34
Object Technology Object Technology

Upload: clementine-harrison

Post on 28-Dec-2015

216 views

Category:

Documents


1 download

TRANSCRIPT

Object TechnologyObject Technology

Course AimCourse Aim

• Examine the differences between procedural and Examine the differences between procedural and object-oriented programming;object-oriented programming;

• Explain the principles, characteristics and benefits of Explain the principles, characteristics and benefits of object technology; object technology;

• Present the concepts underlying distributive object Present the concepts underlying distributive object processing; andprocessing; and

• Introduce and contrast approaches to object Introduce and contrast approaches to object persistence in databases.persistence in databases.

The Object Technology course will -The Object Technology course will -

Course ObjectivesCourse Objectives

• Name and discuss the three foundational concepts upon which Name and discuss the three foundational concepts upon which object technology is builtobject technology is built

• Given a list of terms and characteristics of object methodology, Given a list of terms and characteristics of object methodology, correctly match them with a list of definitionscorrectly match them with a list of definitions

• Contrast object-oriented and traditional programming and Contrast object-oriented and traditional programming and identify the benefits of object orientationidentify the benefits of object orientation

• Describe the benefits of objects residing and operating remotely, Describe the benefits of objects residing and operating remotely, and identify the mechanisms necessary for distributing objectsand identify the mechanisms necessary for distributing objects

• Given names of four persistence mechanisms, provide at least Given names of four persistence mechanisms, provide at least one advantage and one disadvantage of using each as a one advantage and one disadvantage of using each as a database for objects.database for objects.

The successful learner will be able to -The successful learner will be able to -

• After 50 years of information-systems evolution, computers hinder After 50 years of information-systems evolution, computers hinder more than help the process of changemore than help the process of change

• Systems block urgently needed competitive changeSystems block urgently needed competitive change

• 80 - 90% of the average software development budget goes to 80 - 90% of the average software development budget goes to maintenance. (Only 40% in the 1970’s!)maintenance. (Only 40% in the 1970’s!)

• Answer has been Answer has been more productivemore productive software construction (4GLs, software construction (4GLs, CASE tools and object oriented programming)CASE tools and object oriented programming)

• Better answer is to build Better answer is to build more adaptivemore adaptive systems systems

• Software systems must be Software systems must be flexible, easily modifiedflexible, easily modified to meet new to meet new opportunities and challenges opportunities and challenges

From Productivity to Adaptivity...From Productivity to Adaptivity...

The History of Object Technology...The History of Object Technology...

• Basic concepts of object programming were incorporated Basic concepts of object programming were incorporated in “Simula” (simulation language) developed in Norway in in “Simula” (simulation language) developed in Norway in the late 60s to simulate real world processesthe late 60s to simulate real world processes

• Fundamentals of object orientation are as old as universeFundamentals of object orientation are as old as universe• Simula was developed to build working models of complex Simula was developed to build working models of complex

physical systems involving 1,000s of componentsphysical systems involving 1,000s of components• The technology is only now gaining commercial attentionThe technology is only now gaining commercial attention• Most popular languages now are Smalltalk, C++ and JavaMost popular languages now are Smalltalk, C++ and Java• Ada and object COBOL now qualify; Ada and object COBOL now qualify;

Visual Basic v5 lacks only inheritance Visual Basic v5 lacks only inheritance• The promise of object orientation The promise of object orientation

is worth a careful look is worth a careful look

? ? ?

Basic Concepts of Object OrientationBasic Concepts of Object Orientation

• Objects and EncapsulationObjects and Encapsulation

• Classes and InheritanceClasses and Inheritance

• Messages and PolymorphismMessages and Polymorphism

Object programming more closely duplicates real-Object programming more closely duplicates real-world processes than traditional programming world processes than traditional programming because it more nearly models nature’s own means of because it more nearly models nature’s own means of managing complexity and adapting to change.managing complexity and adapting to change.

An object is any person, place, event, thing, screen, An object is any person, place, event, thing, screen, report or concept that applies to the system definedreport or concept that applies to the system definedAn object is any person, place, event, thing, screen, report or concept that applies to the system defined

turnturn

Objects...Objects...

MethodsMethods

AttributesAttributes(Functionality)(Functionality)

(Variables)(Variables)lo

adlo

ad

moveTomoveTo

unloadunload

Methods are Methods are usually publicusually public

Attributes are Attributes are usually privateusually private

stopstop

chgS

peed

chgS

peed

maxSpeedmaxSpeedloadCapacityloadCapacity

FreightVehicleFreightVehicle

Attributes are Attributes are what an object what an object

knowsknows

MethodsMethods are are what an what an

object doesobject does

fuelCapacityfuelCapacity

PropertyProperty

contentscontents

Information hidingInformation hiding is necessary to is necessary to

strong modularitystrong modularity

(Behavior)(Behavior)

Encapsulation encloses an object's state and behavioral characteristics, and is the means by which information hiding and modularity are implemented.

Encapsulation encloses an object's state and behavioral characteristics, and is the means by which information hiding and modularity are implemented.

Objects and Encapsulation...Objects and Encapsulation...

AbstractionAbstraction determines determines

what an what an object knows object knows

and doesand does

Encapsulation Encapsulation hides what an hides what an object knows object knows

and doesand does turnturn

AttributesAttributes(Variables)(Variables)

load

load

moveTomoveTo

unloadunload

stopstop

chgS

peed

chgS

peed

maxSpeedmaxSpeed

FreightVehicleFreightVehicle

MethodsMethods(Functionality)(Functionality)

loadCapacityloadCapacityfuelCapacityfuelCapacitycontentscontents

• Data is wrapped with procedures as in the real worldData is wrapped with procedures as in the real world• Objects make ideal software modules, designed and Objects make ideal software modules, designed and

maintained independently of one anothermaintained independently of one another• Objects are a natural way of viewing complexityObjects are a natural way of viewing complexity• Each object models its own range of behavior, and Each object models its own range of behavior, and

has data about its status -- a self-contained universe has data about its status -- a self-contained universe • Global data does not exist; cannot be corruptedGlobal data does not exist; cannot be corrupted

Advantages of Encapsulated ObjectsAdvantages of Encapsulated Objects

• An object’s data is protected, An object’s data is protected, secure from outside tamperingsecure from outside tampering

• Well defined and “wrapped” Well defined and “wrapped” objects are highly objects are highly reusablereusable

? ?

Basic Concepts of Object OrientationBasic Concepts of Object Orientation

• Objects and EncapsulationObjects and Encapsulation

• Classes and InheritanceClasses and Inheritance

• Messages and PolymorphismMessages and Polymorphism

EncapsulationEncapsulation is the separation of an object’s is the separation of an object’s external external interfaceinterface from its internal implementation. A from its internal implementation. A classclass is a set of objects that share common inherited is a set of objects that share common inherited structure and behavior.structure and behavior.

Classes group similar objects. How many classes to which these objects belong can you name?Classes group similar objects. How many classes to which these objects belong can you name?

Classes...Classes...

Subclasses inherit common methods and variables from the superclass. A class can override inherited attributes and methods.Subclasses inherit common methods and variables from the superclass. A class can override inherited attributes and methods.

Objects Objects andand classes inherit classes inherit

and can and can overrideoverride commonalties commonalties

InheritanceInheritance provides for provides for

special cases of a special cases of a class, thus class, thus classclass

hierarchieshierarchies

Classes...Classes...and Inheritance...and Inheritance...

MethodsMethods

ValuesValues

SuperclassSuperclass

MethodsMethods

ValuesValues

MethodsMethods

ValuesValues

MethodsMethods

ValuesValues

SubclassesSubclasses

MethodsMethods ValuesValuesValuesValues

MethodsMethods ValuesValuesValuesValues

ObjectsObjects

Classes not only group similar objects. They group classes within classes -- subclasses within superclasses.Classes not only group similar objects. They group classes within classes -- subclasses within superclasses.

What Class is What Class is this?this?

Class Hierarchy...Class Hierarchy...

Subclass of what Subclass of what Superclass?Superclass?

WorkersWorkers

Sea CreaturesSea Creatures

Where do Where do these fit?these fit?

SuperclassSuperclass

PeoplePeople

SuperclassSuperclass

AthletesAthletes

MammalsMammals

SubclassesSubclasses

AnimalsAnimals

?

Basic Concepts of Object OrientationBasic Concepts of Object Orientation

• Objects and EncapsulationObjects and Encapsulation

• Classes and InheritanceClasses and Inheritance

• Messages and PolymorphismMessages and Polymorphism

InheritanceInheritance takes advantage of the similarities between takes advantage of the similarities between classes, and classes, and messagingmessaging accomplishes the natural accomplishes the natural interaction of objects needed to accomplish work.interaction of objects needed to accomplish work.

MethodMethodss

Messages...Messages...

Class 2Class 2MethodMethodss

ReceiverReceiver

SenderSender

Message Signature:Message Signature:ObjectName.Method (Parameters)ObjectName.Method (Parameters)

train.shipTo (1000, Chicago)train.shipTo (1000, Chicago) TruckTruck

TrainTrainReturn Value:Return Value:

(Result, if any)(Result, if any) (__________)(__________)

and Polymorphism...and Polymorphism...

Different Different objects can objects can

respond to the respond to the same messagesame message Class 1Class 1

Inte

rfac

Inte

rfac

eeIn

terf

acIn

terf

acee

Real-world objects have an infinite variety of effects on one another, effects implemented through messages.Real-world objects have an infinite variety of effects on one another, effects implemented through messages.

Objects that contain other objects are called composite objects; their member objects are called components.Objects that contain other objects are called composite objects; their member objects are called components.

More characteristics of objects...More characteristics of objects...Composite Objects, or AggregationComposite Objects, or Aggregation

Component Component objects are objects are part of an part of an

aggregationaggregation

Aggregation Aggregation expresses ‘expresses ‘is-is-

part-of’part-of’ relationshipsrelationships

There is a special kind of class called a collection class, which allows managing like objects as a group.

More characteristics of objects...More characteristics of objects...CollectionsCollections

There is a special kind of class called a collection class, which allows managing like objects as a group.

Cabins:Cabins:

First Business EconomyFirst Business Economy

SeatSeatSeatSeat

SeatSeatSeatSeat

SeatSeat

SeatSeatSeatSeat

SeatSeatSeatSeat

SeatSeat

SeatSeatSeatSeat

SeatSeatSeatSeat

SeatSeatSeatSeat

SeatSeatSeatSeat

What collections What collections can be found in can be found in

your house?your house?

Objects, like people, must often collaborate in order to get the job done.Objects, like people, must often collaborate in order to get the job done.

More characteristics of objects...More characteristics of objects...CollaborationCollaboration

DelegationDelegation of of tasks is the tasks is the way objects way objects

collaboratecollaborate to to get work done get work done

Software systems that are easily maintained are loosely coupled and highly cohesive.Software systems that are easily maintained are loosely coupled and highly cohesive.

More characteristics of objects...More characteristics of objects...Coupling and CohesionCoupling and Cohesion

Abstract classes are general, high-level classes created for greater organization; they also serve as inheritance templates. Abstract classes are general, high-level classes created for greater organization; they also serve as inheritance templates.

More characteristics of objects...More characteristics of objects...Abstract classesAbstract classes

MethodsMethods

ValuesValues

MethodsMethods

ValuesValues

MethodsMethods

ValuesValues

MethodsMethods

ValuesValuesMethodsMethods ValuesValuesValuesValues

AthletesAthletes

An An abstract abstract classclass cannot cannot have objects have objects instantiated instantiated

from it. from it.

A class from A class from which objects which objects

can be can be created is a created is a

concrete classconcrete class

Objects are related to one another as expressed in the verbs that connect them, for example, students take courses.Objects are related to one another as expressed in the verbs that connect them, for example, students take courses.

More characteristics of objects...More characteristics of objects...Instance RelationshipsInstance Relationships

CardinalityCardinality determines the determines the

number of number of instances in the instances in the

relationshiprelationship

OptionalityOptionality expresses whether expresses whether the relationship is the relationship is

requiredrequired

• Networked environments introduce several issues about Networked environments introduce several issues about where programmed classes and objects should reside.where programmed classes and objects should reside.How should business logic be divided among network computers?How should business logic be divided among network computers?On which computer should a class be implemented?On which computer should a class be implemented?How can computers on the network be most efficiently used?How can computers on the network be most efficiently used?

• Distributed classes is one architecture for placing Distributed classes is one architecture for placing classes of business logic on computers based on their classes of business logic on computers based on their behaviorbehaviorTraditional client/server approachTraditional client/server approachPeer-to-peer client/server approachPeer-to-peer client/server approachAppletsAppletsProblem: The class may not be where needed at time of process

• Better to distribute objects so they dynamically reside on Better to distribute objects so they dynamically reside on the machine most appropriate for the current processthe machine most appropriate for the current processThe object request broker (ORB) is middleware enabling objects to The object request broker (ORB) is middleware enabling objects to send messages to remote objects send messages to remote objects

Distributing ObjectsDistributing Objects

The The (ORB) object (ORB) object request broker request broker

enables objects to enables objects to communicate across communicate across

the networkthe network

Distributed Objects are objects that dynamically move about the network and reside anywhere they are currently needed.Distributed Objects are objects that dynamically move about the network and reside anywhere they are currently needed.

Distributed objects...Distributed objects...

CORBACORBA is the ORB is the ORB standard with an standard with an

interface definition interface definition languagelanguage (IDL) that (IDL) that

defines servicesdefines services

Message bus

ORBRequest

Response Server

Server

ReceiverReceiver

SenderSender

The first requirement is a The first requirement is a remote messagingremote messaging architecture using a architecture using a message channelmessage channel

The sender of a message first asks the location service for the receiver’s location, then sends its message.The sender of a message first asks the location service for the receiver’s location, then sends its message.

ORB

Distributed objects...Distributed objects...

Location Location transparencytransparency

relieves objects of relieves objects of maintaining maintaining

object locationsobject locations

The Location The Location ServiceService is a service is a service

of the ORB of the ORB

An essential element is location transparencyAn essential element is location transparency

LocationService

ResponseMessage bus

RequestReceiverReceiver

SenderSender

Server

Server

Server

Server

A Proxy Object presents the interface of the remote object it represents to objects on the local machine appearing to them as a local object.

A Proxy Object presents the interface of the remote object it represents to objects on the local machine appearing to them as a local object.

ORB

Distributed objects...Distributed objects...

Remoteness Remoteness transparencytransparency hides hides

the fact the receiving the fact the receiving object is on a object is on a

different machinedifferent machine

ResponseMessage bus

RequestReceiverReceiver

A further step is remoteness transparencyA further step is remoteness transparency

Proxy objectProxy object

SenderSender

AA proxy object proxy object serves as a local serves as a local

representative of a representative of a remote object remote object

Mobile objects Mobile objects allow allow dynamic load dynamic load balancingbalancing of system of system

resources resources

Mobile objects move freely from machine to machine within a virtual object space as they are needed.Mobile objects move freely from machine to machine within a virtual object space as they are needed.

Server

Server

Distributed objects...Distributed objects...

Java allows definition of Java allows definition of mobile objects in its mobile objects in its support for support for agentsagents

The ideal level of implementation is The ideal level of implementation is mobile objectsmobile objects

Mobile ObjectMobile Object

Each higher level of implementation depends upon the lower implementation(s).Each higher level of implementation depends upon the lower implementation(s).

Distributed objects summaryDistributed objects summary

Levels of object distribution implementationLevels of object distribution implementation

Mobile ObjectsMobile Objects

Location TransparencyLocation Transparency

Remoteness TransparencyRemoteness Transparency

Remote MessagingRemote Messaging

BasicBasic

IdealIdeal

• Persistence deals with how objects will be stored between Persistence deals with how objects will be stored between invocations of an object-oriented applicationinvocations of an object-oriented application– Persistent objects must be available & work correctly when neededPersistent objects must be available & work correctly when needed

• Other terminology important to this discussion:Other terminology important to this discussion:– Persistence mechanism - permanent storage facilityPersistence mechanism - permanent storage facility– Persistence layer - the collection of classes necessary for Persistence layer - the collection of classes necessary for

providing and maintaining persistence. The layer wraps the providing and maintaining persistence. The layer wraps the mechanism.mechanism.

– Object identifier (OID) - Typically a large, unique integer used as a Object identifier (OID) - Typically a large, unique integer used as a “key” for accessing an object.“key” for accessing an object.

• There are four common mechanisms:There are four common mechanisms:– Flat filesFlat files– Relational databases Relational databases – Object-oriented databasesObject-oriented databases– Object/relational databasesObject/relational databases

Making objects persistent...Making objects persistent...

Making objects persistent...Making objects persistent...

A common approach is using flat, or single, data filesA common approach is using flat, or single, data files

A flat file is a A flat file is a file of text or file of text or

images images

The biggest design issue is The biggest design issue is whether to read/write whether to read/write

sequentially or randomlysequentially or randomlyFlat File

Map

Flat File Map

ObjectObject

ObjectObject

ObjectObjectObjectObject

ObjectObject

ObjectObject

ObjectObject

Flat File

Data Dictionary

Making objects persistent...Making objects persistent...The most widely used technique is relational databasesThe most widely used technique is relational databases

Relational databases Relational databases can store object-can store object-oriented systems, oriented systems,

especially attributes especially attributes

Persistent objectPersistent object uses data uses data from the dictionary to from the dictionary to create dynamic SQL create dynamic SQL

statements for accessing statements for accessing the databasethe database

PersistentObject

PersistentObject

ObjectObject

ObjectObject

ObjectObjectObjectObject

ObjectObject

ObjectObject

ObjectObject

Data Dictionary

RelationalDatabase

• An An OODBMSOODBMS stores an object’s attributes and methods stores an object’s attributes and methods– This is a fundamental premise of object technologyThis is a fundamental premise of object technology

• Designed specifically for object-oriented systemsDesigned specifically for object-oriented systems– Supports encapsulation, inheritance and polymorphismSupports encapsulation, inheritance and polymorphism– Good systems support object distribution across the networkGood systems support object distribution across the network– Security - restricted access at database, class or object levelsSecurity - restricted access at database, class or object levels– Version control that recognizes functions as well as dataVersion control that recognizes functions as well as data

Making objects persistent...Making objects persistent...

The latest technology is object-oriented databasesThe latest technology is object-oriented databases

Organized, workable Organized, workable approach OR time- approach OR time-

bomb -- it depends on bomb -- it depends on your design your design

• An attempt to combine the advantages of two database An attempt to combine the advantages of two database worlds for storing both data and objectsworlds for storing both data and objects– The relational ability to work with tables of columns and rowsThe relational ability to work with tables of columns and rows– Plus the ability to encapsulate both data and functionalityPlus the ability to encapsulate both data and functionality

• Traversing objects in the database is easy, thus Traversing objects in the database is easy, thus supporting complex relationships between objectssupporting complex relationships between objects

• Object/relational databases implement -Object/relational databases implement -– Inheritance mapping of the type used with relational databasesInheritance mapping of the type used with relational databases– Extensions to SQL for accessing objects as well as dataExtensions to SQL for accessing objects as well as data– Methods in tablesMethods in tables– Easy traversal between objectsEasy traversal between objects

• Better than relational, but easy to fall Better than relational, but easy to fall back into old relational design habitsback into old relational design habits

Making objects persistent...Making objects persistent...A hybrid approach is object/relational databasesA hybrid approach is object/relational databases

Really the best of Really the best of two worlds? -- two worlds? --

Maybe! Maybe!

Course ObjectivesCourse Objectives

• Name and discuss the three foundational concepts upon which Name and discuss the three foundational concepts upon which object technology is builtobject technology is built

• Given a list of terms and characteristics of object methodology, Given a list of terms and characteristics of object methodology, correctly match them with a list of definitionscorrectly match them with a list of definitions

• Contrast object-oriented and traditional programming and Contrast object-oriented and traditional programming and identify the benefits of object orientationidentify the benefits of object orientation

• Describe the benefits of objects residing and operating remotely, Describe the benefits of objects residing and operating remotely, and identify the mechanisms necessary for distributing objectsand identify the mechanisms necessary for distributing objects

• Given names of four persistence mechanisms, provide at least Given names of four persistence mechanisms, provide at least one advantage and one disadvantage of using each as a one advantage and one disadvantage of using each as a database for objects.database for objects.

The successful learner will be able to -The successful learner will be able to -

Thanks for your participation...Thanks for your participation...

Your comments and Your comments and suggestions toward improving suggestions toward improving this course are welcome…..this course are welcome…..