Você está na página 1de 136

CORBA for transportation control and command systems tutorial

ModuIe I : COP8A Disfribufed PoIymorphism


2
3
1
/
0
3
/
0
3
Thales Air Traffic Management
CORBA ATC use case, Note to offline reader.
This is fhe firsf droff of fhe COP8A fronsporfofion fuforioI. This presenfofion is
mode in preporofion of on ATC PFP. If wiII be presenfed of eoch meefing fo heIp new
peopIe fo undersfond how fo use COP8A in Iorge disfribufed compufing sysfem.
Like o good use cose opprooch we wiII nof expIoin COP8A, buf fhe voIue odded of
COP8A ond Objecf Orienfed fechnoIogy for Iorge disfribufed confroI sysfem.
The key ospecf is fo expIoin why if is imporfonf fo ovoid using COP8A onIy by redoing
whof exisf wifh non-objecf fechnoIogies.
Of course if is oIwoys o code sforfing poinf fo firsf redo whof we know when we use o
new fechnoIogy. 8uf we hove fo know fhof if is nof fhe righf soIufion.
Therefore if is nof o crificism, os in good incremenfoI ond iferofive deveIopmenf
process, fhe firsf incremenf is fo Ieorn fhe fechnoIogy ond fhe fooI by oppIying fhem
fo o simpIe cose bosed ond our currenf knowIedge.
3
3
1
/
0
3
/
0
3
Thales Air Traffic Management
The open issue :
Con COP8A be used in Lorge
Disfribufed ConfroI Sysfem such
os Air Troffic ConfroI Sysfem 7
7
4
3
1
/
0
3
/
0
3
Thales Air Traffic Management
3
1
/
0
3
/
0
3
CORBA use case
Can we use CORBA in Large Distributed Control
System ?
What do We want !
Complex System Seamless Integration
Why CORBA ?
Object Software Bus
Design for changes
Change example : Printer
CORBA distributed polymorphism example
CORBA and Distributed Design pattern example
Procedural design versus Object design
Designing Distributed Object
Normalisation processes
5
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Why CORBA ?
Objecf fechnoIogy overcomes fhe choos of soffwore
deveIopmenf ond deIiver higher quoIify producfs in Iess
fime
(Inspired from PofionoI)
We wonf fo use Objecf Disfribufed TechnoIogy To
overcomes fhe choos of Iorge disfribufed soffwore
deveIopmenf ond deIiver higher quoIify producfs in Iess
fime
COP8A provides Disfribufed Objecf PoIymorphism
6
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Practical Use Case
We ore going fo see how COP8A enobIe:
Sysfem SeomIess Infegrofion
0rocefuI Sysfem Moinfenonce ond EvoIufion
Does if work 7
How fo does if work 7
Whof Is fhe odded voIue 7
ExompIes
7
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Complex system : ATC center
Flight Plan
Processing
Flight Plan
Processing
Supervisory
Control
Supervisory
Control
Simulator
Simulator
Recording
Replay
Recording
Replay
controller
Working
Position
controller
Working
Position
Radar Data
Processing
Radar Data
Processing
Radar Front
Processing
Radar Front
Processing
LAN
AFTN/CIDIN
ATFM
ADJACENT
FIR'S/TWR'S
MET Centres
Voice control
and
communications
Voice control
and
communications
Intercom
Priority
Public
RADIO A/G
controller
Working
Position
controller
Working
Position
~ b0
PADAP
8
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Object At system level ?
The quesfion is : con we oppIy objecf fechnoIogy of fhe
sysfem IeveI 7
Con we reoIIy hove communicofion befween sysfem wide
remofe objecf 7
The onswer is :
Yes
8uf you hove fo undersfond whof does if
bring fo you, where is fhe Objecf
Orienfed Design voIue odded.
Then if wiII be very eosy ond sofe.
9
3
1
/
0
3
/
0
3
Thales Air Traffic Management
3
1
/
0
3
/
0
3
CORBA use case
Can we use CORBA in Large Distributed Control
System ?
What do We want !
Complex System Seamless Integration
Why CORBA ?
Object Software Bus
Design for changes
Change example : Printer
CORBA distributed polymorphism example
CORBA and Distributed Design pattern example
Procedural design versus Object design
Designing Distributed Object
Normalisation processes
10
3
1
/
0
3
/
0
3
Thales Air Traffic Management
What Do We Want
CompIex Sysfems SeomIess Infegrofion ond
moinfenonce
Design for chonges
11
3
1
/
0
3
/
0
3
Thales Air Traffic Management
PADAP
ODS
Sup
Pecording
What Do We Want !
Supervision
Operator
Display
System
12
3
1
/
0
3
/
0
3
Thales Air Traffic Management
FIighf
Monogemenf
PADAP
ODS
Sup
Pecording
Pecording PADAP
ODS
Sup
What DO We Want !
Supervision
Operator
Display
System
13
3
1
/
0
3
/
0
3
Thales Air Traffic Management
FIighf
Monogemenf
Pecording PADAP
ODS
Sup
What DO We Want !
Supervision
Operator
Display
System
14
3
1
/
0
3
/
0
3
Thales Air Traffic Management
We want to Increase Integrated software quality
The whole is greater than the sum of
the parts;
The part is greater than a fraction of
the whole.
Aristotle
15
3
1
/
0
3
/
0
3
Thales Air Traffic Management
3
1
/
0
3
/
0
3
CORBA use case
Can we use CORBA in Large Distributed Control
System ?
What do We want !
Complex System Seamless Integration
Why CORBA ?
Object Software Bus
Design for changes
Change example : Printer
CORBA distributed polymorphism example
CORBA and Distributed Design pattern example
Procedural design versus Object design
Designing Distributed Object
Normalisation processes
16
3
1
/
0
3
/
0
3
Thales Air Traffic Management
What We expect ?
We wonf fhis:
FIighf
Monogemenf
Pecording PADAP
ODS
Sup
Supervision
Operator
Display
System
17
3
1
/
0
3
/
0
3
Thales Air Traffic Management
What We expect ?
Mof Thof:
Spogheffi PIofe
18
3
1
/
0
3
/
0
3
Thales Air Traffic Management
What We May Have :
Service D
Service C
Service A
Service 8
Service E
19
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Spaghetti Plate Syndrome
Momed
Pipe
PeIiobIe
MuIficosf
20
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Spaghetti Plate Syndrome
Spogheffi PIofe
Sysfem Archifecf
21
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Spaghetti Plate Syndrome
Spogheffi PIofe
Sysfem Infegrofor
22
3
1
/
0
3
/
0
3
Thales Air Traffic Management
3
1
/
0
3
/
0
3
CORBA use case
Can we use CORBA in Large Distributed Control
System ?
What do We want !
Complex System Seamless Integration
Why CORBA ?
Object Software Bus
Design for changes
Change example : Printer
CORBA distributed polymorphism example
CORBA and Distributed Design pattern example
Procedural design versus Object design
Designing Distributed Object
Normalisation processes
23
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Why CORBA
We need o disfribufed soffwore bus.
8uf fo hove o versofiIe bus wifh componenfs pIug ond
pIoy we need:
Objecf Soffwore 8us.
Objecf poIymorphism enobIe componenf seomIess
infegrofion.
Wifhouf objecf, componenf infegrofion impIies
pervosive modificofions in oII fhe sysfem componenfs
24
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Software Component Integration Bus
Software BUS
25
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Object Software Component Integration Bus
ProceduroI
Objecf
Porodigm
PPC C
COP8A C++/Jovo
MiddIewore Longuoge
Distributed
Polymorphism
Software Components
Evolution
And Replacement
26
3
1
/
0
3
/
0
3
Thales Air Traffic Management
3
1
/
0
3
/
0
3
CORBA use case
Can we use CORBA in Large Distributed Control
System ?
What do We want !
Complex System Seamless Integration
Why CORBA ?
Object Software Bus
Design for changes
Change example : Printer
CORBA distributed polymorphism example
CORBA and Distributed Design pattern example
Procedural design versus Object design
Designing Distributed Object
Normalisation processes
27
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Polymorphism
PoIymorphism
0oF^ definifion, poIymorphism: The obiIify fo subsfifufe
objecfs of mofching inferfoce for one onofher of run-
fime.
PoIymorphism is infensiveIy used inside soffwore
componenfs
We wonf fo use if in befween componenfs
COP8A ~ Disfribufed PoIymorphism
*GoF stand for Gang of Four. It refers to the pattern seminal book of John Vlissides, Erich Gamma,
Richard Helm, Ralph Johnson:
Design Patterns: Elements of Reusable Object-Oriented Software.
28
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Object Software Component Integration Bus
Object Software BUS
29
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Object Software Component Integration Bus
Object Software BUS
Mew Componenf
30
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Procedural versus Object
Procedural Design
Object Design
Before Object After Object
31
3
1
/
0
3
/
0
3
Thales Air Traffic Management
3
1
/
0
3
/
0
3
CORBA use case
Can we use CORBA in Large Distributed Control
System ?
What do We want !
Complex System Seamless Integration
Why CORBA ?
Object Software Bus
Design for changes
Change example : Printer
CORBA distributed polymorphism example
CORBA and Distributed Design pattern example
Procedural design versus Object design
Designing Distributed Object
Normalisation processes
32
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Design for changes
We con'f ovoid "chonges"
We hove fo foreseen fhe chonge in fhe design
If is impossibIe fo free;e everyfhing ond sforf
deveIopmenf
We ore ourseIves fhe moin source of chonge
We con'f free;e oII fhe requiremenfs of fhe very
beginning
FIexibIe design enobIe chonges
Chonges ore voIuobIe
The reoI business is in fhe chonge
33
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Pequiremenfs :
Cusfomers Discover Whof fhey PeoIIy Wonf During or of
fhe End of DeveIopmenfs
TechnoIogy
Performonces Are Increosing Wifh Time
SkiII
We Leorn ond Undersfond fhe ProbIem ond We Discover
fhe Pighf SoIufion on fhe Job
Shorf Term PoIific
Mo Commenfs
^(inspired from Morfin FowIer)
Changes Sources* During Development
34
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Object Oriented Design
Chonges meon odding new code or repIocing exisfing
code wifh new code.
Objecf Orienfed Design (OOD) fechniques
(poIymorphism) enobIe repIocing code ond odding code
wifhouf chonging fhe exisfing code.
Wifh OOD :
OId code con coII new code wifhouf chonge
Wifhouf OOD
OId code con nof coII new code
35
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Without OOD
Without OOD
Design for no Changes
Stationary System
36
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Change management before OOD
Af o given fime fhe sysfem code is sfobiIised ond
voIidofed
The sysfem is mode of coIIing porfs ond coIIed porfs
Current Code Current Code
Caller
called
37
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Change management before OOD
Wifhouf OOD when fhe coIIer code is repIoced if is
possibIe fo ovoid chonges of fhe coIIed code by odopfing
onIy fhe new code. CoIIed code is nof modified.
New Code Old Code
Caller
called
No changes
38
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Change management before OOD
On fhe ofher hond wifhouf OOD, when fhe coIIed code
is chonged fhe coIIer code hos fo be chonge fo be
odopfed fo fhe new code.
New Code Old Code
Old Code New Code
Caller
called
Changes
39
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Change management and code reuse before OO
On fhe ofher hond wifhouf OOD, when fhe coIIed code
is chonged fhe coIIer code hos fo be chonge fo be
odopfed fo fhe new code.
New Code Old Code
Old Code New Code
Modify Old Code
Caller
called
40
3
1
/
0
3
/
0
3
Thales Air Traffic Management
System Integration is a specific change case
Sysfem infegrofion if is o porficuIor chonge cose of
repIocing oId code by new code.
When o new componenf is infegrofed in fhe sysfem oII
fhe sysfem is equivoIenf:
To new code for coIIing inferfoce
To oId code for fhe coIIed inferfoce
System
Component
New
Component
System
Component
Caller
Called
Caller
Called
41
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Integration case
Sysfem infegrofion if is o porficuIor chonge cose of
repIocing oId code by new code.
When o new componenf is infegrofed in fhe sysfem oII
fhe sysfem is equivoIenf:
To new code for coIIing inferfoce
To oId code for fhe coIIed inferfoce
System
Component
New
Component
System
Component
Caller
Called
Caller
Called
New
Code
Old
Code
Old
Code
New
Code
42
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Pervasive Change
Replaced Module (Changed)
43
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Pervasive Change
44
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Pervasive Change
45
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Pervasive Change
Several Changes Replace and Reused
46
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Pervasive Change = Spaghetti Plate
Spogheffi PIofe
After Several Changes Replace and Reused
47
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Procedural versus Object
Without OOD
With OOD
Design For Changes
Evolutionary System
Design for no Changes
Stationary System
48
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Change management with OO reuse
Wifh OOD fhonks fo poIymorphism when fhe coIIed coII
is repIoced by new code if is fronsporenf for fhe coIIer.
Current Code Current Code
Caller
called
OOD
CIoss
49
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Change management with OO reuse
Wifh OOD fhonks fo poIymorphism when fhe coIIed coII
is repIoced by new code if is fronsporenf for fhe coIIer.
Old Code New Code
Add new Code without Modifying Old Code
Caller
called
No changes
CIoss
OOD
50
3
1
/
0
3
/
0
3
Thales Air Traffic Management
With OOD : Software Bus
Object Software Bus
51
3
1
/
0
3
/
0
3
Thales Air Traffic Management
3
1
/
0
3
/
0
3
CORBA use case
Can we use CORBA in Large Distributed Control
System ?
What do We want !
Complex System Seamless Integration
Why CORBA ?
Object Software Bus
Design for changes
Change example : Printer
CORBA distributed polymorphism example
CORBA and Distributed Design pattern example
Procedural design versus Object design
Designing Distributed Object
Normalisation processes
52
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Changes example : the printer
Client
Printing Server
From The CORBA Bible
Michi Henning
Steve Vinoski
Advanced CORBA
Programming with C++
53
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Changes example : the printer
Here is o procficoI exompIe of design for chonges. The
prinfer service.
Af fhe beginning we hod onIy o bIock ond whife Iine
prinfer.
A given omounf of fime Iofer, os hordwore fechnoIogy
evoIve "quicker" fhon soffwore fechnoIogy we con now
use o brond new coIour prinfer.
54
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Changes example : the printer
Client
Printing Server
55
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Changes example : the printer
Old Client
Printing Server
New Client
56
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Change management with OOD reuse
Af fhe beginning we hod onIy o bIock ond whife Iine
prinfer.
Current Code Current Code
Black And White Printer
Client
Printing Server
57
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Change management with OOD reuse
Hordwore fechnoIogy evoIve "quicker" fhon soffwore
fechnoIogy we con now use o brond new coIour prinfer.
Old Code New Code
Colour Printer
Client
Printing Server
58
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Change management and code reuse before OOD
The probIem is fhof our oppIicofion hos fo be chonged
becouse fhe new prinfer server inferfoce chonged.
Old Code New Code
Colour Printer
59
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Change management with OOD reuse
8y using on "objecf" inferfoce ond poIymorphism we con
chonge fhe prinfer server inferfoce fronsporenfIy.
Old Code New Code
Colour Printer
Prinfer
60
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Object properties
"Objecf" meons fhe foIIowing properfies of our
sysfem enfifies:
EncopsuIofion.
Inferfoces.
Inherifonce.
PoIymorphism.
Excepfion hondIing.
PoIymorphism bosed on inferfoce inherifonce
Ief compiIers ond middIewore monoged fhe
chonges.
61
3
1
/
0
3
/
0
3
Thales Air Traffic Management
CORBA = Distributed Polymorphism
In Objecf Orienfed Progromming fhe compiIer
monoges fhe poIymorphism
Wifh COP8A fhe OP8 monoges fhe disfribufed
poIymorphism
COP8A Common Objecf Services (COS) enobIe
disfribufed poIymorphism ond disfribufed
pofferns
62
3
1
/
0
3
/
0
3
Thales Air Traffic Management
3
1
/
0
3
/
0
3
CORBA use case
Can we use CORBA in Large Distributed Control
System ?
What do We want !
Complex System Seamless Integration
Why CORBA ?
Object Software Bus
Design for changes
Change example : Printer
CORBA distributed polymorphism example
CORBA and Distributed Design pattern example
Procedural design versus Object design
Designing Distributed Object
Normalisation processes
63
3
1
/
0
3
/
0
3
Thales Air Traffic Management
CORBA Distributed Polymorphism examples
ExompIe I:
Prinfer wifh COP8A COS Moming service
ExompIe Z:
Prinfer oppIying COP8A COS Life CycIe ond
Absfrocf focfory poffern (0oF)
ExompIe 3:
AppIies sfofe poffern fo fIighf pIon sfofe.
64
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Example UML Diagram
Strip
Strip : string
Print()
Strip : string
Print()
Printer
Print() Print()
Print
1
ColorPrinter
Setcolor() Setcolor()
From The CORBA Bible
Michi Henning
Steve Vinoski
Advanced CORBA
Programming with C++
65
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Example Interface Inheritance (IDL)
1nfeface 1nfeface 1nfeface 1nfeface Co1oP1nfe Co1oP1nfe Co1oP1nfe Co1oP1nfe : : : : P1nfe P1nfe P1nfe P1nfe { {{ {
enum Co1oMode enum Co1oMode enum Co1oMode enum Co1oMode { { { { 81ackAndWh1fe 81ackAndWh1fe 81ackAndWh1fe 81ackAndWh1fe, , , , Iu11Co1o Iu11Co1o Iu11Co1o Iu11Co1o} } } }
vo1d vo1d vo1d vo1d sef sef sef sefco1o co1o co1o co1o {1n {1n {1n {1n Co1oMOde Co1oMOde Co1oMOde Co1oMOde mode} mode} mode} mode}
} } } }
Printer
ColorPrinter
1nfeface 1nfeface 1nfeface 1nfeface P1nfe P1nfe P1nfe P1nfe { {{ {
vo1d vo1d vo1d vo1d p1nf{} p1nf{} p1nf{} p1nf{}
} } } }
66
3
1
/
0
3
/
0
3
Thales Air Traffic Management
printer
Printer
print()
&OLHQW
Print{)
Colour
set_color()
67
3
1
/
0
3
/
0
3
Thales Air Traffic Management
printer
Printer
print()
&OLHQW
Print{)
68
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Prinfer IOP
CORBA Distributed Polymorphism example 1
CIienf
Prinfer
Prinfer.Prinf
Prinfer IOP
foo 8or IOP
WoIdo Fred IOP
quux
Moming
Service
Printer
69
3
1
/
0
3
/
0
3
Thales Air Traffic Management
CORBA = Distributed Polymorphism
COP8A "noming service" enobIes prinfer fo pubIish ifs
inferfoce reference.
CIienfs use fhe noming service fo gef o IogicoI occess fo
prinfer.
Disfribufed Moming Service provides o Iow coupIing
befween cIienfs ond prinfing service.
70
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Objet Reference and Naming
Client Naming
Service
Server
Server exports
IOR
Client lookup
for Interface IOR
Client submits
request to server
71
3
1
/
0
3
/
0
3
Thales Air Traffic Management
CORBA = Distributed Polymorphism
CIienf mokes no ossumpfion on fhe prinfer
impIemenfofion
Thus when fhe oId server is repIoced fhe chonge is
fronsporenf for fhe oId cIienfs.
Mew cIienfs con used fhe prinfer new funcfionoIify
wifhouf modificofions in oId cIienfs.
72
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Prinfer
CoIor IOP
CORBA = Distributed Polymorphism
CIienf
Prinfer
Prinfer IOP
foo 8or IOP
WoIdo Fred IOP
quux
Moming
Service
Prinfer.Prinf
ColorPrinter
Printer Secure Down cosfing
8Iock And Whife
CIienf
73
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Prinfer
CoIor IOP
CORBA Distributed Polymorphism
CIienf
Prinfer
Prinfer IOP
foo 8or IOP
WoIdo Fred IOP
quux
Moming
Service
Prinfer.Prinf
ColorPrinter
Printer Secure Down cosfing
CoIour
CIienf
74
3
1
/
0
3
/
0
3
Thales Air Traffic Management
printer
Printer
print()
&OLHQW
Print{)
Colour
set_color()
75
3
1
/
0
3
/
0
3
Thales Air Traffic Management
3
1
/
0
3
/
0
3
CORBA use case
Can we use CORBA in Large Distributed Control
System ?
What do We want !
Complex System Seamless Integration
Why CORBA ?
Object Software Bus
Design for changes
Change example : Printer
CORBA distributed polymorphism example
CORBA and Distributed Design pattern example
Procedural design versus Object design
Designing Distributed Object
Normalisation processes
76
3
1
/
0
3
/
0
3
Thales Air Traffic Management
We need design patterns
We hove seen fhof COP8A enobIe disfribufed
poIymorphism buf fhe design of sound cIoss Ioffice
require o Iof of insighf.
Design Poffern ond ofhers Pofferns heIp us fo find fhe
cIoss Ioffice which enobIe chonges wifhouf cIienf side
effecf.
COP8A enobIes us fo oppIy weII know pofferns fo
objecf disfribufed progromming.
77
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Distributed Pattern
AppIying Design Poffern (0off) fo Objecf Disfribufed
Sysfem.
Design pofferns enobIe Objecf Soffwore Design which
provides chonges resisfonce bosed on poIymorphism.
ExompIe Focfory poffern which con be used in conjuncfion
wifh Sfofe poffern
Firsf exompIe prinfer wifh Disfribufed Focfory poffern
Second exompIe fIighf pIon sfofe wifh Disfribufed
Focfory poffern
Third exompIe fIighf pIon sfofe wifh sfofe poffern
78
3
1
/
0
3
/
0
3
Thales Air Traffic Management
The GOF Abstract Factory Design Pattern
*GoF stand for Gang of Four. It refers to the famous books of John Vlissides, Erich Gamma, Richard Helm,
Ralph Johnson. Design Patterns: Elements of Reusable Object-Oriented Software.
79
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Polymorphism and Factory Pattern : example 2
CIienf
Prinfer
Prinfer.Prinf
Prinfer IOP
Prinfer
Focfory
80
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Life cycle
Printer Factory
Client Printer
Create Printer
Create Printer
Request
Printer IOR
81
3
1
/
0
3
/
0
3
Thales Air Traffic Management
FACTOY PATTERN (from OOC training)
The Focfory poffern con be oppIied in o wide voriefy of
sifuofions, incIuding fhe foIIowing:
Securify
A client is required to provide security information before the
factory object will allow the client to have access to another
object.
Lood-boIoncing
The factory object manages a pool of objects, often
representing some limited resource, and assigns them to
clients based on some utilization algorithm.
PoIymorphism
A factory object enables the use of polymorphism by returning
object references to different implementations depending on
the criteria specified by a client.
82
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Polymorphism and Factory Pattern
CIienf Prinfer
Prinfer.Prinf
Prinfer IOP
Prinfer
Focfory
83
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Polymorphism and Factory Pattern
CIienf Prinfer
Prinfer.Prinf
Prinfer IOP
Prinfer
Focfory
84
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Factory And Code Generation
Printer
+print()
Black & White
+ print()
&OLHQW
Print{)
85
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Factory And Code Generation
Printer
+print()
&OLHQW
Print{)
Black & White
+ print()
Colour
+ print()
86
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Factory And Code Generation
Printer
+print()
Black & White
+ print()
Print{)
&OLHQW
Colour
+ print()
FAX
+ print()
87
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Factory And Code Generation
Printer
+print()
Black & White
+ print()
Print{)
&OLHQW
Colour
+ print()
FAX
+ print()
Strip
+ print()
88
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Factory And Code Generation
<<Interface>>
Printer
+print()
Black & White
+ print()
Print{)
&OLHQW
Colour
+ print()
FAX
+ print()
Strip
+ print()
89
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Factory And Code Generation
<<Interface>>
Printer Factory
Black & White
Factory
Create
&OLHQW
0enerofed Prinfer Focfory
Colour
Factory
FAX
Factory
Strip
Factory
90
3
1
/
0
3
/
0
3
Thales Air Traffic Management
3
1
/
0
3
/
0
3
CORBA use case
Can we use CORBA in Large Distributed Control
System ?
What do We want !
Complex System Seamless Integration
Why CORBA ?
Object Software Bus
Design for changes
Change example : Printer
CORBA distributed polymorphism example
CORBA and Distributed Design pattern example
Procedural design versus Object design
Designing Distributed Object
Normalisation processes
91
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Why is procedural design expensive to change ?
8ecouse fhe sfrucfure of fhe sysfem is o direcf
mopping of fhe probIem. If does nof represenf
fhe soIufion.
The sysfem sfrucfure is fhe sfrucfure of fhe
probIem.
So when fhe probIem chonges fhe sfrucfure of
fhe sysfem chonges.
92
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Why is OOD easy to change ?
8ecouse in Objecf Orienfed Design fhe
sfrucfure of fhe sysfem is fhe sfrucfure of fhe
soIufion.
Eoch objecf is on independenf enfify.
The soIufion is o sef of cooperofing
independenf enfifies: Objecf.
The soIufion is bosed on fhe objecf
coIIoborofion schemo.
93
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Object collaboration
94
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Why is OOD easy to change ?
So when fhe probIem chonge onIy fhe reIofionship
befween objecf chonges fo fuIfiI fhe new soIufion.
The code of eoch objecf does nof need fo be chonge fo
odopf fo fhe soIufion
Code chonges onIy by repIocing one enfify by on onofher
of fhe some "fype"
95
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Example 3: The problem is in the User Input
Exit Coordination State
A: NIL_EXIT_STATE,
B: FLIGHT_ACTIVATION_PROPOSAL,
C: FLIGHT_ACTIVATION_ALARM,
D: FLIGHT_ACTIVATION_CONFIRMED,
E: HANDOVER_TRANSFERED,
F: COORDINATION_TERMINATED,
G: UNKNOWN_EXIT_STATE
Enter Exit Coordination State =>
96
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Replace case and enum by object .
enum ExitCoordinationState {
NIL_EXIT_STATE,
FLIGHT_ACTIVATION_PROPOSAL,
FLIGHT_ACTIVATION_ALARM,
FLIGHT_ACTIVATION_CONFIRMED,
HANDOVER_TRANSFERED,
COORDINATION_TERMINATED,
UNKNOWN_EXIT_STATE
}
97
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Example of structural fragility : the switch
SfrucfuroI Swifch ore nof resisfonf fo chonges
EvoIuofe fhe pofenfioIify of chonge ond chonge cosf by
counfing in your soffwore fhe number of swifch
OOD repIoces sfrucfuroI swifch by poIymorphism
OOD enobIes hiding IikeIy fo chonge ospecfs,
Everywhere you hove fo decide occording fo fhe sfofe
voIue, you hove fo swifch occording fo fhe sfofe voIue.
When fhe sef of sfofe voIue chonges you hove fo
chonge everywhere fhe swifch cose.
98
3
1
/
0
3
/
0
3
Thales Air Traffic Management
structural switch
static void printsStatus(int status) {
switch(status) {
case NIL_EXIT_STATE :
processing 1
case FLIGHT_ACTIVATION_PROPOSAL:
processing 2
case FLIGHT_ACTIVATION_ALARM:
processing 3
case FLIGHT_ACTIVATION_CONFIRMED:
processing 4
case HANDOVER_TRANSFERED,
processing 5
case COORDINATION_TERMINATED,
processing 6
case UNKNOWN_EXIT_STATE
processing 7
}
}
99
3
1
/
0
3
/
0
3
Thales Air Traffic Management
structural switch
static void flightUpdate(int status) {
switch(status) {
case NIL_EXIT_STATE :
processing 1
case FLIGHT_ACTIVATION_PROPOSAL:
processing 2
case FLIGHT_ACTIVATION_ALARM:
processing 3
case FLIGHT_ACTIVATION_CONFIRMED:
processing 4
case HANDOVER_TRANSFERED,
processing 5
case COORDINATION_TERMINATED,
processing 6
case UNKNOWN_EXIT_STATE
processing 7
}
}
100
3
1
/
0
3
/
0
3
Thales Air Traffic Management
structural switch
static void flightUpdate(int status) {
switch(status) {
case NIL_EXIT_STATE :
processing 1
case FLIGHT_ACTIVATION_PROPOSAL:
processing 2
case FLIGHT_ACTIVATION_ALARM:
processing 3
case FLIGHT_ACTIVATION_CONFIRMED:
processing 4
case HANDOVER_TRANSFERED,
processing 5
case COORDINATION_TERMINATED,
processing 6
case UNKNOWN_EXIT_STATE
processing 7
}
}
static void flightUpdate(int status) {
switch(status) {
case NIL_EXIT_STATE :
processing 1
case FLIGHT_ACTIVATION_PROPOSAL:
processing 2
case FLIGHT_ACTIVATION_ALARM:
processing 3
case FLIGHT_ACTIVATION_CONFIRMED:
processing 4
case HANDOVER_TRANSFERED,
processing 5
case COORDINATION_TERMINATED,
processing 6
case UNKNOWN_EXIT_STATE
processing 7
}
}
static void flightUpdate(int status) {
switch(status) {
case NIL_EXIT_STATE :
processing 1
case FLIGHT_ACTIVATION_PROPOSAL:
processing 2
case FLIGHT_ACTIVATION_ALARM:
processing 3
case FLIGHT_ACTIVATION_CONFIRMED:
processing 4
case HANDOVER_TRANSFERED,
processing 5
case COORDINATION_TERMINATED,
processing 6
case UNKNOWN_EXIT_STATE
processing 7
}
}
staticvoidflightUpdate(int status) {
switch(status){
caseNIL_EXIT_STATE:
processing1
caseFLIGHT_ACTIVATION_PROPOSAL:
processing2
caseFLIGHT_ACTIVATION_ALARM:
processing3
caseFLIGHT_ACTIVATION_CONFIRMED:
processing4
caseHANDOVER_TRANSFERED,
processing5
caseCOORDINATION_TERMINATED,
processing 6
case UNKNOWN_EXIT_STATE
processing 7
}
}
static void flightUpdate(int status) {
switch(status) {
case NIL_EXIT_STATE :
processing 1
case FLIGHT_ACTIVATION_PROPOSAL:
processing 2
case FLIGHT_ACTIVATION_ALARM:
processing 3
case FLIGHT_ACTIVATION_CONFIRMED:
processing 4
case HANDOVER_TRANSFERED,
processing 5
case COORDINATION_TERMINATED,
processing 6
case UNKNOWN_EXIT_STATE
processing 7
}
}
Software
Module A
Software
Module B
Software
Module C
Software
Module D
Software
Module E
101
3
1
/
0
3
/
0
3
Thales Air Traffic Management
The problem space and the solution space.
If fhe swifch voIue refIecfs fhe probIem for exompIe
user inpufs.
When fhe user requesf new cose you hove fo chonge
everywhere you use fhe swifch voIue.
102
3
1
/
0
3
/
0
3
Thales Air Traffic Management
User Imput
Exit Coordination State
A: NIL_EXIT_STATE,
B: FLIGHT_ACTIVATION_PROPOSAL,
C: FLIGHT_ACTIVATION_ALARM,
D: FLIGHT_ACTIVATION_CONFIRMED,
E: HANDOVER_TRANSFERED,
F: COORDINATION_TERMINATED,
G: NewState
H: UNKNOWN_EXIT_STATE
Enter Exit Coordination State =>
103
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Replace case and enum by object .
enum ExitCoordinationState {
NIL_EXIT_STATE,
FLIGHT_ACTIVATION_PROPOSAL,
FLIGHT_ACTIVATION_ALARM,
FLIGHT_ACTIVATION_CONFIRMED,
HANDOVER_TRANSFERED,
COORDINATION_TERMINATED,
NewState,
UNKNOWN_EXIT_STATE
}
104
3
1
/
0
3
/
0
3
Thales Air Traffic Management
static void printsStatus(int status) {
switch(status) {
case NIL_EXIT_STATE :
processing 1
case FLIGHT_ACTIVATION_PROPOSAL:
processing 2
case FLIGHT_ACTIVATION_ALARM:
processing 3
case FLIGHT_ACTIVATION_CONFIRMED:
processing 4
case HANDOVER_TRANSFERED,
processing 5
case COORDINATION_TERMINATED,
processing 6
case New_State,
processing 7
case UNKNOWN_EXIT_STATE
processing 8
}
}
structural switch
105
3
1
/
0
3
/
0
3
Thales Air Traffic Management
structural switch
static void flightUpdate(int status) {
switch(status) {
case NIL_EXIT_STATE :
processing 1
case FLIGHT_ACTIVATION_PROPOSAL:
processing 2
case FLIGHT_ACTIVATION_ALARM:
processing 3
case FLIGHT_ACTIVATION_CONFIRMED:
processing 4
case HANDOVER_TRANSFERED,
processing 5
case COORDINATION_TERMINATED,
processing 6
case UNKNOWN_EXIT_STATE
processing 7
}
}
static void flightUpdate(int status) {
switch(status) {
case NIL_EXIT_STATE :
processing 1
case FLIGHT_ACTIVATION_PROPOSAL:
processing 2
case FLIGHT_ACTIVATION_ALARM:
processing 3
case FLIGHT_ACTIVATION_CONFIRMED:
processing 4
case HANDOVER_TRANSFERED,
processing 5
case COORDINATION_TERMINATED,
processing 6
case UNKNOWN_EXIT_STATE
processing 7
}
}
static void flightUpdate(int status) {
switch(status) {
case NIL_EXIT_STATE :
processing 1
case FLIGHT_ACTIVATION_PROPOSAL:
processing 2
case FLIGHT_ACTIVATION_ALARM:
processing 3
case FLIGHT_ACTIVATION_CONFIRMED:
processing 4
case HANDOVER_TRANSFERED,
processing 5
case COORDINATION_TERMINATED,
processing 6
case UNKNOWN_EXIT_STATE
processing 7
}
}
staticvoidflightUpdate(int status) {
switch(status){
caseNIL_EXIT_STATE:
processing1
caseFLIGHT_ACTIVATION_PROPOSAL:
processing2
caseFLIGHT_ACTIVATION_ALARM:
processing3
caseFLIGHT_ACTIVATION_CONFIRMED:
processing4
caseHANDOVER_TRANSFERED,
processing5
caseCOORDINATION_TERMINATED,
processing 6
case UNKNOWN_EXIT_STATE
processing 7
}
}
static void flightUpdate(int status) {
switch(status) {
case NIL_EXIT_STATE :
processing 1
case FLIGHT_ACTIVATION_PROPOSAL:
processing 2
case FLIGHT_ACTIVATION_ALARM:
processing 3
case FLIGHT_ACTIVATION_CONFIRMED:
processing 4
case HANDOVER_TRANSFERED,
processing 5
case COORDINATION_TERMINATED,
processing 6
case UNKNOWN_EXIT_STATE
processing 7
}
}
Software
Module A
Software
Module B
Software
Module C
Software
Module D
Software
Module E
Changes
106
3
1
/
0
3
/
0
3
Thales Air Traffic Management
OOD hides the problem space
Wifh OOD IikeIy fo chonge ospecfs ore encopsuIofed
ond hidden fo ofher objecfs.
How ond Whof ore seporofed
The probIem : Whof
The soIufion : How
107
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Polymorphism
Status
+print()
NIL_EXIT
_STATE
+ print()
Print()
Client
FLIGHT_ACTIVATION
_PROPOSAL
+ print()
FLIGHT_ACTIVATION
_ALARM
+ print()
UNKNOWN_EXI
T_STATE
+ print()
108
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Factory Pattern
Status
+print()
NIL_EXIT
_STATE
+ print()
Print{)
&OLHQW
FLIGHT_ACTIVATION
_PROPOSAL
+ print()
FLIGHT_ACTIVATION
_ALARM
+ print()
UNKNOWN_EXIT
_STATE
+ print()
StatusFactory
+ create()
109
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Factory Pattern
The swifch is now hidden in fhe objecf sfofe focfory.
The focfory refurns o new objecf of fhe righf derived
cIoss by using o swifch cose on fhe sfofe infeger code.
The cIienf oIwoys sees fhe roof cIoss objecf fype
Sfofus.
Eoch sfofe objecf knows how fo monoge cIienf
invocofion in ifs cose.
110
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Factory pseudo code
static Status create(int status) {
switch(status) {
case NIL_EXIT_STATE :
return status = new nil_exit_state();
break;
case FLIGHT_ACTIVATION_PROPOSAL:
return status = new flight_activation_proposal();
break;
case FLIGHT_ACTIVATION_ALARM:
return status = new flight_activation_alarm();
break;
case FLIGHT_ACTIVATION_CONFIRMED:
return status = new flight_activation_confirmed();
break;
case HANDOVER_TRANSFERED,
return status = new handover_transfered();
break;
case COORDINATION_TERMINATED,
return status = new coordination_terminated();
break;
case UNKNOWN_EXIT_STATE
return status = new unknown_exit_state();
}
}
New Object
111
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Polymorphism and changes
Status
+print()
NIL_EXIT
_STATE
+ print()
Print{)
&OLHQW
FLIGHT_ACTIVATION
_PROPOSAL
+ print()
FLIGHT_ACTIVATION
_ALARM
+ print()
UNKNOWN_EXIT
_STATE
+ print()
NEW_STATE
+ print()
No Changes
112
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Polymorphism and state patterns
If we hove on objecf which sfofe con chonge during ifs
Iifefime ond we hove fo perform differenf operofions
occording fo fhe objecf sfofe we use fhe poffern sfofe.
poffern Sfofe ovoid swifch even if fhe sfofe of fhe
objecf is chonging
poffern Sfofe creofes one objecf for eoch sfofe ond
uses poIymorphism fo enobIe fronsporenf cIienf
invocofion.
113
3
1
/
0
3
/
0
3
Thales Air Traffic Management
State Pattern (from the GoF)
GoF stand for Gang of Four. It refers to the famous books of Vlisside and Co.
Design Patterns: Elements of Reusable Object-Oriented Software.
114
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Object Programming
State2
Stat1
State4
Sfofe diogrom
State5
enum ExifCoordinofionSfofe {
NIL_EXIT_STATE
FLISHT_ACTIVATION_PROPOSAL
FLISHT_ACTIVATION_ALARM
FLISHT_ACTIVATION_CONFIRMED
HANDOVER_TRANSFERED
COORDINATION_TERMINATED
UNkNOWN_EXIT_STATE
}
115
3
1
/
0
3
/
0
3
Thales Air Traffic Management
State Pattern
In fhe sfofe poffern fhe confexf objecf dynomicoIIy
swifches fhe sfofe objecf
AII fhe sfofe objecf exisf of fhe some fime, ogoin eoch
one knows how fo monoge ifs sfofe, ond how fo reocf fo
cIienf invocofions.
116
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Polymorphism
Status
+print()
NIL_EXIT
_STATE
+ print()

