Top Banner
Components Components vs. vs. Objects Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland ( Presented at Nordic Workshop on Programming Theory, Bergen, Norway, Oct 11-13, 2000 Presented at Nordic Workshop on Programming Theory, Bergen, Norway, Oct 11-13, 2000)
22

Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

Dec 16, 2015

Download

Documents

Brett Selden
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

Components Components vs. vs. ObjectsObjects

Luigia PetreTurku Centre for Computer Science

&

Åbo Akademi University,

FIN-20520 Turku, Finland

(Presented at Nordic Workshop on Programming Theory, Bergen, Norway, Oct 11-13, 2000Presented at Nordic Workshop on Programming Theory, Bergen, Norway, Oct 11-13, 2000)

Page 2: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

Software Engineering AbstractionsSoftware Engineering Abstractions

Component-based SE = constructing new systems from already existing, service-providing components

Object-based SE = constructing a new system in terms of interacting, distinct units of information and services called objects

Page 3: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

MotivationMotivationBoth components and objects

– have encapsulation properties

– are accessed via well-defined interfaces

– are considered to improve the reuse of software

– are considered to alleviate the software evolution phase

– are thought of being natural abstractions of real-world entities

– a real-world entity can be modelled / implemented using either notion

Page 4: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

Our AimOur Aim

...is to answer to:

(a) What is the essential difference between components and objects?

(b) (Why) do we need them both?

Page 5: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

Components (1)Components (1)

Software components = units of composition with contractually specified interfaces and context dependencies only

A SW component– can be deployed independently– is subject to composition by third parties

Page 6: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

Components (2)Components (2)

=> possibly 3 parties involved: – one specifies the component, – one implements the specification of a component, – one deploys / use the component

contractualinterfaces

contractual dependencies

Component (binary unit)

Page 7: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

contractualinterfaces

contractual dependencies

Component (binary unit)

Page 8: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

Components (3)Components (3)

A system built up from components – is more robust– is more flexible (alleviates evolution)– has a shorter development time / process

The foremost advantage: reuse of software

Page 9: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

Objects (1)Objects (1)

Object - abstraction from a real-world entity, with associated items of information and a set of specific operations

It has– a unique and invariant identifier– a class to which it belongs– a state that has a certain value

Page 10: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

Classes (1)Classes (1)

Class - abstract data type with a set of properties (attributes and operations) common to its objects

- has the means of creating objects with these properties

Page 11: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

Classes (2)Classes (2)Person

PhysicianDriver

superclass / base class

subclasses / derived classes

inheritance

Person} Driver}

Person} Physician}

Page 12: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

Objects (2)Objects (2)Objects interaction -- using each others operations

Objects visibility -- the state and the implementation of the operations is hidden

A system built up from objects– is modular (designing classes rather than the whole

system)– is reusable (inheritance)– alleviates evolution (objects are fundamental and

stable, implementation is hidden)

Page 13: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

The conceptual difference: The conceptual difference: their roletheir role

Objects

– describe / implement real-world entities (and their hierarchies)

– mathematical modelling approach to software

– partition the state space

Components

– describe / implement services of real-world entities

– engineering approach to software

– partition the service space

Page 14: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

Example: Mail Delivery System Example: Mail Delivery System (MDS)(MDS)

Services:– input mail– send mail

– load mail into the transportation means– transport mail to destination

– confirm delivery

Page 15: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

MDS Component ViewMDS Component View

We need a component (PostCar) that is able

– to move– to have a certain loading capacity

We need a component (Driver) that is able – to drive for x hours in a row– to drive certain types of cars– to receive a salary of no more than y

Page 16: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

MDS Object ViewMDS Object View

We need a class PostCar, with – a move operation – a capacity attribute

We need a class Driver, with attributes in some ranges

Page 17: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

Components vs. Objects = Components vs. Objects = Service vs. Identity Service vs. Identity

Using a service from a component: specify the required service and use any component providing an implementation of that service

Using a service from an object: specify what object is used and use the service that particular object (with the particular state) can provide

Page 18: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

Using Components and ObjectsUsing Components and Objects

Components -- service-oriented => they describe best the functionality of a system

Objects -- identity-oriented => they describe best the problem domain of a system

Consequently, we should– start the software development with components– develop each component in terms of objects

Page 19: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

UML Diagrams Outline (1)UML Diagrams Outline (1)

Drive

Unload

Transport

Dispatch

Confirm Delivery

Input Mail

Send Mail

Load

Customer

MDS

Page 20: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

UML Diagrams Outline (2)UML Diagrams Outline (2)

Drive

Unload

Transport

Dispatch

Confirm Delivery

Input Mail

Send Mail

Load

Customer

MDS

Page 21: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

UML Diagrams Outline (3)UML Diagrams Outline (3)

Driver

Drive

Load

UnloadDriver

TruckDriver CarDriver BusDriver

Task

Outage

0..1

1On leave

On Duty

0..11

Page 22: Components vs. Objects Luigia Petre Turku Centre for Computer Science & Åbo Akademi University, FIN-20520 Turku, Finland Presented at Nordic Workshop on.

ConclusionsConclusions

Components -- service-oriented => best as functional abstractions

Objects -- identity-oriented => best as problem domain abstractions

Components and objects -- best as software construction abstractions