- 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.
推薦閱讀
- Objective-C Memory Management Essentials
- Visual FoxPro程序設(shè)計(jì)教程
- Visual Basic 6.0程序設(shè)計(jì)計(jì)算機(jī)組裝與維修
- 體驗(yàn)設(shè)計(jì)原理:行為、情感和細(xì)節(jié)
- Django Design Patterns and Best Practices
- ASP.NET動(dòng)態(tài)網(wǎng)頁(yè)設(shè)計(jì)教程(第三版)
- NativeScript for Angular Mobile Development
- Silverlight魔幻銀燈
- MATLAB實(shí)用教程
- 數(shù)據(jù)結(jié)構(gòu)(C語(yǔ)言)
- Big Data Analytics
- 零基礎(chǔ)輕松學(xué)SQL Server 2016
- .NET 3.5編程
- CRYENGINE Game Development Blueprints
- WildFly Cookbook