CISC 323 Intro to Software Engineering
Week 8: Software Architecture (Continued)
CISC 323 Intro to Software Engineering Week 8: Software - - PowerPoint PPT Presentation
CISC 323 Intro to Software Engineering Week 8: Software Architecture (Continued) CISC 323 Intro to Software Engineering Lecture 8-1 Data-Centered and Interpreter Architectural Styles Architectural Style Examples [Shaw&Garlan]
Week 8: Software Architecture (Continued)
Lecture 8-1 Data-Centered and Interpreter Architectural Styles
3 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
[Shaw&Garlan]
4 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– Allows data to be allowing shared amongst a set
– Active repository cooperative, distributed decision making
5 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
share data
structure shared by multiple components
components to read/write to repository
Repository
architecture style
passed between phases
that can be passed over a pipe --
syntax tree
program text executable code tokens parse tree parse tree
7 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
program text executable code tokens control control
Repository: Parse Tree
Control information passed between phases rather than parse tree
8 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– For complex data structures, saves overhead
from one component to another – If components on different machines, this overhead might be considerable – If components on different machines, cost of accessing repository might be high
Repository c1 c2 c3
9 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– E.g., if components and repositories on different machines, each call to repository goes over network – Need to balance this cost vs cost of moving data between phases using pipes and filters – E.g., if c2 makes 1000 calls for information to repository, each call takes 1 ms, total time = 1 s. Compare to time to pass repository from c1 to c2
Repository c1 c2 c3
10 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– Need to ensure repository can scale to load of components making requests of it – Ideally, do not want components waiting while repository operates on long queue of requests – This analysis is complex, out
Repository c1 c2 c3
11 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– Numerous infrastructures for repositories already exist -- e.g.
Invocation (RMI)
– Need to balance savings in development time vs need to learn infrastructures
Repository c1 c2 c3
12 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– Repository potentially available to anyone who can connect to it – Particularly dangerous in distributed setting where repository available via Internet protocol – E.g., don’t want medical patient information available to anyone who knows IP address of medical database
Repository c1 c2 c3
13 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– Repository becomes critical component in system – Failure in repository causes entire system to fail
Repository c1 c2 c3
14 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– Can activate components in response to changes in blackboard contents
– Use blackboard to mediate cooperative activity amongst components – Tasks where desired
defined or error prone
Blackboard c1 c2 c3 Update/request information from repository Activate components as new information becomes available
(e.g. Apache)
(e.g., Netscape, Internet Explorer)
Requests for book info, delivery times, orders, etc. HTML document Requests for book info Requests for delivery time Order placement Request availability
16 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
coordinate filling orders
arrives
packaged
Request availability
Record new stock Record stock shipped Inform
Initiate shipping Order stock
17 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– Using: Active badges, voice recognition, cameras – Allows
machines)
– Sitting down at someone else’s PC is just like sitting down at your own
– Use gestures/voice to
– Combine modalities
18 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
physical devices
– Cameras, microphones, door switches
– Voice recognition speech recognition, gesture recognition
– Who is in room, what command are they executing
Microphone Camera1 Cameran
Reader Voice samples Badge data Camera inputs People detector Model: people in room Command detector Model: command
20 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
21 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
[Shaw&Garlan]
22 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– Providing higher level language for problem domain simplifies programming problem – Examples
23 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
Program state Program being interpreted Simulated Interpretation Engine Internal Interpreter State inputs
selected instruction selected data program code
24 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
Program state Java class files Java Virtual Machine (JVM) JVM State inputs
selected instruction selected data program code
25 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
represented as a set of class files
– Contain byte code describing operations on the Java Virtual Machine
executed as if they were being run on a native machine
represented in JVM Program state Java class files Java Virtual Machine (JVM) JVM State inputs
selected instruction selected data program code
26 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
structured data for
– Archiving – Interchanging between applications – Sending over the Internet
style
See e.g. http://www.xml101.com:8081/xml/
– Follow format of
<tagname attr1=value1,…,attrn=valuen>
contents
</tagname>
<books> <book isbn=”0201199300"> <title>Software Architecture in Practice</title> <author>Len Bass</author> <author>Paul Clements</author> <author>Rick Kazman</author> </book> </books>
28 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
particular kind of XML document
<!DOCTYPE listOfBooks [
<!ELEMENT books (book*)> <!ELEMENT book (title,author+)> <!ATTLIST book isbn CDATA “0”> <!ELEMENT title (#CDATA)> <!ELEMENT author (#CDATA)>
]> <listOfBooks>
<books> <book isbn=”0201199300"> <title>Software Architecture in Practice</title> <author>Len Bass</author> <author>Paul Clements</author> <author>Rick Kazman</author> </book> </books> Example document following this DTD
29 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– A book must have a title and 1 or more authors – A set of books consists of 0 or more books – A book has an ISBN attribute (unique number for books), which is character text (CDATA), with a default value of “0”
<books> <book isbn=”0201199300"> <title>Software Architecture in Practice</title> <author>Len Bass</author> <author>Paul Clements</author> <author>Rick Kazman</author> </book> </books>
30 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
Component for converting book
Java classes Book order as Java class Book order as XML document
31 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
Books DTD XML Processor DTD Book order as Java class Book order as XML document Component for converting book
to Java classes
32 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
Books DTD XML Processor Book order Web Browser (XML document) Order Processor DTD Books data structure XML Order Other components…
33 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
capable of processing book orders
– Can reuse XML processor in many contexts – If format of book orders change, just need to change DTD, not code
34 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– Tremendous potential for reuse
– Interpretation may be slower than hand-coded solutions
– Can be improved by restricting modification to data being interpreted
Lecture 8-2 PAC Architectural Style
36 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
[Shaw&Garlan]
37 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
multiple concrete architectures
– Program decomposed into a set of agents, each responsible for some part of the task of interacting with the user
38 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
controlling navigation
– “Back” means return to previous page in history, “Forward” means go forward to last page we moved back from (if there is
List of pages visited Current page
page, sets current page to that page
39 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– A label (e.g. “Back”, “Forward”) – A state (disabled, enabled)
– “Rollover” - become highlighted when mouse moves over them – Become depressed following mouse down – Become released following mouse up
Enabled button Disabled button “Rolled over” button Depressed button
40 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– Label (String value) – Is Enabled? (Boolean value) – Is “rolled over”? (Boolean value) – Is depressed? (Boolean value)
values and a string value
41 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
constructed from a set of components
composed of three facets
– Presentation: handles user input and redraws the display – Abstraction: underlying state of interactive entity – Control: mediates communication between Presentation, Abstraction and other PAC components
Presentation Abstraction
Control
Inter-facet communication, typically event or method call
42 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– Java object containing methods to set/get
Presentation Abstraction
Control
43 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– Accepts mouse input
– If button enabled, depresses button
– If button depressed, releases button
– If active, puts button in rollover state
– If rolled over, removes rollover state
Presentation Abstraction
Control
44 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– Responsible for redrawing button
depressed/released, rolled over, redraws with appropriate animation, GIF image
Presentation Abstraction
Control
Question: Why doesn’t input part of Presentation simply handle redrawing?
45 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
browser, such as the display of the web page
List of pages visited Current page
page, sets current page to that page
46 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
P A
C
P A
C
P A
C
P A
C
Back Button Forward Button Web Page Navigation
47 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
pages, current page pointer
current page, enables back button
current page, enables forward button
manipulate current page
required
Presentation Abstraction
Control
48 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
P A
C
P A
C
P A
C
P A
C
Back Button Forward Button Web Page Navigation Current page Initial state: current page is end of queue, therefore “Forward” button is inactive. I.e., we have never clicked the back button
49 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
P A
C
P A
C
P A
C
P A
C
Back Button Forward Button Web Page Navigation Current page Final state: current page is moved back
page is displayed, and the forward button becomes enabled
50 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
P A
C
P A
C
P A
C
P A
C
Back Button Forward Button Web Page Navigation
mouse clicked down; C informs A that button depressed; C informs P that button should be redrawn; P redraws button
51 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
P A
C
P A
C
P A
C
P A
C
Back Button Forward Button Web Page Navigation
mouse released; C informs A that button released; C informs P that button should be redrawn; P redraws button; C informs Navigation that Back button has been clicked
52 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
P A
C
P A
C
P A
C
P A
C
Back Button Forward Button Web Page Navigation
C informs web page that new page needs to be drawn.
Lecture 8-3 Example: COM and the Object-oriented Architectural Style
54 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– Component Object Model – Used for building Microsoft’s large applications
– Variants
– Built on top of COM to allow document types to be combined
infrastructure
55 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– Object-Oriented Architecture Style – Interpreter Architecture Style – Layer Architecture Style – Event-Driven Architecture Style
56 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
57 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
58 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
59 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
60 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
components
– Document component holds the value of one document – Window component implements UI functionality of
– List component holds formatting information for a list in a document – Etc…
61 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
document to embed elements of spreadsheet documents
both Word and Excel components
62 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
COM DCOM OLE ActiveX
63 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
COM DCOM OLE ActiveX Mechanism for connecting together software components. Components have an interface (similar to methods). Applications are made up of a set of components, but components may be shared amongst more than one application. Components can be in different languages.
64 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
COM DCOM OLE ActiveX Like COM, but components don’t all have to be on the same machine.
65 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
COM DCOM OLE ActiveX Object Linking and Embedding: Simple mechanism for embedding documents of one type within
spreadsheet within a Word document, embed a spreadsheet managed by Excel.
66 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
COM DCOM OLE ActiveX Allows delivery of components
special tag indicates that the URL content is not an HTML page, but a COM component that is to be downloaded and
installation CD required.
67 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
COM DCOM OLE ActiveX
68 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
OO techniques
– Inheritance – Aggregation – Polymorphism
References:
69 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
For fun, try running this in MS Word - select Tools|Macro|Visual Basic Editor
70 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
71 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
72 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
An application contains a set of documents, which in turn contain many
characters (sentences, words) in the document, the currently selected range, the document’s styles, and many, many
74 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
A range represents a section of text over which editing operations can be performed. A range contains many properties, such as the set of characters/sentences/words in the range, the set of fonts used, the paragraph format, the set of errors returned by checking tools, and many more.
75 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– void insertBefore (String) -- inserts given string before the range – void cut ()-- copies the range to the clipboard, deletes the range – void sort (…) -- sorts the range according to given parameters – SpellingSuggestions getSpellingSuggestions (…) -- returns spelling suggestions for any misspelled words in the range – long delete (Unit, Count) -- deletes count number of unit items – …and dozens more…
76 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
languages
– E.g., C++, Java, C#, Visual Basic, …
the operating system and (with DCOM) on different machines
connectors
– What object do you call? – What format are parameters in? E.g., when passing a Visual Basic object as a parameter to a C++ COM object?
77 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– Language-independent points of service – Interfaces described in Interface Definition Language (IDL) – Language-dependent IDL translators transform method calls from native language to IDL format – IDL is very close to C++, so C++ translation is trivial
COM Component Interface
78 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
[object, uuid(E7CD0D00-1827-11CF-9946-444553540000) ] interface ISpellChecker : IUnknown { import “unknwn.idl”; HRESULT LookupWord([in] OLECHAR word[31], [out] boolean *found); HRESULT AddToDictionary([in] OLECHAR word[31]); HRESULT RemoveFromDictionary([in] OLECHAR word[31]); }
79 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
Calling Component Called Component IDL Specification IDL Translator
80 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
architectural style
– Components = objects – Connectors = call
elements of object-orientation
– Encapsulation – Inheritance – Polymorphism
81 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
blocks to describe OO architectures
– Class diagrams
components
– Object diagrams
are instantiated into objects
82 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
– Sequence diagrams
communicate with each other in real scenarios
– Use-Case diagrams
83 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323
architectures
– Can express not just structure but also dynamic information
level than architecture
– E.g. data structure information