Modeling Real-World Data

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: