Design Pattern(3) 设计模式(3 Institute of Computer Software 2021/2/5 Nanjing University
设计模式(3) Design Pattern (3) 2021/2/5 Institute of Computer Software Nanjing University 1
最病 过摘要 2 Design Patterns a Why, What, How a Creational, Structural and Behavioral Patterns Institute of Computer Software 2021/215 Nanjing University
摘要 Design Patterns Why, What, How Creational, Structural and Behavioral Patterns 2021/2/5 Institute of Computer Software Nanjing University 2
最病 A Behavioral Patterns 口行为模式是对在不同的对象之间划分责任和算 法的抽象化。行为模式不仅仅是关于类和对象 的,而且关注它们之间的通信模式。 口类的行为模式:使用继承关系在几个类之间分配行 *-Interpreter template Method 口对象的行为模式:使用对象的聚合来分配行为 Institute of Computer Software 2021/215 Nanjing University
Behavioral Patterns 行为模式是对在不同的对象之间划分责任和算 法的抽象化。行为模式不仅仅是关于类和对象 的,而且关注它们之间的通信模式。 类的行为模式:使用继承关系在几个类之间分配行 为 – Interpreter, Template Method 对象的行为模式:使用对象的聚合来分配行为 2021/2/5 Institute of Computer Software Nanjing University 3
最病 A Behavioral Patterns a Chain of responsibility 口 Command 口 Interpreter 口| terator 口 Mediator 口 Memento 口○ oserver a State 口 Strategy 口 Template Method 口 Visitor Institute of Computer Software 2021/215 Nanjing University
Behavioral Patterns Chain of Responsibility Command Interpreter Iterator Mediator Memento Observer State Strategy Template Method Visitor 2021/2/5 Institute of Computer Software Nanjing University 4
最病 A Chain of Responsibility 5 口| ntent 口使多个对象都有机会处理请求,从而避免请求的发送者和接 收者之间的耦合关系。将这些对象连成一条链,并沿着这条 链传递该请求,直到有一个对象处理它为止。 口 Motivation 口应根据普遍性即从最特殊到最普遍的顺序来组织帮助信息 比如用户界面中会有一个对象来处理帮助请求,但是哪一个 对象则取决于上下文 口给多个对象处理一个请求的机会,从而解耦发送者和接受者 Institute of Computer Software 2021/215 Nanjing University
Chain of Responsibility Intent 使多个对象都有机会处理请求,从而避免请求的发送者和接 收者之间的耦合关系。将这些对象连成一条链,并沿着这条 链传递该请求,直到有一个对象处理它为止。 Motivation 应根据普遍性即从最特殊到最普遍的顺序来组织帮助信息, 比如用户界面中会有一个对象来处理帮助请求,但是哪一个 对象则取决于上下文 给多个对象处理一个请求的机会,从而解耦发送者和接受者 2021/2/5 Institute of Computer Software Nanjing University 5