您的位置:首页 > 其它

每天一个设计模式之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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: