每天一个设计模式之Flyweight
2011-06-06 17:42
197 查看
http://www.oodesign.com/flyweight-pattern.html
Some programs require a large number of objects that have some shared state among them.例如一个游戏中的士兵,创建大量士兵对象将消耗大量内存。但是我们可以发现:每个士兵的位置和health各有不同,但是持有的武器,行进速度等很多特性都是相同的。
Flyweight模式处理的问题就是:
The intent of this pattern is to use sharing to support a large number
of objects that have part of their internal state in common where the
other part of state can vary.
Some programs require a large number of objects that have some shared state among them.例如一个游戏中的士兵,创建大量士兵对象将消耗大量内存。但是我们可以发现:每个士兵的位置和health各有不同,但是持有的武器,行进速度等很多特性都是相同的。
Flyweight模式处理的问题就是:
The intent of this pattern is to use sharing to support a large number
of objects that have part of their internal state in common where the
other part of state can vary.
相关文章推荐
- 每天一个设计模式(4):简单工厂“模式”
- 一天一个设计模式之享元模式(flyweight)
- 每天一个设计模式(3):装饰者模式
- 《每天学一个设计模式》 之 策略模式
- 每天一个设计模式之 -- 过滤器模式
- 每天一个设计模式之Decorator
- 每天一个设计模式之 -- 组合模式
- 每天一个设计模式: 桥模式(Bridge)
- 每天一个设计模式: 抽象工厂模式(AbstractFactory)
- 每天一个设计模式(6):抽象工厂模式
- 每天一个设计模式: 状态模式(State)
- 每天一个设计模式
- 每天一个设计模式之composite
- 每天一个设计模式之proxy
- 每天一个设计模式之 -- 工厂模式
- 每天一个设计模式之代理模式
- 每天一个设计模式(1):策略模式
- 每天一个设计模式之Template Method
- 每天一个设计模式之 -- 抽象工厂模式
- 每天一个设计模式: 命令模式(Command)