ICS 123 The C 2 Architectural Style ICS

  • Slides: 22
Download presentation
ICS 123 The C 2 Architectural Style ICS 123 Richard N. Taylor and Eric

ICS 123 The C 2 Architectural Style ICS 123 Richard N. Taylor and Eric M. Dashofy UC Irvine http: //www. isr. uci. edu/classes/ics 123 s 02/

Architectural Styles Topic 4 The C 2 Architectural Style ICS 123 • “Walk like

Architectural Styles Topic 4 The C 2 Architectural Style ICS 123 • “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 2

The C 2 Style (Taylor et al. , UC Irvine) Topic 4 The C

The C 2 Style (Taylor et al. , UC Irvine) Topic 4 The C 2 Architectural Style ICS 123 • 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 3

The C 2 Style Topic 4 The C 2 Architectural Style ICS 123 •

The C 2 Style Topic 4 The C 2 Architectural Style ICS 123 • 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) 4

Intellectual Heritage Topic 4 The C 2 Architectural Style ICS 123 • Domain-specific software

Intellectual Heritage Topic 4 The C 2 Architectural Style ICS 123 • 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 5

Qualities Affected Topic 4 The C 2 Architectural Style ICS 123 • Advantages –

Qualities Affected Topic 4 The C 2 Architectural Style ICS 123 • 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!) 6

A Second Look at the C 2 Style Topic 4 The C 2 Architectural

A Second Look at the C 2 Style Topic 4 The C 2 Architectural Style ICS 123 • Asynchronous, event-based communication among • • autonomous components, mediated by active connectors No component-component links Event-flow rules: • Hierarchical application Notifications fall Requests rise Connector “pull” Component “push” Connector 7

Example: KLAX Video Game Topic 4 The C 2 Architectural Style ICS 123 KLAX

Example: KLAX Video Game Topic 4 The C 2 Architectural Style ICS 123 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 8

A Simple Example: KLAX Clock logic Next tile placing logic Status ADT Tile match

A Simple Example: KLAX Clock logic Next tile placing logic Status ADT Tile match logic • KLAX™ game – 16 components, approx. 4 k SLOC, 100 kb compiled – implemented from scratch in the C 2 architectural style [TMA+96] Chute ADT Well ADT Palette ADT Relative pos logic Status artist Well artist Chute artist Tile artist Layout manager Graphics binding Palette artist

KLAX: Adaptability • Spelling KLAX – spell words from falling letters – replaces 3

KLAX: Adaptability • Spelling KLAX – spell words from falling letters – replaces 3 components Clock logic Next tile placing logic Status ADT Tile match logic • Multi-player networked KLAX – a match adds a tile to opponents’ chute Well ADT Palette ADT Relative pos logic Status logic • High score list – adds 3 new components Chute ADT Status artist Well artist Chute artist Tile artist Layout manager Graphics binding Palette artist

KLAX: Adaptability • Spelling KLAX – spell words from falling letters – replaces 3

KLAX: Adaptability • Spelling KLAX – spell words from falling letters – replaces 3 components Clock logic Nextletter tile Next placing logic Status ADT Tile match Word match logic • Multi-player networked KLAX – a match adds a tile to opponents’ chute Well ADT Palette ADT Relative pos logic Status logic • High score list – adds 3 new components Chute ADT Status artist Well artist Chute artist Tile Letter artist Layout manager Graphics binding Palette artist

KLAX: Adaptability • Spelling KLAX – spell words from falling letters – replaces 3

KLAX: Adaptability • Spelling KLAX – spell words from falling letters – replaces 3 components High score ADT Clock logic Nextletter tile High score Next placing logic Status ADT Tile match Word match logic • Multi-player networked KLAX – a match adds a tile to opponents’ chute Well ADT Palette ADT Relative pos logic Status logic • High score list – adds 3 new components Chute ADT High score artist Status artist Well artist Chute artist Tile Letter artist Layout manager Graphics binding Palette artist

KLAX: Adaptability • Spelling KLAX – spell words from falling letters – replaces 3

KLAX: Adaptability • Spelling KLAX – spell words from falling letters – replaces 3 components High Client score ADT Clock logic Nextletter tile High score Next placing logic Status ADT Tile match Word match logic • Multi-player networked KLAX – a match adds a tile to opponents’ chute Well ADT Palette ADT Relative pos logic Status logic • High score list – adds 3 new components Chute ADT High Client score artist Status artist Well artist Chute artist Tile Letter artist Layout manager Graphics binding Palette artist

C 2 Component Structure (I) Topic 4 The C 2 Architectural Style ICS 123

C 2 Component Structure (I) Topic 4 The C 2 Architectural Style ICS 123 • The internal object is the Domain Translator Dialog Wrapper Internal Object • “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 requests 14 notifications reuse of independentlydeveloped, “off-the-shelf” components as the internal object

C 2 Component Structure (II) Topic 4 The C 2 Architectural Style ICS 123

C 2 Component Structure (II) Topic 4 The C 2 Architectural Style ICS 123 • The dialog provides the Domain Translator Dialog requests 15 Wrapper Internal Object notifications • • “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

C 2 Component Connection Topic 4 The C 2 Architectural Style ICS 123 •

C 2 Component Connection Topic 4 The C 2 Architectural Style ICS 123 • C 2 Connectors Connector 16 – 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 » …

A Typical C 2 Configuration Topic 4 The C 2 Architectural Style ICS 123

A Typical C 2 Configuration Topic 4 The C 2 Architectural Style ICS 123 • Computation originates Comp 1 Comp 5 notifications requests Conn 1 mostly in lower layers • Components need not Comp 2 Conn 2 process all messages they receive • Connectors need not fully segregate layers Comp 3 17 Comp 4

Rules of the C 2 Style Topic 4 The C 2 Architectural Style ICS

Rules of the C 2 Style Topic 4 The C 2 Architectural Style ICS 123 • 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 18

Topic 4 The C 2 Architectural Style Component Interfaces Comp 1 Comp 5 notifications

Topic 4 The C 2 Architectural Style Component Interfaces Comp 1 Comp 5 notifications requests Conn 1 Comp 2 Conn 2 Comp 3 Comp 4 ICS 123 Comp 1 top bottom request query(ID: int, M: msg) notification ack(ID: int) Comp 2 top request notification ack(ID: int) bottom request init(ID: int) notification. . . 19

A C 2 Style Architecture for KLAX Topic 4 The C 2 Architectural Style

A C 2 Style Architecture for KLAX Topic 4 The C 2 Architectural Style ICS 123 • Exhibits typical C 2 characteristics – State components reside in upper layers – Interface components reside in lower layers – Intermediate layers provide control logic 20

Turning KLAX into Spelling KLAX Topic 4 The C 2 Architectural Style ICS 123

Turning KLAX into Spelling KLAX Topic 4 The C 2 Architectural Style ICS 123 • 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 21

Example: A Long-Distance Telecommunications System Topic 4 The C 2 Architectural Style ICS 123

Example: A Long-Distance Telecommunications System Topic 4 The C 2 Architectural Style ICS 123 • Telephones • Local Switches (one per area code) • Long-Distance Switches (communications backbone) • Call Records database • Other embellishments – – 22 800 numbers 911 stations Operator stations Bill generators