CH 6 Architecture
CH 6 Architecture
Outline:
• Definitions
• Models
Architectural Design
• Architectural Patterns
! 1. MVC: Model-View-Controller
! 2. Layered (or tiered)
Chapter 6 3. Pipe and Filter
4. Repository
5. Client-Server
!1 !2
!3 !4
Services and subsystem interfaces Architectural Models
• A service is a set of related operations that share
• Simple box and line diagrams
a common purpose.
• Subsystem interface: the set of one subsystems’
• Each box is a component of the system (a
subsystem)
operations that are available to other subsystems.
- specification includes the signature of each operation: • Boxes within boxes are subcomponents of a
name of the operation, types of each parameter. subsystem
• Why specify interfaces to components? • Arrows indicate data and/or messages are passed
- so components may be developed in parallel between components
• Helps promote independence (separation).
- can make changes behind the interface without affecting
components using that interface.
!5 !6
Example: Architecture of a
packing robot control system Architectural Patterns
The robot uses the vision Vision • An architectural pattern is an abstract description of
system to pick out
system
system organization that has been successful in
objects on a conveyor,
identify the type of object,
previous projects (in various contexts)
Object Arm Gripper
and select the right kind
of packaging. It packs the
identification
system
controller controller
• Patterns are a means of representing, sharing and
object, and places it on reusing knowledge.
another conveyor.
- Architectural designers can browse pattern descriptions to
Packaging
selection identify potential candidates for their project
system
•
Conveyor
system controller Design goals: simplicity (reduce complexity) and
independence (reduce dependence).
!7 !8
1. Model-View-Controller Model-View-Controller (MVC)
(MVC) Pattern Pattern Diagram
• Commonly used in desktop, mobile phone, and
web applications. Controller View
selection
View
• Used to separate the data (the model) from the to model updates
Selects view
User events
Requests model updates
Sends user events to
Change
•
(set values Model
View objects present data to and receive actions in model)
Encapsulates application
from model)
!9 !10
Model-View-Controller (MVC)
2. Layered Architecture Pattern
Pattern Description
Name MVC (Model-View-Controller)
• System functionality is organized into
Description Separates presentation and interaction from the system data. The system
is structured into three logical components that interact with each other. ! separate layers.
• Model component manages the system data and associated operations
on that data. !
• View component defines and manages how the data is presented to the • Each layer relies only on facilities and
user. !
• Controller component manages user interaction (e.g., key presses,
services of layer immediately beneath it.
•
mouse clicks, etc.) and passes these interactions to the View and the
Model. Advantages:
Example Most web-based application systems, most desktop apps.
When used When there are multiple ways to view and interact with data. Also used
- Changes to one layer do not affect layers above
when the future requirements for interaction and presentation of data are - If interface changes, affects only layer above.
unknown.
Advantages Allows the data (model) to change independently of its representation
- Easily replace one layer by another equivalent one (with
(view) and vice versa. Supports presentation of the same data in different same interface).
ways with user changes made in one representation shown in all of them.
Disadvantages Can involve additional code and code complexity when the data model
- Portability: need to change only bottom layer to port to
and interactions are simple. different machine(s).
!11 !12
Layered Architecture Pattern Layered Architecture Pattern
Diagram Example: LIBSYS
Allows controlled electronic Web browser interface
access to copyrighted
User interface
material from a group of
university libraries
LIBSYS Forms and Print
User interface management login query manager manager
Authentication and authorization
Library index
System support (OS, database etc.)
Databases from
different libraries
!13 !14
•
When used Used when !
• building new facilities on top of existing systems !
• the development is spread across several teams with each team
Data is transformed as it moves through the system.
responsibility for a layer of functionality !
• there is a requirement for multi-level security. • Transformations can be run concurrently.
•
Advantages Allows replacement of entire layers so long as the interface is
maintained. Redundant facilities (e.g., authentication) can be provided in
each layer to increase the dependability of the system.
Commonly used in batch processing systems and
Disadvantages In practice, providing a clean separation between layers is often difficult embedded control systems.
•
and a high-level layer may have to interact directly with lower-level
layers rather than through the layer immediately below it. Performance
can be a problem because of multiple levels of interpretation of a service
Difficult to use for interactive systems.
request as it is processed at each layer.
!15 !16
Pipe and Filter Architecture Pipe and Filter Example:
Example: Processing invoices Compiler (g++)
Issue
Receipts
receipts
Read issued
invoices
Identify
payments
lexical analysis Symbol table
Find Issue
produces stream Syntax tree
payments payment Reminders of tokens
due reminder
Invoices Payments
!17 !18
•
communicating transformations. Each transformation must parse
its input and unparse its output to the agreed form. This Communication between components may be
increases system overhead and may mean that it is impossible to
reuse functional transformations that use incompatible data inefficient.
structures.
!19 !20
Repository Architecture Example: Repository Architecture
Compiler/IDE (eclipse) Description
Name Repository
Client-Server Architecture
5. Client-Server Architecture
Example: Film Library
• Commonly used organization for distributed systems.
• Composed of:
Serves information,
Client 1 Client 2 Client 3 Client 4
- A set of servers that offer specific (unique) services to other videos, still photos.
components. Catalog server
handles searching. Internet
- A set of clients that call on services offered by the servers
Clients are multiple
- A network that allows the clients to access the services. instances of a user
•
interface (in a web
Clients make remote procedure calls to servers using browser).
Catalog
server
Video
server
Picture
server
Web
server
a protocol like http, then wait for reply. Library Film store Photo store Film and
•
catalogue photo info.
Several instances of client on different machines.
!23 !24
Client-Server Architecture
Description
Name Client-server
When used Used when data in a shared database has to be accessed from a range of
locations. Because servers can be replicated, may also be used when the
load on a system is variable.
Advantages The principal advantage of this model is that servers can be distributed
across a network. General functionality (e.g., a printing service) can be
available to all clients and does not need to be implemented by all services.
!25