Upload
audra-charles
View
228
Download
6
Tags:
Embed Size (px)
Citation preview
Software Architecture Software Architecture - 1- 1
April 19, 2023April 19, 2023
All Architectural PatternsAll Architectural Patterns Data Flow ArchitectureData Flow Architecture
– Batch SequentialBatch Sequential– Pipe and FilterPipe and Filter– Process ControlProcess Control
Data Centered ArchitectureData Centered Architecture– RepositoryRepository– BlackboardBlackboard
Hierarchical ArchitectureHierarchical Architecture– Main-subroutineMain-subroutine– Master-slaveMaster-slave– LayeredLayered– Virtual MachinesVirtual Machines
All Architectural PatternsAll Architectural Patterns Implicit Asynchronous Communication Implicit Asynchronous Communication
ArchitectureArchitecture– Non-buffered event-based Implicit InvocationNon-buffered event-based Implicit Invocation– Buffered messaged-basedBuffered messaged-based
Interaction-Oriented ArchitectureInteraction-Oriented Architecture– Model-View-Controller (MVC)Model-View-Controller (MVC)– Presentation-Abstraction-Control (PAC)Presentation-Abstraction-Control (PAC)
Distributed ArchitectureDistributed Architecture– Client-serverClient-server– Broker Broker – Service-oriented architecture (SOA)Service-oriented architecture (SOA)
Component-based ArchitectureComponent-based Architecture
Architectural Patterns - 1Architectural Patterns - 1 Data Flow ArchitectureData Flow Architecture
– Batch SequentialBatch Sequential– Pipe and FilterPipe and Filter– Process ControlProcess Control
Data Centered ArchitectureData Centered Architecture– RepositoryRepository– BlackboardBlackboard
Hierarchical ArchitectureHierarchical Architecture– Main-subroutineMain-subroutine– Master-slaveMaster-slave– LayeredLayered– Virtual MachinesVirtual Machines
Data-Flow ArchitectureData-Flow Architecture OverviewOverview
– A series of transformation on successive sets of dataA series of transformation on successive sets of data– Data sets and operations are independent of each Data sets and operations are independent of each
other. other. Three subcategoriesThree subcategories
– Batch SequentialBatch Sequential– Pipe and FilterPipe and Filter– Process Control Process Control
Batch SequentialBatch Sequential OverviewOverview
– A transformation subsystem or module cannot start its A transformation subsystem or module cannot start its process until the previous module completes its process until the previous module completes its computationcomputation
– Data flow carries a batch of data as a whole from a Data flow carries a batch of data as a whole from a module to nextmodule to next
– series of transformation on successive sets of dataseries of transformation on successive sets of data– Data sets and operations are independent of each Data sets and operations are independent of each
other. other. ApplicationsApplications
– Business data processing in banking and utility billingBusiness data processing in banking and utility billing
Batch SequentialBatch Sequential
Validate Sort Update Report
data transformation
Data flow
Batch SequentialBatch Sequential
222 U 111 I 333 D -123 U
Validate
222 U 111 I 333 D
sort
111 I 222 U 333 D
Update100 ----111 ----200 ----222 ----444 ----
100 ---200 ---222 ---333 ---444 ---
Generate Report
Sortedtransaction
Validated transaction
Updated Master file
Rejected transaction
-123 U
Master file
Reports
Transaction File
Batch SequentialBatch Sequential
Using Unix Shell ScriptUsing Unix Shell Script(exec) validate trans validTrans invalids(exec) validate trans validTrans invalids
(exec) sort validTrans sortedTrans(exec) sort validTrans sortedTrans
(exec) update master sortedTrans(exec) update master sortedTrans
(exec) generateReports master report1 report2 (exec) generateReports master report1 report2
Batch SequentialBatch Sequential Applicable DomainsApplicable Domains
– Data are batchedData are batched– Intermediate files are sequential filesIntermediate files are sequential files– Each module reads input files and writes output files Each module reads input files and writes output files
BenefitsBenefits– Simple division on subsystemsSimple division on subsystems– Each subsystem can be stand-alone programEach subsystem can be stand-alone program
LimitationsLimitations– Implementation requires external controlImplementation requires external control– No interactive interfaceNo interactive interface– Concurrency not supportedConcurrency not supported
Pipe and FilterPipe and Filter OverviewOverview
– A system consists of data source, filters, pipes, and A system consists of data source, filters, pipes, and data sinksdata sinks
– Connections between components are data streamsConnections between components are data streams– Each data stream is a first-in-first-out bufferEach data stream is a first-in-first-out buffer– Each filter reads data from its input stream, processes Each filter reads data from its input stream, processes
it, and writes it over a pipe for next filter to process it, and writes it over a pipe for next filter to process – A filter processes data once received, does not wait A filter processes data once received, does not wait
until the whole data is receiveduntil the whole data is received– A filter only knows its connected pipes, does not know A filter only knows its connected pipes, does not know
what are at the other end of the pipewhat are at the other end of the pipe– Filters are independent of each otherFilters are independent of each other– Pipes and filters may run concurrently Pipes and filters may run concurrently
Pipe and FilterPipe and Filter Active filterActive filter
– Pulls in (read) data from upstream and pushes out Pulls in (read) data from upstream and pushes out (write) data to downstream(write) data to downstream
Passive filterPassive filter– It lets connected upstream pipes push (write) data to it It lets connected upstream pipes push (write) data to it
and lets downstream pipes to pull (read) data from itand lets downstream pipes to pull (read) data from it
Pipe and FilterPipe and Filter
data source:Data Source
filter1:Filter
pipe:pipe
filter2:Filter
data sink:Data Sink
R
write
W
read
Filter1
Data Source Filter1 Filter2 Data Sink
pipe
Filter2
Pipe and FilterPipe and Filter
H 1L 2
HL LO WUpper caseConversionFilter
orldMatch (H,L)Filter
Hello World
Sort & Count Filter
Pipe and FilterPipe and Filter
Pipe and FilterPipe and Filter Applicable DomainsApplicable Domains
– System can be broken into a series of steps over data System can be broken into a series of steps over data streamsstreams
– Data format in the streams is simple, stable and Data format in the streams is simple, stable and adaptableadaptable
– Significant amount can be pipelined for performanceSignificant amount can be pipelined for performance BenefitsBenefits
– Concurrency: all filters may operate at the same timeConcurrency: all filters may operate at the same time– Reusability: filters are easy to plug and playReusability: filters are easy to plug and play
LimitationsLimitations– No user interactionNo user interaction– Difficult to configure Difficult to configure – Concurrency not supportedConcurrency not supported
Data-Centered Data-Centered Architecture Architecture OverviewOverview
– A centralized data store is shared by all A centralized data store is shared by all surrounding software componentssurrounding software components
– The surrounding components are normally The surrounding components are normally independent each otherindependent each other
– Significant amount can be pipelined for Significant amount can be pipelined for performanceperformance
Two categories:Two categories:– RepositoryRepository– BlackboardBlackboard
RepositoryRepository OverviewOverview
– Data store is passiveData store is passive– Clients of the data store are activeClients of the data store are active– Supports interactive data processing Supports interactive data processing – Clients control the computation and flow of Clients control the computation and flow of
logiclogic
RepositoryRepository
RepositoryRepository
RepositoryRepository
RepositoryRepository ApplicationsApplications
– Suitable for large complex information systems where Suitable for large complex information systems where many software component clients need to access it in many software component clients need to access it in different waysdifferent ways..
– Data transactions to drive the control flow of computation.Data transactions to drive the control flow of computation. Benefits:Benefits:
– Easy to backup and restoreEasy to backup and restore..– Easy to add new software componentsEasy to add new software components– Reduce the overhead of transient dataReduce the overhead of transient data
Limitations:Limitations:– Centralized repository is vulnerable to failure compared to Centralized repository is vulnerable to failure compared to
distributed repository with data replication.distributed repository with data replication.– High dependency between the structure of the data store High dependency between the structure of the data store
and its agents. and its agents.
BlackboardBlackboard OverviewOverview
– Data store is activeData store is active– Clients are passiveClients are passive– Clients are also called knowledge sources, Clients are also called knowledge sources,
listeners, and subscriberslisteners, and subscribers Two partitionsTwo partitions
– Blackboard: store data (hypotheses and facts)Blackboard: store data (hypotheses and facts)– Knowledge sources: domain-specific Knowledge sources: domain-specific
knowledge is storedknowledge is stored– Controller: initiate the blackboard and Controller: initiate the blackboard and
knowledge sources and take overall knowledge sources and take overall supervisionsupervision
BlackboardBlackboard CollaborationCollaboration
– Knowledge sources register with the Knowledge sources register with the blackboard in advance in a blackboard in advance in a publish/subscribe fashionpublish/subscribe fashion
– Data changes in the blackboard trigger Data changes in the blackboard trigger one or more matched knowledge sources one or more matched knowledge sources to continue processingto continue processing
– Data changes may be caused by new Data changes may be caused by new deduced information or hypothesis results deduced information or hypothesis results by knowledge sourcesby knowledge sources
– Knowledge sources normally do not Knowledge sources normally do not interact with each otherinteract with each other
BlackboardBlackboard
BlackboardBlackboard
Blackboard – example 1Blackboard – example 1
Animal identification System(KBS). Animal identification System(KBS). – The knowledge is represented as production The knowledge is represented as production
rules. rules. R1: IF animal gives milk THEN animal is mammalR1: IF animal gives milk THEN animal is mammalR2: IF animal eats meat THEN animal is carnivoreR2: IF animal eats meat THEN animal is carnivoreR3: R3: IF animal is mammal AND animal is carnivore AND IF animal is mammal AND animal is carnivore AND
animal has tawny color AND animal has black stripes animal has tawny color AND animal has black stripes THEN animal is tigerTHEN animal is tiger
– A set of facts A set of facts F1: animal eats meatF1: animal eats meatF2: animal gives milkF2: animal gives milkF3: animal has black stripesF3: animal has black stripesF4: animal has tawny colorF4: animal has tawny color
Blackboard – example 1Blackboard – example 1
Forward reasoning Forward reasoning – New knowledge is added to blackboard New knowledge is added to blackboard
N1: animal is carnivore (from R2 + F1)N1: animal is carnivore (from R2 + F1)N2: animal is mammal (from R1 + F2) IF animal gives milk N2: animal is mammal (from R1 + F2) IF animal gives milk
THEN animal is mammalTHEN animal is mammalN3: animal is tiger (R3 + N3 + N2 + F3 + F4)N3: animal is tiger (R3 + N3 + N2 + F3 + F4)
Blackboard – example 2Blackboard – example 2
Travel Consulting System Travel Consulting System – Participating agentsParticipating agents
Airline, hotel reservation, auto rental, and attraction Airline, hotel reservation, auto rental, and attraction agents agents
– BlackboardBlackboard Budget, available time, locations, etcBudget, available time, locations, etc
– Clients of the systemClients of the system Clients fill out a initial travel form Clients fill out a initial travel form The system will respond with many optional plans The system will respond with many optional plans
for client to choosefor client to choose
Blackboard – example 2Blackboard – example 2
Travel Consulting System Travel Consulting System – ProcessProcess
A client submits a requestA client submits a request The system stores all the data in the blackboardThe system stores all the data in the blackboard The blackboard makes a request to the air agentThe blackboard makes a request to the air agent Once air reservation data is returned and stored in Once air reservation data is returned and stored in
blackboard, the change triggers hotel, auto rental, blackboard, the change triggers hotel, auto rental, attraction agents for a travel plans under budge and attraction agents for a travel plans under budge and timetime
Client chooses one of the planClient chooses one of the plan The system triggers the billing processThe system triggers the billing process
BlackboardBlackboard ApplicationsApplications
– Suitable for open-ended and complex problems (AI)Suitable for open-ended and complex problems (AI)– The problem spans multiple disciplines, each of them The problem spans multiple disciplines, each of them
has complete different knowledge expertisehas complete different knowledge expertise– Partial, or approximate solution is acceptable to the Partial, or approximate solution is acceptable to the
problems.problems. Benefits:Benefits:
– Easy to add new or update existing knowledge source.Easy to add new or update existing knowledge source.– Concurrency: all knowledge sources can work in Concurrency: all knowledge sources can work in
parallelparallel– Reusability of knowledge source agents.Reusability of knowledge source agents.
BlackboardBlackboard Limitations:Limitations:
– Tight dependency between the blackboard and Tight dependency between the blackboard and knowledge source,knowledge source,
– Difficult to make a decision when to terminate Difficult to make a decision when to terminate reasoning, since only partial or approximated solutions reasoning, since only partial or approximated solutions are expectedare expected
– Synchronization of multiple agents is an issue. Synchronization of multiple agents is an issue. – Debugging and testing of the system is a challenge. Debugging and testing of the system is a challenge.
Hierarchical ArchitectureHierarchical Architecture
OverviewOverview– The software system is decomposed into logical modules The software system is decomposed into logical modules
(sub-systems) at different levels in the hierarchy. (sub-systems) at different levels in the hierarchy. – Modules at different levels are connected by explicit or Modules at different levels are connected by explicit or
implicit method invocations. implicit method invocations. – A lower level module provides services to its adjacent A lower level module provides services to its adjacent
upper level modulesupper level modules– Upper level modules invoke the methods or procedures Upper level modules invoke the methods or procedures
in lower level. in lower level. Four categoriesFour categories
– Main-subroutineMain-subroutine– Master-slaveMaster-slave– LayeredLayered– Virtual MachinesVirtual Machines
Main-subroutineMain-subroutine OverviewOverview
– The main-subroutine architecture has dominated The main-subroutine architecture has dominated the software design methodologies for a very long the software design methodologies for a very long time. time.
– Reuse the subroutines and have individual Reuse the subroutines and have individual subroutines developed independently. subroutines developed independently.
– Using this style, a software system is decomposed Using this style, a software system is decomposed into subroutines hierarchically refined according to into subroutines hierarchically refined according to the desired functionality of the system. the desired functionality of the system.
– Refinements are conducted vertically until the Refinements are conducted vertically until the decomposed subroutine is simple enough to have decomposed subroutine is simple enough to have its sole independent responsibility, and whose its sole independent responsibility, and whose functionality may be reused and shared by functionality may be reused and shared by multiple callers above.multiple callers above.
Main-subroutineMain-subroutine
Main-subroutineMain-subroutine
Data Flow Diagram to Main-subroutineData Flow Diagram to Main-subroutine– Transform flow: incoming flow feeds data in Transform flow: incoming flow feeds data in
an external format, and the data is then an external format, and the data is then transformed to another format, and then the transformed to another format, and then the outgoing flow carries the data outoutgoing flow carries the data out
– Transaction flow: evaluates its incoming data, Transaction flow: evaluates its incoming data, and decided which path to follow among and decided which path to follow among many action paths.many action paths.
– A transform flow is mapped by a controlling A transform flow is mapped by a controlling module for incoming, transform and outgoing module for incoming, transform and outgoing information processing.information processing.
– The transaction node becomes a dispatcher The transaction node becomes a dispatcher control module that controls all subordinate control module that controls all subordinate action modulesaction modules
Main-subroutineMain-subroutine
Main-subroutineMain-subroutine
Applicable DomainsApplicable Domains– Data are batchedData are batched– Intermediate files are sequential filesIntermediate files are sequential files– Each module reads input files and writes output files Each module reads input files and writes output files
BenefitsBenefits– Easy to decompose the system based on the definition Easy to decompose the system based on the definition
of the tasks in a top-down refinement manner of the tasks in a top-down refinement manner LimitationsLimitations
– Globally shared data in classical main-subroutines Globally shared data in classical main-subroutines introduces vulnerabilities.introduces vulnerabilities.
– Tight coupling may cause more ripple effects of Tight coupling may cause more ripple effects of changes as compared to OO Design.changes as compared to OO Design.
Master-slaveMaster-slave
OverviewOverview– A variant of the main-subroutine architecture style that A variant of the main-subroutine architecture style that
supports fault tolerance and system reliability. supports fault tolerance and system reliability. – Slaves provide replicated services to the master, and Slaves provide replicated services to the master, and
the master selects a particular result among slaves by the master selects a particular result among slaves by certain selection strategy. certain selection strategy.
– The slaves may perform the same functional task by The slaves may perform the same functional task by different algorithms and methods or totally different different algorithms and methods or totally different functionality.functionality.
Master-slaveMaster-slave
Master-slaveMaster-slave
Applicable DomainsApplicable Domains– Software systems where reliability is critical.Software systems where reliability is critical.
Layered ArchitectureLayered Architecture OverviewOverview
– The system is decomposed into a number of higher The system is decomposed into a number of higher and lower layers in a hierarchyand lower layers in a hierarchy
– Each layer consists of a group of related classes Each layer consists of a group of related classes that are encapsulated in package, in a deployed that are encapsulated in package, in a deployed component, or as a group of subroutines in the component, or as a group of subroutines in the format of method library or header file. format of method library or header file.
– Also, each layer has its own sole responsibility in Also, each layer has its own sole responsibility in the system.the system.
– A request to layer i +1 invokes the services A request to layer i +1 invokes the services provided by the layer i via the interface of layer i. provided by the layer i via the interface of layer i.
– The response may go back to the layer i +1 if the The response may go back to the layer i +1 if the task is completed; otherwise layer i continually task is completed; otherwise layer i continually invokes services from the layer i -1 below. invokes services from the layer i -1 below.
Layered ArchitectureLayered Architecture
Layered ArchitectureLayered Architecture
Layered ArchitectureLayered Architecture
FTP
TCP
IP
Ethernet
FTP
TCP
IP
Ethernet
TCP protocol
IP protocol
Physical connection
Ethernet protocol
FTP protocol
Layered ArchitectureLayered Architecture
Layered ArchitectureLayered Architecture Applicable DomainsApplicable Domains
– Any system that can be divided between the application specific Any system that can be divided between the application specific portions and platform specific portions .portions and platform specific portions .
– Applications that have clean divisions between core services, Applications that have clean divisions between core services, critical services, user interface services, etc.critical services, user interface services, etc.
BenefitsBenefits– Incremental development based on levels of abstraction.Incremental development based on levels of abstraction.– Enhanced independence of upper layer to lower layer as long as Enhanced independence of upper layer to lower layer as long as
their interfaces remain unchanged. their interfaces remain unchanged. – separation of the standard interface and its implementation.separation of the standard interface and its implementation.– Component-based technology may be used to implement the Component-based technology may be used to implement the
layered architecture; this makes the system much easier to allow layered architecture; this makes the system much easier to allow for plug-and-play of new components.for plug-and-play of new components.
– Promotion of portability: each layer can be an abstract machine Promotion of portability: each layer can be an abstract machine deployed independently. deployed independently.
– Easy to decompose the system based on the definition of the tasks Easy to decompose the system based on the definition of the tasks in a top-down refinement manner in a top-down refinement manner
Layered ArchitectureLayered Architecture
LimitationsLimitations– Lower runtime performance since a client’s request or Lower runtime performance since a client’s request or
a response to client must go through potentially a response to client must go through potentially several layers. There are also performance concerns several layers. There are also performance concerns on overhead on the data marshaling and buffering by on overhead on the data marshaling and buffering by each layer.each layer.
– Many applications cannot fit this architectural design.Many applications cannot fit this architectural design.– Breach of interlayer communication may cause Breach of interlayer communication may cause
deadlocks and “bridging” may cause tight coupling.deadlocks and “bridging” may cause tight coupling.– Exceptions and error handling is an issue in the layered Exceptions and error handling is an issue in the layered
architecture, since faults in one layer must propagate architecture, since faults in one layer must propagate upwards to all calling layers. upwards to all calling layers.
Virtual MachineVirtual Machine
OverviewOverview– A virtual machine is built up on an existing A virtual machine is built up on an existing
system and provides a virtual abstraction, a system and provides a virtual abstraction, a set of attributes, and operations. set of attributes, and operations.
– In most cases, we find that a virtual machine In most cases, we find that a virtual machine separates a programming language or separates a programming language or application environment from a execution application environment from a execution platform. platform.
– Some people say that a virtual machine looks Some people say that a virtual machine looks like emulation software. like emulation software.
Virtual MachineVirtual Machine
Virtual MachineVirtual Machine
Virtual MachineVirtual Machine Applicable DomainsApplicable Domains
– Suitable for solving a problem by simulation or translation Suitable for solving a problem by simulation or translation if there is no direct solution.if there is no direct solution.
– Sample applications include interpreters of Sample applications include interpreters of microprogramming, XML processing, script command microprogramming, XML processing, script command language execution, rule-based system execution, language execution, rule-based system execution, Smalltalk and Java interpreter typed programming Smalltalk and Java interpreter typed programming languagelanguage
BenefitsBenefits– Portability and machine platform independency.Portability and machine platform independency.– Simplicity of software development.Simplicity of software development.– Simulation for disaster working model.Simulation for disaster working model.
LimitationsLimitations– Slow execution of the interpreter due to the interpreter Slow execution of the interpreter due to the interpreter
nature.nature.– Additional overhead due to the new layer.Additional overhead due to the new layer.