Design Patterns -- Factory Method
来源:互联网 发布:mysql更新语句怎么写 编辑:程序博客网 时间:2024/04/30 14:13
The Factor Method pattern lets a class developer define the interface for creating an object while retaining control of which class to instantiate, see pic:
To summarize, the signs that Factory Method is at work are that an operation:
- Creates a new object
- Returns a type that is an abstract calss or an interface
- The class/interface returned is implemented by several classes (The subclass is to determine which class to instantiate)
The spirit of Factory Method is that the object creator makes a choice about which of several possible classes to instantiate for the client. In other words, Factory Method lets subclasses decide which class to instantiate.
The Iterator in Java is a good example for Factory Method.
The Factory Method pattern often appears when we use parallel herarchies to model a problem domain. Factory Method lets you connect parallel hiearchies by letting subclasses in one hierarchy determine which class to instantiate in the corresponding hierarchy, see pic:
and sequence diagram:
- Design Patterns -- Factory Method
- C++ Design Patterns : Template + Factory Method
- Design Patterns - Factory Method - Example 1
- Design Patterns VI : Simple Factory, Factory Method, Abstract Factory
- Design Patterns: Factory vs Factory method vs Abstract Factory
- Design Patterns -- Abstract Factory
- Design Patterns - Abstract Factory
- Design Pattern Factory Method
- Design pattern:Factory Method
- Design pattern-Factory method
- Java Design Patterns Abstract Factory
- Understanding Factory Method and Abstract Factory Patterns
- Design Patterns 1 : Template Method
- Delphi Design Pattern - Factory Method
- Design Pattern: Factory Method 模式
- Design Pattern: Factory Method 模式
- Design Pattern: Factory Method 模式
- Patterns in SOME –Factory Method
- 网站项目建设流程概述
- [b/s]使用 Ajax 操纵 Lotus Notes 文档
- [ASP.NET学习笔记之五]ASP.NET 中的缓存功能介绍
- 项目测试反馈规则
- TEST
- Design Patterns -- Factory Method
- 一个较简易的分页javascript类
- Lotus Sametime 开发入门: 使用客户端 ToolKit 与 Sametime 服务器交互
- Biztalk 实例之 从SQL Server中获取数据
- [ASP.NET学习笔记之六]开发高性能的ADO.NET应用
- 经典收藏 C++内存管理操作详解
- 程序人生 - 开发工程师人生之路
- ClearCase Deliver过程解析
- 贝多芬的弦乐四重奏