Software Architecture CS 414, Software Engineering I Mark Ardis, Rose-Hulman Institute January 14, 2003 1 Outline Definitions of Architecture Architectural Styles Patterns 2 Definitions of Architecture (1) 1. The art and science of designing and erecting buildings. 2. Buildings and other large structures: “the low, brick-and-adobe architecture of the Southwest.” American Heritage® Dictionary of the English Language: Fourth Edition. 2000. 3 Definitions of Architecture (2) 3. A style and method of design and construction: “Byzantine architecture.” 4. Orderly arrangement of parts; structure: “the architecture of the federal bureaucracy; the architecture of a novel.” American Heritage® Dictionary of the English Language: Fourth Edition. 2000. 4 Definitions of Architecture (3) 5. Computer Science The overall design or structure of a computer system, including the hardware and the software required to run it, especially the internal structure of the microprocessor. American Heritage® Dictionary of the English Language: Fourth Edition. 2000. 5 Software Architecture Global control Communication, synchronization and data access Assignment of functionality to design elements Composition of design elements Scaling and performance 6 Outline Definitions of Architecture Architectural Styles Patterns 7 Architectural Styles (1) Dataflow Batch sequential Pipes and filters Call-and-return Main program and subroutine OO systems Hierarchical layers 8 Architectural Styles (2) Independent components Communicating processes Event systems Virtual machines Interpreters Rule-based systems 9 Architectural Styles (3) Data-centered Databases Hypertext systems Blackboards 10 Blackboard Architecture Knowledge sources separate and independent Blackboard data structure problem-solving state knowledge sources update it Control driven by state of blackboard 11 Blackboard Example ks1 ks2 ks7 ks3 Blackboard (shared data) ks6 ks4 ks5 12 Pipe and Filter Architecture Filters Pipes 13 Examples of Pipe-and-Filter Unix shell scripts Compilers lexical analysis, parsing, semantic analysis, code generation Batch sequential degenerate case where all input processed before any output 14 Layered Architecture Applications Utilities Core 15 Interpreter Architecture Program Data Interpreter Engine Output 16 Architecture Review Boards Review Architectural Specifications Provide shared knowledge across projects Prevent mistakes early 17 First Cartoon of the Day 18 Outline Definitions of Architecture Architectural Styles Patterns 19 Christopher Alexander Architect who proposed that people design their own dwellings, using accepted patterns of design Wrote a series of books that influenced the OO community 20 A Place to Wait (1/3) The process of waiting has inherent conflicts in it. On the one hand, whatever people are waiting for---the doctor, an airplane--has built-in uncertainties, which make it inevitable that they must spend a long time hanging around, waiting, doing nothing. 21 A Place to Wait (2/3) On the other hand, they cannot usually afford to enjoy this time. Since they never know when their turn will come, they cannot even take a stroll or sit outside. 22 A Place to Wait (3/3) Therefore: In places where people end up waiting, create a situation which makes the waiting positive. Fuse the waiting with some other activity--newspaper, coffee, pool tables; something which draws people in who are not simply waiting. And also the opposite: make a place which can draw a person waiting into a reverie; quiet; a positive silence. 23 History of Software Patterns Kent Beck had read Alexander's work while in college Kent convinced Ward Cunningham that ideas were good They helped a group design a user interface by letting users design it (1987) 24 Beck and Cunningham's Original Patterns Window Per Task Few Panes Standard Panes Nouns and Verbs Short Menus 25 Window Per Task Make a specific window for each task the user must perform. All of the information needed to complete a task should be available in the Few Panes of the window. Assume prerequisite tasks have been completed (if they haven't, the user will simply change windows). 26 Few Panes To understand complex things one often must see it from several points of view. Therefore: Provide these points of view by dividing the area of your Window Per Task into panes. 27 Standard Panes One must learn to operate each kind of pane offered in the Few Panes of every window. Therefore: Cast each pane into the format offered by one of a few standard panes. [Tektronix had 4.] 28 Nouns and Verbs Things exist while action happens. Therefore: Put lists of things (nouns) in a list pane (one of Few Panes) which persists through interactions. Put actions (verbs) in Short Menus which pop up and then disappear as the action commences. 29 Short Menus The elements of a pop-up menu must be visually searched repeatedly. Therefore: Make them short, fixed and single-level. 30 What is a Pattern? "a named nugget of insight that conveys the essence of a proven solution to a recurring problem within a certain context amidst competing concerns" "a solution to a problem in a context" 31 Pattern Parts Name Problem description Context: when is it applicable? Forces: what are the tradeoffs? Solution Consequences ... 32 A Good Pattern solves a problem is a proven concept describes a relationship has a significant human component provides a solution that isn't obvious 33 Qualities of a Pattern Encapsulation and abstraction Openness and variability Generativity and composability Equilibrium 34 Leaky Bucket Counters (1/2) Problem: How do you deal with transient faults? Context: Fault-tolerant software that must deal with failure events. Forces: You want a hardware module to exhibit hard failures before taking drastic action. Some failures come from the environment, and should not be blamed on the device. 35 Leaky Bucket Counters (2/2) Solution: A failure group has a counter that is incremented for each failure. Each counter is decremented periodically. A hard failure is not reported until the counter exceeds a threshold. Consequences: Hard errors are handled, but transient errors are not as likely to trigger error handling. 36 Second Cartoon of the Day 37 Writers' Workshops Method of publishing patterns Process: 1. 2. 3. Author reads a short segment Others provide constructive criticism while author remains silent Group thanks author (applause) 38 Pattern Mining Interview experts about their domain Record patterns that are found Share resulting set with experts 39 Advantages of Patterns Shorten discovery Avoid inexpert design decisions Reuse large chunks of design 40 References Gamma, Helm, Johnson and Vlissides Design Patterns, Addison-Wesley 1995, ISBN 0-201-63361-2. (Gang of Four) Jim Coplien, Software Patterns Management Briefing, 1996, http://www.bell-labs.com/ user/cope/Patterns/WhitePaper Appleton, Brad Patterns and Software: Essential Concepts and Terminology, 2000 http://www.cmcrossroads.com/ bradapp/docs/patterns-intro.html 41 Books by Alexander Notes on the Synthesis of Form, Harvard University Press, 1964 The Oregon Experiment, Oxford University Press, 1975 A Pattern Language: Towns, Buildings, Construction, Oxford University Press, 1977 The Timeless Way of Building, Oxford University Press, 1979 42