01-01-01 Factory Design Pattern
来源:互联网 发布:电脑制作电子相册软件 编辑:程序博客网 时间:2024/05/07 08:50
Pattern Name
Synopsis:
Factory pattern is one of most used design pattern in Java. This type of design pattern comes under creational pattern as this pattern provides one of the best ways to create an object.
Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
Varying: subclass of object that is instantiated.
I would like to think about design patterns in terms of classes being as ‘people,’ and patterns are ways that people talk to each other.
So, to me the factory pattern is like a hiring agency. You’ve got someone that will need a variable number of workers. This person may know some info they need in the people they hire, but that’s it.
So, when they need a new employee, they call the hiring agency and tell them what they need. Now, to actually hire someone, you need to know a lot of stuff - benefits, eligibility verification, etc. But the person hiring doesn’t need to know any of this - the hiring agency handles all of that.
In the same way, using a Factory allows the consumer to create new objects without having to know the details of how they’re created, or what their dependencies are - they only have to give the information they actually want.
Intent:
In what situations can the pattern be used, we can consider it as pattern`s context.
- creates objects without exposing the instantiation logic to the
client - refers to the newly created object through a common interface
Structure
Diagram using the Object Modeling Technique (OMT)
Implementation
: Implementation details to consider
Applicability
Participants
Classes and objects in design
Related patterns
: A list of related patterns
Motivation
: A scenario that illustrates the problem
- 01-01-01 Factory Design Pattern
- Design Pattern --- Factory Pattern
- Design Pattern - Factory Pattern
- Design Pattern - Factory Pattern
- 01 Design Pattern
- Design Pattern 2-Factory
- [Design Pattern]:Factory
- The Factory Design Pattern
- Design Pattern Abstract Factory
- Design Pattern Factory Method
- Design Pattern :Simple Factory
- Design pattern:Factory Method
- Design Pattern:Abstract Factory
- Java Design Pattern: Factory
- Design pattern-Factory method
- 一句话Design Pattern:Factory
- design pattern -- factory
- Design Pattern - Abstract Factory Pattern
- 什么是WMS
- 查看和修改MySql6.0数据库编码(Linux版本)
- Icon and Image Sizes
- android使用smb协议在线播放视频(二)
- POJ No.3169 Layout
- 01-01-01 Factory Design Pattern
- 究竟wifi是怎么定位我的
- iOS开发——POST异步网络请求自行封装
- 陈越、何钦铭《数据结构》第一讲基本概念 笔记
- 全排列
- Effective C++——条款17(第3章)
- 服务器类型,服务器名称,数据库,数据库服务实例之间的关系
- Android UI设计——ViewPage的无限循环(五)
- Android Version