object vs components- com para tie
TRANSCRIPT
-
8/7/2019 Object vs Components- Com Para Tie
1/22
ComponentsComponentsvsvs.. ObjectsObjects
Luigi a PetreTurku Centre for Computer Science
&
Abo 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)
-
8/7/2019 Object vs Components- Com Para Tie
2/22
Software Engineering AbstractionsSoftware Engineering Abstractions
? Component-based SE = constructing new systemsfrom already existing, service-providingcomponents
? Object-based SE = constructing a new system interms of interacting, distinct units of information andservices called objects
-
8/7/2019 Object vs Components- Com Para Tie
3/22
MotivationMotivation
Both 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-worldentities
a real-world entity can be modelled / implemented usingeither notion
-
8/7/2019 Object vs Components- Com Para Tie
4/22
Our AimOur Aim
...is to answer to:
(a) What is the essential difference between
components and objects?
(b) (Why) do we need them both?
-
8/7/2019 Object vs Components- Com Para Tie
5/22
Components (1)Components (1)
Software components = units of compositionwith contractually specified interfaces andcontext dependencies only
A SW component
can be deployed independently
is subject to composition by third parties
-
8/7/2019 Object vs Components- Com Para Tie
6/22
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
contractualdependencies
Component
(binaryunit)
-
8/7/2019 Object vs Components- Com Para Tie
7/22
contractualinterfaces
contractualdependencies
Component
(binaryunit)
-
8/7/2019 Object vs Components- Com Para Tie
8/22
-
8/7/2019 Object vs Components- Com Para Tie
9/22
Objects (1)Objects (1)
Object - abstraction from a real-world entity,with associated items of information and a setof specific operations
It has
a unique and invariant identifier
a class to which it belongsa state that has a certain value
-
8/7/2019 Object vs Components- Com Para Tie
10/22
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 theseproperties
-
8/7/2019 Object vs Components- Com Para Tie
11/22
Classes (2)Classes (2)Person
PhysicianDriver
superclass / base class
subclasses /derived classes
inheritance
?Person} ? ??Driver}
?Person} ? ??Physician}
-
8/7/2019 Object vs Components- Com Para Tie
12/22
Objects (2)Objects (2)
Objects interaction -- using each others operationsObjects visibility -- the state and the implementation of
the operations is hidden
A system built up from objectsis modular (designing classes rather than the whole
system)
is reusable (inheritance)
alleviates evolution (objects are fundamental andstable, implementation is hidden)
-
8/7/2019 Object vs Components- Com Para Tie
13/22
The conceptual difference:The conceptual difference: their roletheir role
Objects
describe / implementreal-world entities (and
their hierarchies)
mathematical modelling
approach to software
partition the state space
Components
describe / implementservices of real-world
entities
engineering approach to
software
partition the servicespace
-
8/7/2019 Object vs Components- Com Para Tie
14/22
Example: Mail Delivery SystemExample: Mail Delivery System
(MDS)(MDS)Services:
input mail
send mailload mail into the transportation means
transport mail to destination
confirm delivery
-
8/7/2019 Object vs Components- Com Para Tie
15/22
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
-
8/7/2019 Object vs Components- Com Para Tie
16/22
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 someranges
-
8/7/2019 Object vs Components- Com Para Tie
17/22
ComponentsComponents vsvs. Objects =. Objects =
ServiceService vsvs. Identity. Identity
Using a service from a component:specify the required service and use any
component providing an implementation ofthat service
Using a service from an object:specify what object is used and use the
service that particular object (with theparticular state) can provide
-
8/7/2019 Object vs Components- Com Para Tie
18/22
Using Components and ObjectsUsing Components and Objects
Components -- service-oriented => they describe bestthe functionality of a system
Objects -- identity-oriented => they describe best theproblem domain of a system
Consequently, we should
start the software development with components
develop each component in terms of objects
-
8/7/2019 Object vs Components- Com Para Tie
19/22
UML Diagrams Outline (1)UML Diagrams Outline (1)
Drive
Unload
Transport
Dispatch
Confirm Delivery
Input Mail
Send Mail
Load
Customer
MDS
-
8/7/2019 Object vs Components- Com Para Tie
20/22
UML Diagrams Outline (2)UML Diagrams Outline (2)
Drive
Unload
Transport
Dispatch
Confirm Delivery
InputMail
SendMail
Load
Customer
MDS
-
8/7/2019 Object vs Components- Com Para Tie
21/22
UML Diagrams Outline (3)UML Diagrams Outline (3)
DriverDrive
Load
UnloadDriver
TruckDriver CarDriver BusDriver
Task
Outage
0..1
1Onleav
eOnDuty
0..11
-
8/7/2019 Object vs Components- Com Para Tie
22/22
ConclusionsConclusions
? Components -- service-oriented => best asfunctionalabstractions
? Objects -- identity-oriented => best asproblem domainabstractions
? Components and objects -- best as softwareconstructionabstractions