In this chapter, you'll discover how to apply object-oriented programming principles within your Kotlin code. We'll learn how to write cleaner code by modeling data using classes, interfaces, and the concepts of inheritance and composition. We'll explore different ways of modeling data with classes, enumerations, and sealed classes and learn when to choose one over the other to minimize the amount of code we must write and to enforce best practices such as immutability and strong type safety.
This chapter is structured as follows:
- Discovering how to create a simple class in Kotlin
- Understanding how to realize the concepts of inheritance and composition within your Kotlin code
- Learning how to leverage data classes to reduce boilerplate
- Learning about different types of classes such as object classes, sealed classes, enums, and inline classes...