CISC 323 Intro to Software Engineering Week 8: Software - - PowerPoint PPT Presentation

cisc 323 intro to software engineering
SMART_READER_LITE
LIVE PREVIEW

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]


slide-1
SLIDE 1

CISC 323 Intro to Software Engineering

Week 8: Software Architecture (Continued)

slide-2
SLIDE 2

CISC 323 Intro to Software Engineering

Lecture 8-1 Data-Centered and Interpreter Architectural Styles

slide-3
SLIDE 3

3 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Architectural Style Examples

[Shaw&Garlan]

  • Pipes and Filters
  • Layers
  • Event-Based
  • Data-Centered
  • Interpreter
  • PAC
slide-4
SLIDE 4

4 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Data-Centered Architecture Style

  • Repository

– Allows data to be allowing shared amongst a set

  • f components
  • Blackboard

– Active repository cooperative, distributed decision making

slide-5
SLIDE 5

5 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Repository

  • Set of components

share data

  • E.g., database or data

structure shared by multiple components

  • Connectors permit

components to read/write to repository

Repository

slide-6
SLIDE 6

Example

  • Compiler based on pipes and filter

architecture style

  • Parse tree is complex data structure

passed between phases

  • Needs to be converted into a stream

that can be passed over a pipe --

  • verhead
  • Use repository to represent abstract

syntax tree

Scanner Parser Semantic Analyzer Code Generator

program text executable code tokens parse tree parse tree

slide-7
SLIDE 7

7 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Compiling as Pipe and Filter Architecture Augmented with Repository

Scanner Parser Semantic Analyzer Code Generator

program text executable code tokens control control

Repository: Parse Tree

Control information passed between phases rather than parse tree

slide-8
SLIDE 8

8 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Properties of Repository Architecture Style

  • Performance

– For complex data structures, saves overhead

  • f passing data structure

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

slide-9
SLIDE 9

9 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Properties of Repository Architecture Style

  • Performance

– 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

slide-10
SLIDE 10

10 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Properties of Repository Architecture Style

  • Performance

– 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

  • f scope of this course

Repository c1 c2 c3

slide-11
SLIDE 11

11 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Properties of Repository Architecture Style

  • Development Time

– Numerous infrastructures for repositories already exist -- e.g.

  • Commercial databases
  • Java Remote Method

Invocation (RMI)

– Need to balance savings in development time vs need to learn infrastructures

Repository c1 c2 c3

slide-12
SLIDE 12

12 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Properties of Repository Architecture Style

  • Security

– 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

slide-13
SLIDE 13

13 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Properties of Repository Architecture Style

  • Availability

– Repository becomes critical component in system – Failure in repository causes entire system to fail

Repository c1 c2 c3

slide-14
SLIDE 14

14 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Blackboard Architecture Style

  • Variant of repository
  • Repository is active

– Can activate components in response to changes in blackboard contents

  • Typical application

– Use blackboard to mediate cooperative activity amongst components – Tasks where desired

  • utcome is imprecisely

defined or error prone

Blackboard c1 c2 c3 Update/request information from repository Activate components as new information becomes available

slide-15
SLIDE 15

HTTP Server

(e.g. Apache)

HTTP Client

(e.g., Netscape, Internet Explorer)

Order System Inventory Catalogue

Requests for book info, delivery times, orders, etc. HTML document Requests for book info Requests for delivery time Order placement Request availability

Recall example of

  • nline book ordering

system...

slide-16
SLIDE 16

16 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Example: Inventory System using the Blackboard Architecture

  • Inventory blackboard used to

coordinate filling orders

  • Order system initiates orders
  • Receiver records new stock as it

arrives

  • Shipper sends order to be

packaged

  • All communication via inventory

Order System Inventory

Request availability

Receiver Shipper

Record new stock Record stock shipped Inform

  • rder filled

Initiate shipping Order stock

slide-17
SLIDE 17

17 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Example: Smart office

  • Tracking who is in the office

– Using: Active badges, voice recognition, cameras – Allows

  • Ease of finding colleagues
  • User authentication (no need to have door keys, logins at

machines)

  • People’s environments to follow them

– Sitting down at someone else’s PC is just like sitting down at your own

  • Smart commands

– Use gestures/voice to

  • Turn on projector, connect to PC
  • Record contents of whiteboard save them under my username

– Combine modalities

  • Say “Save *this* on my laptop”, while pointing at whiteboard
slide-18
SLIDE 18

18 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Example: Smart office

  • Application depends on combining a set of

physical devices

– Cameras, microphones, door switches

  • and a set of services

– Voice recognition speech recognition, gesture recognition

  • and a set of models

– Who is in room, what command are they executing

slide-19
SLIDE 19

Microphone Camera1 Cameran

  • Active Badge

Reader Voice samples Badge data Camera inputs People detector Model: people in room Command detector Model: command

slide-20
SLIDE 20

20 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Interesting scenarios

  • Person enters room, but their active badge is malfunctioning
  • When they first speak, voice recognition detects their presence
slide-21
SLIDE 21

21 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Architectural Style Examples

[Shaw&Garlan]

  • Pipes and Filters
  • Layers
  • Event-Based
  • Data-Centered
  • Interpreter
  • PAC
slide-22
SLIDE 22

22 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Interpreter Architecture Style

  • Develop domain-specific language for problem area
  • Express solution in terms of this language
  • Include interpreter in system to evaluate the solution
  • Motivation

– Providing higher level language for problem domain simplifies programming problem – Examples

  • XML parsers
  • Extensible interpreters such as JVM, tcl
  • Rule-based/expert systems
slide-23
SLIDE 23

23 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Interpreter Architecture [Shaw&Garlan p. 27]

Program state Program being interpreted Simulated Interpretation Engine Internal Interpreter State inputs

  • utputs

selected instruction selected data program code

slide-24
SLIDE 24

24 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

E.g., Interpreting Java Programs

Program state Java class files Java Virtual Machine (JVM) JVM State inputs

  • utputs

selected instruction selected data program code

slide-25
SLIDE 25

25 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Interpreting Java Programs

  • Java programs are

represented as a set of class files

– Contain byte code describing operations on the Java Virtual Machine

  • These programs are

executed as if they were being run on a native machine

  • Program state is actually

represented in JVM Program state Java class files Java Virtual Machine (JVM) JVM State inputs

  • utputs

selected instruction selected data program code

slide-26
SLIDE 26

26 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Example: Processing XML

  • XML (eXtensible Markup Language) is a way of encoding

structured data for

– Archiving – Interchanging between applications – Sending over the Internet

  • (e.g. e-commerce business-to-business applications)
  • XML processing is implemented via the interpreter architecture

style

See e.g. http://www.xml101.com:8081/xml/

slide-27
SLIDE 27

XML

  • XML documents consist of tagged text
  • Tags indicate semantics of data
  • Tags may be arbitrary

– 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>

slide-28
SLIDE 28

28 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

XML DTD’s

  • A DTD (Document Type Definition) describes legal use of tags in a

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

slide-29
SLIDE 29

29 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

DTD’s specify

  • What tags are legal
  • How tags are combined

– 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>

slide-30
SLIDE 30

30 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Using XML in a System for Ordering Books

Component for converting book

  • rders from XML to

Java classes Book order as Java class Book order as XML document

slide-31
SLIDE 31

31 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Using XML in a System for Ordering Books

Books DTD XML Processor DTD Book order as Java class Book order as XML document Component for converting book

  • rders from XML

to Java classes

slide-32
SLIDE 32

32 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Using XML in a System for Ordering Books

Books DTD XML Processor Book order Web Browser (XML document) Order Processor DTD Books data structure XML Order Other components…

slide-33
SLIDE 33

33 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

XML Processor for Ordering Books

  • XML Processor is an interpreter for DTD’s
  • When given the Books DTD, becomes a component

capable of processing book orders

  • Advantages

– Can reuse XML processor in many contexts – If format of book orders change, just need to change DTD, not code

slide-34
SLIDE 34

34 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Attributes of Interpreter Style

  • Development Time

– Tremendous potential for reuse

  • Performance

– Interpretation may be slower than hand-coded solutions

  • Modifiability

– Can be improved by restricting modification to data being interpreted

slide-35
SLIDE 35

CISC 323 Intro to Software Engineering

Lecture 8-2 PAC Architectural Style

slide-36
SLIDE 36

36 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Architectural Style Examples

[Shaw&Garlan]

  • Pipes and Filters
  • Layers
  • Event-Based
  • Data-Centered
  • Interpreter
  • PAC
slide-37
SLIDE 37

37 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

The PAC Architecture Style

  • Supporting development of user interfaces
  • Conceptual architecture that can be mapped to

multiple concrete architectures

  • Agent-based

– Program decomposed into a set of agents, each responsible for some part of the task of interacting with the user

slide-38
SLIDE 38

38 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Example: PAC Architecture for a Set of Buttons

  • Assume an interface has a set of buttons

controlling navigation

– “Back” means return to previous page in history, “Forward” means go forward to last page we moved back from (if there is

  • ne)

Button

List of pages visited Current page

  • “Back” decrements current page counter
  • “Forward” increments current page counter
  • If current page is front of list, “Back” button is disabled
  • If current page is end of list, “Forward button is disabled
  • Going to a new page enqueues that page after the current

page, sets current page to that page

slide-39
SLIDE 39

39 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Starting with Just a Button...

  • Buttons have