&OLHQW
FLIGHT_ACTIVATION
_PROPOSAL
+ print()
FLIGHT_ACTIVATION
_ALARM
+ print()
UNKNOWN_EXIT
_STATE
+ print()
117
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Polymorphism
status
+print()
NIL_EXIT
_STATE
+ print()

&OLHQW
FLIGHT_ACTIVATION
_PROPOSAL
+ print()
FLIGHT_ACTIVATION
_ALARM
+ print()
UNKNOWN_EXIT
_STATE
+ print()
Status
+print()

Context
Concrete state
118
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Coarse Grain Examples
These exompIes ore very simpIe, you con soy foo simpIe
fo refIecf o reoI usoge in o confroI ond commond
sysfem.
AcfuoIIy, if is fhe righf IeveI fo use objecf in o Iorge
disfribufed sysfem.
Theses exompIes ore coorse groin exompIes
Sysfem wide COP8A objecf ore coorse groin objecfs
119
3
1
/
0
3
/
0
3
Thales Air Traffic Management
On line coordination with CORBA Objects
Air Traffic Control Centre
Status
Status
Status
Status
120
3
1
/
0
3
/
0
3
Thales Air Traffic Management
3
1
/
0
3
/
0
3
CORBA use case
Can we use CORBA in Large Distributed Control
System ?
What do We want !
Complex System Seamless Integration
Why CORBA ?
Object Software Bus
Design for changes
Change example : Printer
CORBA distributed polymorphism example
CORBA and Distributed Design pattern example
Procedural design versus Object design
Designing Distributed Object
Normalisation processes
121
3
1
/
0
3
/
0
3
Thales Air Traffic Management
CORBA = Coarse Grain Object
Remote Object Local Object
Operation1()
Operation2()
Operation3()
Operation4()
Fine Grain Object
NO
122
3
1
/
0
3
/
0
3
Thales Air Traffic Management
CORBA = Coarse Grain Object
Remote Object Local Object
GroupOperation()
YES
123
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Distributed Object Patterns
Faade
Local Object
Operation1()
Operation2()
Operation3()
Remote Object
GetRemoteObject()
Foode And
LocoI Coche
124
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Object By Value
Local Object
Operation1()
Operation2()
Operation3()
Remote Object
OBV
Event Factory
new
Event Type
LocoI Objecfs
125
3
1
/
0
3
/
0
3
Thales Air Traffic Management
3
1
/
0
3
/
0
3
CORBA use case
Can we use CORBA in Large Distributed Control
System ?
What do We want !
Complex System Seamless Integration
Why CORBA ?
Object Software Bus
Design for changes
Change example : Printer
CORBA distributed polymorphism example
CORBA and Distributed Design pattern example
Procedural design versus Object design
Designing Distributed Object
Normalisation processes
126
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Separation Of Concern
Fault
Tolerance
Printer
Load
Balancing
Printer
Transaction
Printer
Security
Printer
127
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Separation Of Concern
Inferfoce inherifonce enobIes fronsporenf weoving of
domoin ospecf ond fechnicoI ospecf.
The prinfer moy be o fronsocfionoI objecf
The prinfer moy be o fouIf foIeronf objecf
The prinfer moy be secure objecf
The prinfer moy Iood boIonced objecf
The code responsibIe of fhe domoin ospecf is unowore
of fhe fechnicoI properfies of fhe sysfem objecf os
seen by remofe cIienfs.
128
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Separation Of Concern
Security
Load
Balancing
Printer
Transaction
Fault
Tolerance
129
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Separation Of Concern
Security
Load
Balancing
Printer
Transaction
Fault
Tolerance
130
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Separation Of Concern
Security
Load
Balancing
Printer
Transaction
Fault
Tolerance
Domain
Services
Technical
Services
131
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Y development cycle
Application Logic
Application Techniques
!ntegration
FouIf foIeronce
Lood 8oIoncing
Persisfence
TronsocfionoI
0eneric MiddIewore
Domain Nodel
132
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Application Lay out
AppIicofion
Logic
ond Technique
133
3
1
/
0
3
/
0
3
Thales Air Traffic Management
AppIicofion
Logic
ond Technique
AppIicofion
Logic
Application Lay out
AppIicofion Technique
134
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Application Lay out
AppIicofion Logic
AppIicofion Technique
AppIicofion
Archifecfs
TechnicoI
Archifecfs
135
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Y Standardization Process
Inferfoce inherifonce encouroges soffwore ond sysfem
Ioyering
TechnicoI Ioyer provides generic middIewore dedicofed
fo o specific business
Domoin modeI is independenf of fechnicoI properfies of
fhe sysfem.
We hove o fwo frock deveIopmenf ond normoIi;ofion
process.
136
3
1
/
0
3
/
0
3
Thales Air Traffic Management
Y Standardization Process
Application Logic
Application Techniques
Domain Logic
Patterns
Domain Technical
Patterns
Transportation DTF

Você também pode gostar