当前位置:
文档之家› 软件体系结构-第二讲(架构模式)
软件体系结构-第二讲(架构模式)
2012-7-11
Software A Architecture Design
—— Chapter two Software Architecture Style
李哲洙 lizhezhu@
1
本章要点
Software Architecture Style Typical Architecture style C/S & B/S Style New Architecture Style Case Study
Pipes and Filters:Strengths
• System easy to understand
• Reuse, Enhancement & Maintainability • Concurrency can be easily exploited.
– System = simple composition of individual filters – No complex interaction between components – Easy to add filters & replace existing ones (why?)
• Components: Filter
– Completely independent entities – Consume streams of inputs and produce streams of outputs – Context independent (do not know what produced the input or will consume the output) – Output starts before input is (entirely) consumed (incremental transformation of data) – Carrier of data streams – Binding between component ports
• Implicit invocation • Explicit invocation
– Main program and subroutine – OO (& Data abstraction) – Layered
• Virtual Machine
– Interpreter – Rule-based system
3
2012-7-11
Mary Shaw, CMU
Architectural style (cont.)
• What is the structural pattern—the components, connectors, and constraints? • What is the underlying computational model? • What are the essential invariants of the style? • What are some common examples of its use? • What are the advantages and disadvantages of using that style? • What are some of the common specializations?
– a vocabulary of components and connector types – a set of constraints on how they can be combined – one or more semantic models that specify how a system’s overall properties can be determined from the properties of its parts
Distributed Event-driven Frame-based Batch Pipes and filters Repository-centric Blackboard Interpreter Rule-based
设计模式
代码模式
5
Mary Shaw, CMU
Architectural style
• An architecture style defines a family of systems in terms of a pattern of structural organization. • An architectural style defines
1
2012-7-11
模式在知识理念中的地位
抽象的 (abstract) 模式 Patterns
应用设计框架 Frameworks
应用实践的参考设计
Reference Implementation
具体的 (concrete)
平台 (Platform)
Patterns
• • •
A pattern is a solution to a problem in a context A pattern codifies specific knowledge collected from experience in a domain All well-structured systems are full of patterns
– Do not share data. – Do not know identity of neighbors.
• Individual filter behavior: simple I/O relation • System behavior = simple composition of individual filter behaviors.
Software Architecture Style Typical Architecture style C/S & B/S Style New Architecture Style Case Study
架构模式的经典分类
12
6
2012-7-11
架构模式的现代分类
13
Common Architectural Styles
– Adapter – Bridge – Proxy
•
Behavioral patterns
– Chain of responsibility – Mediator – Visitor
•
Mechanisms are the soul of an architecture
5
2012-7-11
本章要点
10
2012-7-11
Pipes and Filters:Weaknesses
• Can lead to batch sequential processing • Not well suited to interactive applications • Use of this style may
– – –
Idioms Design patterns Architectural patterns
2
2012-7-11
不同层次的模式
• 区别:在于三种不同的模式存在于它们各自的抽象层次和具体层次。
架构模式
– 是系统的高层次策略,涉及到大尺度的组件以及整体性质 – 可作为具体软件体系结构的模板,是开发一个软件系统时的基本设计决策 – 规定了系统范围结构特性,架构模式的好坏影响到总体布局和框架性结构 – 是中等尺度的结构策略。实现了一些大尺度组件的行为和它们之间的关系 – 模式的好坏不会影响到系统的总体布局和总体框架。 – 设计模式定义出子系统或组件的微观结构 – 是特定的范例和与特定语言有关的编程技巧 – 处理特定设计问题的实现,关注设计和实现方面 – 模式的好坏会影响中等尺度组件的内部、外部的结构或行为的底层细节
Style 一: Pipes and Filters
• Unix shell
ps -x | grep vi | awk '{print "kill -9 " $1}' > kill.vi
ps
grep
awk
8
2012-7-11
Pipes /Filters
管道
过滤器
Pipes and Filters:Components & Connectors
Types of Architeture Pattern
• • • •
From Mud to Structure Distributed Systems Interactive Systems Adaptable Systems
4
2012-7-11
Architectural patterns
Software Architecture Shaw and Garlan Buschmann et al A System of Patterns Buschman et al Booch
• Dataflow
– Pipes and filters – Batch sequential
• Call and Return
• Data-centered
– Repository – Blackboard
• Independent components
– Communicating processes – Client/server – Event systems
11
2012-7-11
Pipes and Filters:Variations
• Pipelines
– Linear sequences of filters
• Batch Sequential Systems • Bounded pipes • Typed pipes • “UI pipes”