摘要
设计模式不仅使开发者更容易理解设计的思路,而且在很大程度上提高开发者的系统设计能力。在面向对象的设计中,我们经常使用继承来扩展对象的功能,但是复杂的继承关系很容易造成类爆炸,而且这种方式缺乏灵活性。Decorator模式可以很好地解决这个问题。以Decorator模式在数据打印中的应用为例,具体介绍Decorator模式问题的产生、解决和效果,同时也说明了Decorator模式带来软件扩充和复用的方便性。
Design Pattern which not only makes developers more easier to understand the thinking of design, but also improves the developer's systematic designed capacity to a great extent. We often use inheritance to extend object's function in the application of Object- Oriented Programming, but complicated inheritance casuses class explosion. Moreover the method lacks of flexibility. Decorator pattern solve the problem perfectly. The origins, solutions and effects of Decorator Pattern are described in details on the basis of the application in data printing. The expansion and reusage of software brought by Decorator Pattern are also stated at the same time.
出处
《软件导刊》
2009年第2期14-16,共3页
Software Guide