Title: COMP2110 Software Design in 2004 lecture 10 Software Architecture 2 of 2 design lecture 5 of 6
1COMP2110 Software Design in 2004 lecture 10
Software Architecture 2 of 2 design
lecture 5 of 6
- Goal of this small course modulea descriptive
understanding(not detailed application of a big
library of examples). - Some existing software architectures
- batch and pipeline
- client-server and broker see the notes
- layers see the notes
2Software Architecture in general
- The decomposition of the design into groups of
abstract modules (clusters of classes) - modules are concepts, with names
- account management, playing field, characters
- potential for generality and reuse in other
projects - playing field, alarm control, selection list
- coherence and coupling
- stronger/more relationships between classes
inside the module boundarythan going in and out
through the boundary
3Elements of software architecture
- description of elements from which software
systems are built - interactions between those elements
- patterns that guide their composition
- constraints on those patterns
- In general, a system is defined in terms of
- a collection of components
- interactions between those components
4Existing software architectures (just a few)
- dataflow systems
- batch sequential
- pipes and filters
- call-and-return systems
- main program and subroutines
- hierarchical layers
- independent components
- communicating systems
- Model View Controller
example 1lex,parse,generate
notes 2 layers
notes 3 broker
example 2 MVC
5Example 1Lexical analysis, parsing,
identification (1)
- a widespread class of problems require processing
relatively complex sequences of character input
by - lexical analysis
- parsing
- identification of words (identifiers)
- examples
- programming languages for pretty print,
syntax-sensitive editing, compilation,
interpreting - HTML, XML for many kinds of further processing
rendering, editing
6scan parse identify batch architecture (2)
- Batch processing uses the schema
- divide the processing into a number of processing
stages that can be done in sequence. - process all of the input in a batch as a whole
through process 1, to produce a batch of
intermediate data stage 1 - process all of the intermediate data stage 1
through process 2... to produce a batch of
intermediate data stage 2 - in general
- process data stage i through process stage i1
to produce data stage i1
7batch architecture
input
data stage 3
data stage 1
data stage 2
process 2
process 3
process 1
abstract syntax tree
AST with tagged meanings
character sequence
token sequence
lexical scan
parse
identify
8Stage 1 lexical scan
output sequence of tokens
inputHTML source
STARTTAG "p ATTR "color ATTRVAL "black ATTR
"font ATTRVAL "Times DATA "This is it
STARTTAG "pre DATA " no more code! COMMENT "
but then... DATA " no more ENDTAG "pre DATA
"that was it ENDTAG "p"
ltp color"black font"TimesThis is it ltpregt no
more code!lt!-- but then... --gt no morelt/pregt
that was it lt/pgt
lexical analysis
9Stage 2 parse
input sequence of tokens
phrase structure(syntax tree)
STARTTAG "p ATTR "color ATTRVAL "black ATTR
"font ATTRVAL "Times DATA "This is it
STARTTAG "pre DATA " no more code! COMMENT "
but then... DATA " no more ENDTAG "pre DATA
"that was it ENDTAG "p"
ATTRVAL "black ATTR "color
ATTRVAL "Times ATTR "font ATTRIBSEQ 2
DATA "This is it DATA " no more code!
COMMENT " but then... DATA " no more
ELEMENT "pre" 3 DATA "that was it ELEMENT "p"
4
parse
(this is a syntax tree, in postfix
notationindentation added for human reader)
10Pipeline architecture
- in a pipeline, the processes produce the same
input and output as the batch processes but as
sequences, not as complete batchesThe processes
operate incrementally later processes can start
before the earlier ones have finished. - the batch architecture is a limiting case of the
pipeline
11pipeline architecture
input
data stage 3
data stage 1
data stage 2
process 2
process 3
process 1
abstract syntax tree
AST with tagged meanings
character sequence
token sequence
lexical scan
parse
identify
12pipeline ctd
- the processes are not always in lock step
- the scanner will need to consume a variable
number of characters for each token - the parser may need to consume several tokens
before it can produce any parse tree - the architectures can be mixed e.g in WebView
- lexical scanner-gt parser
Pipeline - -gt renderer
Batch
13batch vs pipeline
- performance space (batch big) and time
- responsiveness pipeline has fast first output
- may need whole structure to apply variety of last
stage processes suggests batch at the last - may need overview across whole of input
- pipeline may be too complex to program
14batch vs pipeline
- performance space (batch big) and time
- responsiveness pipeline has fast first output
- may need whole structure to apply variety of last
stage processes suggests batch at the last - may need overview across whole of input
- pipeline may be too complex to program
15example 2Model-View-Controller Architecture
- Recall the example of a spreadsheet program
- Model - the core application part
- underlying data, functional core of application
- registers dependent views and controllers
- notifies views and controllers when data changes
- View - the graphical part of the interface
- creates its controllers
- displays information (about the model) to the
user - updates itself when notified that the model
changes - retrieves data (gets state) from the model
- Controller - the decision-making part
- accepts user inputs and other events
- translates events into service requests for the
modelor display requests for the view - (from comp2100 notes and JMT book)
16Using an existing architecture in a high-level
design
- How to document the use of an architecture in a
high level design - name the architectural model you use
- e.g. Model View Controller
- name which modules play which roles
- e.g. the Model is module CentralControlStates
- the View is module UserInterfaceManager
- the Controller is the ControlLogicManager module
- state any major differences from the architecture