摘要
介绍了应用装饰模式自动生成CSS的方法.原始的设计是基于继承的,子类功能的增加是通过覆盖或扩展父类方法实现的.优化的设计应用了装饰模式,获得了良好的可扩展性和可维护性.将CSS细分成不同的部分,每个部分作为一个装饰类.可以根据需要灵活地使用这些装饰类生成不同风格的CSS.通过对比这两种设计方式,最后列出了利用装饰模式的优缺点.
This paper introduces the application of Decorator Pattern in the field of creating CSS automatically. The original design is based on inheritance and the additional functionality of subclasses is implemented by over- riding or extending methods in the superclass. The optimized design that applies Decorator Pattern accommodates the future extension and maintenance. It divides a CSS file into several parts, each of which develops into a dec- orator. These decorators can be flexibly used to create CSS of different style. The processes of both designs are explained in detail. By contrasting both designs, the advantages and disadvantages of the pattern are listed.
出处
《兰州工业高等专科学校学报》
2012年第6期20-23,共4页
Journal of Lanzhou Higher Polytechnical College
关键词
装饰模式
继承
应用
CSS
Decorator Pattern
inheritance
application
CSS