the c2 architectural style

22
ICS 123 The C2 Architectural Style ICS 123 Richard N. Taylor and Eric M. Dashofy UC Irvine http://www.isr.uci.edu/ classes/ics123s02/

Upload: jonco

Post on 23-Feb-2016

39 views

Category:

Documents


0 download

DESCRIPTION

The C2 Architectural Style. ICS 123 Richard N. Taylor and Eric M. Dashofy UC Irvine http://www.isr.uci.edu/classes/ics123s02/. Architectural Styles. “Walk like this!” “Why should I walk like that?” Canonical structures and rules provide context focus attention - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: The C2 Architectural Style

ICS 123

The C2 Architectural Style

ICS 123Richard N. Taylor and Eric M. Dashofy

UC Irvinehttp://www.isr.uci.edu/classes/

ics123s02/

Page 2: The C2 Architectural Style

ICS 123

2

Topic 4The C2Architectural StyleArchitectural Styles

•“Walk like this!”•“Why should I walk like that?”•Canonical structures and rules

–provide context–focus attention–promote shared understanding–carry hard-won domain knowledge and proven solution techniques

Page 3: The C2 Architectural Style

ICS 123

3

Topic 4The C2Architectural Style

The C2 Style(Taylor et al., UC Irvine)•A general multi-tier architectural style

– Asynchronous message-based integration of independent components•Based on past experience with the model-view-

controller design pattern and the Chiron-1 UIMS– Generalizes architectures for user interface management systems

•Notable feature: flexible connectors– Accommodate arbitrary numbers of components– Facilitate runtime architectural change

•Principle of substrate independence– A component need not know anything about components beneath it– We’ll define the layering rules and the notion of “beneath” shortly …

•Rich design environment for composition & analysis

Page 4: The C2 Architectural Style

ICS 123

4

Topic 4The C2Architectural StyleThe C2 Style

•Autonomous components– own thread and non-shared address space

•All communication is by asynchronous events which must pass through a connector

– connectors may be complex and powerful•Some additional rules to promote reuse•(A variety of implementation techniques)

Page 5: The C2 Architectural Style

ICS 123

5

Topic 4The C2Architectural StyleIntellectual Heritage

•Domain-specific software architectures– concurrent, loosely coupled, distributed, dynamic apps

•Smalltalk’s model-view-controller paradigm

•Field’s event-based integration•Abstraction and separation of concerns•OO typing•Lisp, et.al.s dynamic properties

Page 6: The C2 Architectural Style

ICS 123

6

Topic 4The C2Architectural StyleQualities Affected

• Advantages– Reusability (discrete components promote reusability)– Evolvability/Flexibility: Because event receivers are not explicitly

named, it is possible to integrate new components fairly easily– Dynamism (can change architecture on the fly)– Visibility (explicit & mandatory connectors provide points for

observation)– Distributability (all events are assumed to be independent, and

therefore components can be distributed across hosts)– Understandability (particularly promoted via substrate independence)

• Disadvantages– Familiarity: Programmers often not initially familiar with event-based &

asynchronous programming– Complexity: Because of asynchrony, concurrency issues are more

prevalent and must be handled, event interactions are not always obvious (although tools can help!)

Page 7: The C2 Architectural Style

ICS 123

7

Topic 4The C2Architectural Style

A Second Look at the C2 Style• Asynchronous, event-based communication

among autonomous components, mediated by active connectors

• No component-component links• Event-flow rules:

• Hierarchical applicationNotifications fallRequests rise Component

Connector

“push”

“pull”

Connector

Page 8: The C2 Architectural Style

ICS 123

8

Topic 4The C2Architectural Style

Example: KLAX Video Game

KLAX Chute– Tiles of random colors drop one cell at

a time, starting at random times and locations

KLAX Palette– Palette manipulated to catch tiles

coming down the Chute and to drop them into the Well

KLAX Well– Horizontal, vertical and diagonal sets of

three or more consecutive tiles of the same color are removed, and any tiles above them collapse down to fill in the newly-created empty spaces

KLAX Status– Points scored as sets are formed– Lives lost as Well or Palette spills over

Page 9: The C2 Architectural Style

A Simple Example: KLAX

• KLAX™ game – 16 components, approx.

4k SLOC, 100kb compiled– implemented from scratch in

the C2 architectural style[TMA+96]

Clocklogic

StatusADT

ChuteADT

WellADT

PaletteADT

Next tileplacing logic

Tile matchlogic

Relative poslogic

Statuslogic

Statusartist

Wellartist

Chuteartist

Paletteartist

Tileartist

Layoutmanager

Graphicsbinding

Page 10: The C2 Architectural Style

KLAX: Adaptability• Spelling KLAX

– spell words from falling letters– replaces 3 components

• High score list– adds 3 new components

• Multi-player networked KLAX– a match adds a tile to

opponents’ chute

Clocklogic

StatusADT

ChuteADT

WellADT

PaletteADT

Next tileplacing logic

Tile matchlogic

Relative poslogic

Statuslogic

Statusartist

Wellartist

Chuteartist

Paletteartist

Tileartist

Layoutmanager

Graphicsbinding

Page 11: The C2 Architectural Style

KLAX: Adaptability• Spelling KLAX

– spell words from falling letters– replaces 3 components

