本文介绍了装饰图案与分类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以通过添加子类来解决添加功能的问题,然后为什么要使用装饰器模式装饰器模式的真正优势?
解决方案来自的装饰图案的div>
装饰器模式的整个点是动态添加额外的行为/功能,这当然不可能在设计时间。
从同一篇文章:
I can solve the problem of adding functionality by adding sub classing then why should I use decorator pattern what's the real advantage of decorator pattern ?
解决方案
from Decorator pattern at wikipedia
The whole point of decorator pattern is to dynamically add additional behaviour/functionality, which is of course not possible at design time.
from the same article:
这篇关于装饰图案与分类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-11 11:22