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

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.

主站蜘蛛池模板: 班戈县| 辽阳县| 徐州市| 枝江市| 改则县| 南丹县| 巨野县| 天镇县| 乌拉特中旗| 绥棱县| 邢台县| 黎川县| 女性| 海门市| 镇远县| 晋江市| 磴口县| 河西区| 报价| 东光县| 建昌县| 湖南省| 江孜县| 三河市| 扎赉特旗| 新竹市| 田东县| 皋兰县| 高清| 泰宁县| 陈巴尔虎旗| 诸城市| 宁阳县| 民县| 菏泽市| 永吉县| 宣城市| 揭阳市| 巨野县| 金湖县| 金堂县|