• High score list– adds 3 new components

• Multi-player networked KLAX– a match adds a tile to

opponents’ chute

Clocklogic

StatusADT

ChuteADT

WellADT

PaletteADT

Next tileplacing logic

Tile matchlogic

Relative poslogic

Statuslogic

Statusartist

Wellartist

Chuteartist

Paletteartist

Tileartist

Layoutmanager

Graphicsbinding

Letterartist

Next letterplacing logic

Word matchlogic

Page 12: The C2 Architectural Style

KLAX: Adaptability• Spelling KLAX

– spell words from falling letters– replaces 3 components

• High score list– adds 3 new components

• Multi-player networked KLAX– a match adds a tile to

opponents’ chute

Clocklogic

StatusADT

ChuteADT

WellADT

PaletteADT

Next tileplacing logic

Tile matchlogic

Relative poslogic

Statuslogic

Statusartist

Wellartist

Chuteartist

Paletteartist

Tileartist

Layoutmanager

Graphicsbinding

Letterartist

Next letterplacing logic

Word matchlogic

High scoreADT

High scoreartist

High scorelogic

Page 13: The C2 Architectural Style

KLAX: Adaptability• Spelling KLAX

– spell words from falling letters– replaces 3 components

• High score list– adds 3 new components

• Multi-player networked KLAX– a match adds a tile to

opponents’ chute

Clocklogic

StatusADT

ChuteADT

WellADT

PaletteADT

Next tileplacing logic

Tile matchlogic

Relative poslogic

Statuslogic

Statusartist

Wellartist

Chuteartist

Paletteartist

Tileartist

Layoutmanager

Graphicsbinding

Letterartist

Next letterplacing logic

Word matchlogic

High scoreADT

High scoreartist

High scorelogic

ClientADT

Clientartist

Page 14: The C2 Architectural Style

ICS 123

14

Topic 4The C2Architectural Style

C2 Component Structure (I)

DialogInternalObject

DomainTranslator Wrapper

requests

notifications

• The internal object is the “guts” of the component

• The wrapper maps messages to operations of the internal object

– Requests Operation Invocations

– Operation Results Notifications– Wrapped object can be described

in terms of method signatures• This organization allows

reuse of independently-developed, “off-the-shelf” components as the internal object

Page 15: The C2 Architectural Style

ICS 123

15

Topic 4The C2Architectural Style

C2 Component Structure (II)

DialogInternalObject

DomainTranslator Wrapper

• The dialog provides the “control logic”, routing any relevant message to/from the internal object

• The domain translator translates messages from this component’s “vocabulary” to that of the layer above

• Note that a component never requests anything of components “beneath” it

requests

notifications

Page 16: The C2 Architectural Style

ICS 123

16

Topic 4The C2Architectural Style

C2 Component Connection

• C2 Connectors– Broadcast all messages

received on the bottom side to the top side, and vice versa

– Operate across machines– Operate across languages– Accommodate dynamic

attachment and removal of components

– Can be implemented in a number of ways

» Procedure calls» Ada rendezvous» Java events» CORBA ORBs» …

Connector

Page 17: The C2 Architectural Style

ICS 123

17

Topic 4The C2Architectural Style

A Typical C2 Configuration

Comp1

Comp2

Comp4Comp3

Conn1

Conn2requ

ests

notifi

catio

ns

Comp5

• Computation originates mostly in lower layers

• Components need not process all messages they receive

• Connectors need not fully segregate layers

Page 18: The C2 Architectural Style

ICS 123

18

Topic 4The C2Architectural StyleRules of the C2 Style

•Components are never attached to other components

– A component can be attached to at most one connector on its top side and one on its bottom side

•Connectors can be attached to other connectors

– A connector must have at least one component or connector attached on its top side and one attached on its bottom side

•Requests only go up in an architecture•Notifications only go down in an architecture•There is no circularity allowed

– A component can never receive its own messages

Page 19: The C2 Architectural Style

ICS 123

19

Topic 4The C2Architectural StyleComponent Interfaces

Comp1

Comp2

Comp4Comp3

Conn1

Conn2requ

ests

notifi

catio

ns

Comp5

Comp1 top bottom request query(ID: int, M: msg) notification ack(ID: int)

Comp2 top request notification ack(ID: int) bottom request init(ID: int) notification

...

Page 20: The C2 Architectural Style

ICS 123

20

Topic 4The C2Architectural Style

A C2 Style Architecture for KLAX

• Exhibits typical C2 characteristics

– State components reside in upper layers

– Interface components reside in lower layers

– Intermediate layers provide control logic

Page 21: The C2 Architectural Style

ICS 123

21

Topic 4The C2Architectural Style

Turning KLAX intoSpelling KLAX

• Flexible connectors facilitate the necessary architectural changes

– Next Letter Placing Logic component substituted for Next Tile Placing Logic component

– Spelling Logic substituted for Tile Logic

– Letter Artist substituted for Tile Artist

Page 22: The C2 Architectural Style

ICS 123

22

Topic 4The C2Architectural Style

Example: A Long-Distance Telecommunications System•Telephones•Local Switches (one per area code)•Long-Distance Switches (communications

backbone)•Call Records database•Other embellishments

– 800 numbers– 911 stations– Operator stations– Bill generators