Book Image

Mastering High Performance with Kotlin

Book Image

Mastering High Performance with Kotlin

Overview of this book

The ease with which we write applications has been increasing, but with it comes the need to address their performance. A balancing act between easily implementing complex applications and keeping their performance optimal is a present-day requirement In this book, we explore how to achieve this crucial balance, while developing and deploying applications with Kotlin. The book starts by analyzing various Kotlin specifcations to identify those that have a potentially adverse effect on performance. Then, we move on to monitor techniques that enable us to identify performance bottlenecks and optimize performance metrics. Next, we look at techniques that help to us achieve high performance: memory optimization, concurrency, multi threading, scaling, and caching. We also look at fault tolerance solutions and the importance of logging. We'll also cover best practices of Kotlin programming that will help you to improve the quality of your code base. By the end of the book, you will have gained some insight into various techniques and solutions that will help to create high-performance applications in the Kotlin environment
Table of Contents (12 chapters)

Preventing Unnecessary Overhead Using Delegates

Delegation is an extremely powerful pattern in which a delegating object assigns authority to a delegate object. The delegating object keeps a reference to the delegate object and dispatches messages to it.

Dispatch, or message passing, is a concept in object-oriented programming by means of which one object invokes the method of another.

The delegating object uses the delegate object to provide an interface that's similar to an interface of the delegate. In some cases, the delegating object can send a message to the delegate object to just update its own state or that of another object. This is shown in the following diagram:

In other cases, the delegating object assigns responsibility for performing some behavior to the delegate object, as follows:

In this chapter, we'll cover the following topics:

  • Types of delegation...