Java设计模式(8) —— 抽象工厂

来源:互联网 发布:php编程 第3版 pdf 编辑:程序博客网 时间:2024/05/18 20:13

Abstract Factory

 

英文简单描述

Intent
Provide an interface for creating families of related or dependent objects without specifying their concrete classes.

How to
AbstractFactory
declares an interface for operations that create abstract product objects.

ConcreteFactory
implements the operations to create concrete product objects.

AbstractProduct
declares an interface for a type of product object.

ConcreteProduct
defines a product object to be created by the corresponding concrete factory.
implements the AbstractProduct interface.

Client
uses only interfaces declared by AbstractFactory and AbstractProduct classes.

Known cases

Look and Feel

Persistance Tier

 

UML

 

此模式经常与工厂模式和单例模式一同使用

 

代码:


原创粉丝点击