官术网_书友最值得收藏!

Decorator

In the previous chapter, we discussed the Prototype design pattern, which allowed for creating instances of classes with slightly (or not so slightly) different data.

What if we would like to create a set of classes with slightly different behavior though? Well, since functions in Kotlin are first-class citizens (more on that in a bit), you could use the Prototype design pattern to achieve that. After all, that's what JavaScript does successfully. But the goal of this chapter is to discuss another approach to the same problem. After all, design patterns are all about approaches.

By implementing this design pattern, we allow the user of our code to specify which abilities he or she wants to add.

主站蜘蛛池模板: 山东省| 介休市| 平阴县| 浮山县| 鱼台县| 安岳县| 扶风县| 英吉沙县| 巴林左旗| 万载县| 龙游县| 广宗县| 水城县| 简阳市| 来安县| 正定县| 桓仁| 建瓯市| 昌乐县| 专栏| 宁乡县| 杂多县| 临猗县| 比如县| 石首市| 黑龙江省| 囊谦县| 玛曲县| 衡东县| 怀集县| 革吉县| 辰溪县| 响水县| 三台县| 榆树市| 福泉市| 柏乡县| 怀宁县| 安溪县| 宜州市| 海兴县|