– A label (e.g. “Back”, “Forward”) – A state (disabled, enabled)

  • Buttons have local behaviour

– “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

slide-40
SLIDE 40

40 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Button Abstraction

  • A button’s state is therefore

– Label (String value) – Is Enabled? (Boolean value) – Is “rolled over”? (Boolean value) – Is depressed? (Boolean value)

  • Therefore, the state of a button is captured in three Boolean

values and a string value

  • In PAC, this state is called the button’s Abstraction
slide-41
SLIDE 41

41 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

PAC Components

  • PAC architectures

constructed from a set of components

  • Each component

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

  • ther PAC components
  • ther PAC components

Inter-facet communication, typically event or method call

slide-42
SLIDE 42

42 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

PAC Button

  • Abstraction

– Java object containing methods to set/get

  • Button label
  • Enabled/disabled state
  • Rolled-over state
  • Depressed/released state

Presentation Abstraction

Control

  • ther PAC components
  • ther PAC components
slide-43
SLIDE 43

43 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

PAC Button

  • Presentation

– Accepts mouse input

  • mouse down

– If button enabled, depresses button

  • mouse up

– If button depressed, releases button

  • mouse enter

– If active, puts button in rollover state

  • mouse leave

– If rolled over, removes rollover state

Presentation Abstraction

Control

  • ther PAC components
  • ther PAC components
slide-44
SLIDE 44

44 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

PAC Button

  • Presentation

– Responsible for redrawing button

  • When changes in enabling,

depressed/released, rolled over, redraws with appropriate animation, GIF image

Presentation Abstraction

Control

  • ther PAC components
  • ther PAC components

Question: Why doesn’t input part of Presentation simply handle redrawing?

slide-45
SLIDE 45

45 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Building an Architecture with PAC Components

  • Require a PAC component for each button
  • Require a component for navigation
  • Require components for the rest of the

browser, such as the display of the web page

Button

List of pages visited Current page

  • “Back” decrements current page counter
  • “Forward” increments current page counter
  • If current page is front of list, “Back” button is disabled
  • If current page is end of list, “Forward button is disabled
  • Going to a new page enqueues that page after the current

page, sets current page to that page

slide-46
SLIDE 46

46 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

PAC Architecture

P A

C

P A

C

P A

C

P A

C

Back Button Forward Button Web Page Navigation

slide-47
SLIDE 47

47 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Navigation Component

  • Abstraction contains queue of

pages, current page pointer

  • If there are pages before

current page, enables back button

  • If there are pages after

current page, enables forward button

  • Actions from buttons

manipulate current page

  • No Presentation facet

required

Presentation Abstraction

Control

  • ther PAC components
slide-48
SLIDE 48

48 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Scenario: Go Back One Page

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

slide-49
SLIDE 49

49 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Scenario: Go Back One Page

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

  • ne position in the queue; the new web

page is displayed, and the forward button becomes enabled

slide-50
SLIDE 50

50 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Scenario: Go Back One Page

P A

C

P A

C

P A

C

P A

C

Back Button Forward Button Web Page Navigation

  • 1. User clicks mouse down; P informs C that

mouse clicked down; C informs A that button depressed; C informs P that button should be redrawn; P redraws button

slide-51
SLIDE 51

51 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Scenario: Go Back One Page

P A

C

P A

C

P A

C

P A

C

Back Button Forward Button Web Page Navigation

  • 2. User releases mouse; P informs C that

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

slide-52
SLIDE 52

52 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Scenario: Go Back One Page

P A

C

P A

C

P A

C

P A

C

Back Button Forward Button Web Page Navigation

  • 3. C informs A that current page moved back
  • ne. C informs forward button that it is enabled.

C informs web page that new page needs to be drawn.

slide-53
SLIDE 53

CISC 323 Intro to Software Engineering

Lecture 8-3 Example: COM and the Object-oriented Architectural Style

slide-54
SLIDE 54

54 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Case Study

  • Microsoft’s COM architecture

– Component Object Model – Used for building Microsoft’s large applications

  • Word, Excel, PowerPoint, …

– Variants

  • DCOM (distributed version)
  • OLE (Object Linking and Embedding)

– Built on top of COM to allow document types to be combined

  • ActiveX (Web version)
  • .NET – replaces DCOM and some of the higher-level

infrastructure

slide-55
SLIDE 55

55 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Microsoft OLE

  • Combines

– Object-Oriented Architecture Style – Interpreter Architecture Style – Layer Architecture Style – Event-Driven Architecture Style

slide-56
SLIDE 56

56 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Motivation: Object Embedding

slide-57
SLIDE 57

57 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Motivation: Object Embedding

slide-58
SLIDE 58

58 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Motivation: Object Embedding

