Pattern Frame work 模式&框架 Institute of Computer Software 2021/27 Nanjing University
模式&框架 Pattern & Framework 2021/2/7 Institute of Computer Software Nanjing University 1
最病 过摘要 2 口 More about pattern 口 Framework 口 Comparison Institute of Computer Software 2021/2/7 Nanjing University
摘要 More about Pattern Framework Comparison 2021/2/7 Institute of Computer Software Nanjing University 2
最病 o More about Pattern 口 Patterns of patterns 口Anti- pattern 口J2 EE patterns Institute of Computer Software 2021/2/7 Nanjing University
More about Pattern Patterns of Patterns Anti-pattern J2EE patterns 2021/2/7 Institute of Computer Software Nanjing University 4
最病 o More about Pattern 5 口 Patterns of patterns 口Anti- pattern 口J2 EE patterns Institute of Computer Software 2021/2/7 Nanjing University
More about Pattern Patterns of Patterns Anti-pattern J2EE patterns 2021/2/7 Institute of Computer Software Nanjing University 5
最病 A Working together 6 n Patterns are often used together and combined with the same design solution o a compound pattern combines two or more patterns into a solution that solves a recurring or general problem. Institute of Computer Software 2021/2/7 Nanjing University
Working together Patterns are often used together and combined with the same design solution. A compound pattern combines two or more patterns into a solution that solves a recurring or general problem. 2021/2/7 Institute of Computer Software Nanjing University 6
Example:设计一个文档编辑器 7 口设计问题 口文档结构 口格式化 口修饰用户界面 口支持多种视感look-and-e标准 口支持多种窗口系统 口用户操作 口拼写检查和连字符 Institute of Computer Software 2021/2/7 Nanjing University
Example:设计一个文档编辑器 设计问题 文档结构 格式化 修饰用户界面 支持多种视感(look-and-feel)标准 支持多种窗口系统 用户操作 拼写检查和连字符 2021/2/7 Institute of Computer Software Nanjing University 7
使用设计模式 a Composite表示文档的物理结构:递归组合 口 Strategyγ允许不同的格式化算法 口 Decorator修饰用户界面 口 Abstract Factory支持多视感标准 口 Bridge允许多个窗口平台 口 Command支持撤销用户操作 口 Iterator访问和遍历对象结构 口 Visitor允许无限扩充分析能力而又不会使文档结 构的实现复杂化 Institute of Computer Software 2021/2/7 Nanjing University
使用设计模式 Composite表示文档的物理结构:递归组合 Strategy允许不同的格式化算法 Decorator修饰用户界面 Abstract Factory支持多视感标准 Bridge允许多个窗口平台 Command支持撤销用户操作 Iterator访问和遍历对象结构 Visitor允许无限扩充分析能力而又不会使文档结 构的实现复杂化 2021/2/7 Institute of Computer Software Nanjing University 8
最病 A Duck Example 9 a Start with a bunch of quackables o a goose came along and wanted to act like a Quakable too Adapter n Then the Quackologists decided they wanted to count lacks. Decorator Abstract factory j o but the quackologists were worried theyd forget to add the Quack Counter decorator a We had management problems keeping track of all those ducks and geese and quackables Composite Iterator n The Qvackologists also wanted to be notified when any quackable quacked. Observer Institute of Computer Software 2021/2/7 Nanjing University
Duck Example Start with a bunch of Quackables.. A goose came along and wanted to act like a Quakable too. Then, the Quackologists decided they wanted to count quacks. But the Quackologists were worried they’d forget to add the QuackCounter decorator. We had management problems keeping track of all those ducks and geese and quackables. The Quackologists also wanted to be notified when any quackable quacked. 2021/2/7 Institute of Computer Software Nanjing University 9 Adapter Decorator Abstract factory Composite Iterator Observer
最病 A Compound Patterns 口MVC aa song about MvC by James Dempsey (yrics you urface and ey see the en9 mey new so pining View Controller det tells the ew the state has Contreller os The odel containd all the state. data, and appeats Institute of Computer Software 2021/2/7 Nanjing University
Compound Patterns MVC a song about MVC by James Dempsey (lyrics) 2021/2/7 Institute of Computer Software Nanjing University 10
最病 E MVO a MVC is a compound pattern consisting of the Observer(model), Strategy (controller )and Composite(view) patterns. a The Adapter pattern can be used to adapt a new model to an existing view and controller Institute of Computer Software 2021/2/7 Nanjing University
MVC MVC is a compound pattern consisting of the Observer (model), Strategy (controller) and Composite (view) patterns. The Adapter pattern can be used to adapt a new model to an existing view and controller. 2021/2/7 Institute of Computer Software Nanjing University 11