- Hands-On Design Patterns with Kotlin
- Alexey Soshin
- 120字
- 2021-06-25 20:49:31
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.
推薦閱讀
- Computer Vision for the Web
- Oracle從新手到高手
- C語言程序設(shè)計基礎(chǔ)與實驗指導(dǎo)
- Oracle數(shù)據(jù)庫從入門到運維實戰(zhàn)
- Java深入解析:透析Java本質(zhì)的36個話題
- 數(shù)據(jù)結(jié)構(gòu)(C語言)
- Java EE企業(yè)級應(yīng)用開發(fā)教程(Spring+Spring MVC+MyBatis)
- PHP與MySQL權(quán)威指南
- RESTful Web Clients:基于超媒體的可復(fù)用客戶端
- Oracle 12c從入門到精通(視頻教學(xué)超值版)
- iOS開發(fā)項目化入門教程
- 數(shù)字媒體技術(shù)概論
- VC++ 2008專題應(yīng)用程序開發(fā)實例精講
- C語言進階:重點、難點與疑點解析
- Xamarin Cross-platform Application Development(Second Edition)