slide-59
SLIDE 59

59 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Motivation: Object Embedding

slide-60
SLIDE 60

60 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

What’s Actually Going On...

  • Microsoft applications are made up of a set of

components

  • E.g., in Word

– Document component holds the value of one document – Window component implements UI functionality of

  • ne window

– List component holds formatting information for a list in a document – Etc…

slide-61
SLIDE 61

61 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

What’s Really Going On...

  • Similarly, Excel spreadsheet documents are made up
  • f a number of components
  • COM (Component Object Model) allows our Word

document to embed elements of spreadsheet documents

  • Therefore create a compound document involving

both Word and Excel components

slide-62
SLIDE 62

62 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

COM as a Layered System

(Idealized View)

COM DCOM OLE ActiveX

slide-63
SLIDE 63

63 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

COM as a Layered System

(Idealized View)

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.

slide-64
SLIDE 64

64 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

COM as a Layered System

(Idealized View)

COM DCOM OLE ActiveX Like COM, but components don’t all have to be on the same machine.

slide-65
SLIDE 65

65 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

COM as a Layered System

(Idealized View)

COM DCOM OLE ActiveX Object Linking and Embedding: Simple mechanism for embedding documents of one type within

  • another. E.g., if you want a

spreadsheet within a Word document, embed a spreadsheet managed by Excel.

slide-66
SLIDE 66

66 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

COM as a Layered System

(Idealized View)

COM DCOM OLE ActiveX Allows delivery of components

  • ver the web. In web browser,

special tag indicates that the URL content is not an HTML page, but a COM component that is to be downloaded and

  • executed. Simplifies delivery
  • f programs, since no

installation CD required.

slide-67
SLIDE 67

67 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

COM as a Layered System

(Slightly more accurate view)

COM DCOM OLE ActiveX

slide-68
SLIDE 68

68 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

COM as an OO System

  • Applications are built as a set of COM components
  • These components are constructed using standard

OO techniques

– Inheritance – Aggregation – Polymorphism

References:

  • D. Mackenzie, Word 2000 VBA, WROX Press, 1999
  • D. Chappell, Understanding ActiveX and OLE, Microsoft Press, 1996
slide-69
SLIDE 69

69 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

A Visual Basic COM (OLE) Program

For fun, try running this in MS Word - select Tools|Macro|Visual Basic Editor

slide-70
SLIDE 70

70 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Result of Running the Program within MS Word

slide-71
SLIDE 71

71 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

A Visual Basic COM (OLE) Program

slide-72
SLIDE 72

72 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Result of Running the Program within MS Word

slide-73
SLIDE 73

An application contains a set of documents, which in turn contain many

  • ther objects. Examples include the set of

characters (sentences, words) in the document, the currently selected range, the document’s styles, and many, many

  • thers.

OO Design of MS Word

slide-74
SLIDE 74

74 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

OO Design

  • f MS Word

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.

slide-75
SLIDE 75

75 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Example Operations

  • Range

– 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…

slide-76
SLIDE 76

76 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Connectors in COM

  • COM components can be created in many different

languages

– E.g., C++, Java, C#, Visual Basic, …

  • Components can reside in different applications, in

the operating system and (with DCOM) on different machines

  • Connectors therefore are not simple method call

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?

slide-77
SLIDE 77

77 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Connecting COM Components

  • Components provide interfaces

– 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

slide-78
SLIDE 78

78 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Example IDL Specification

[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]); }

slide-79
SLIDE 79

79 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Connecting COM Components

Calling Component Called Component IDL Specification IDL Translator

slide-80
SLIDE 80

80 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

The Object-Oriented Architectural Style

  • Object-orientation can be seen as an

architectural style

– Components = objects – Connectors = call

  • We have already seen the fundamental

elements of object-orientation

– Encapsulation – Inheritance – Polymorphism

slide-81
SLIDE 81

81 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

The Object-Oriented Architectural Style

  • Unified Modeling Language (UML) provides building

blocks to describe OO architectures

– Class diagrams

  • Define types of components, relationships between

components

– Object diagrams

  • Define runtime structure of architecture, showing how classes

are instantiated into objects

slide-82
SLIDE 82

82 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

The Object-Oriented Architectural Style

– Sequence diagrams

  • Shows timeline of how components

communicate with each other in real scenarios

– Use-Case diagrams

  • Show how users interact with system
slide-83
SLIDE 83

83 Queen’s University, CISC 323 http://www.cs.queensu.ca/~cisc323

Relation Between OO Design and Software Architecture

  • Software architecture describes the high-level structure
  • f a system in terms of components and connectors
  • OO Design (e.g. using UML) can express software

architectures

– Can express not just structure but also dynamic information

  • OO Design can also express information at a much lower

level than architecture

– E.g. data structure information