Introduction

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

When developing an app, there are numerous cases when you need to model and represent data. Consider a simple client program that fetches blog posts from a server. To show those blog posts in the client, you need to have some representation of a blog post object. This object may contain the title, body, and author, while more complex sites would put even more into that object.

In other languages, modeling these data objects requires a lot of boilerplate code and numerous fields to hold the data. As with most things Kotlin, Kotlin data classes represent these objects in an elegant, streamlined manner.

Whether you’re just starting with Kotlin or have been using the language for a long time, this lesson will show you how to get started using these classes. Additionally, you’ll go over some concrete use cases for Kotlin data classes and consider the pros and cons of using this paradigm versus something else.

See forum comments
Download course materials from Github
Previous: Quiz: Use Companion Objects Next: Instruction