Polymorphism and Alternatives
In this chapter, we are going to take a real-life example and solve the problem by implementing various solutions using different approaches. We will use polymorphism as a baseline for the solution. Afterward, we will use other approaches that are powered by the Kotlin language. Finally, we will compare them and try to understand which one is suitable under which circumstances.
We will cover the following topics in this chapter:
- Why Kotlin?
- Real-life example – revisited
- Polymorphic solution
- Sealed class solution
- Delegation solution
- Functional solution
- Comparison and summary