Автор: Marcin Moskała
Издательство: Leanpub
Год: 2024-10-10
Страниц: 385
Язык: английский
Формат: pdf (true), epub
Размер: 19.8 MB
Effective Kotlin summarizes the best practices and experiences of the Kotlin community, together with a deep explanation of some lesser-known Kotlin functionalities. All of the best practices are presented as simple rules with detailed explanations.
Kotlin is a powerful and pragmatic language, but it's not enough to know about its features. We also need to know when they should be used and in what way. This book is a guide for Kotlin developers on how to become excellent Kotlin developers. It presents and explains in-depth the best practices for Kotlin development. Each item is presented as a clear rule of thumb, supported by detailed explanations and practical examples.
Why do we decide to use Kotlin in our projects instead of Java, jаvascript, or C++? For developers, the answer is often that Kotlin is a modern language with a lot of useful features. For business, the answer is usually that Kotlin is a safe language, meaning that it is less prone to errors due to its design. You don’t need to have any experience with development to get upset when an application crashes or there is an error on a website that does not let you check out after you’ve spent an hour adding products to your basket. Fewer crashes improve the lives of both users and developers, thus providing significant business value.
Safety is important for us, and Kotlin is a really safe language, but it still needs developer support to be truly safe. In this chapter, we’ll talk about the most important best practices for safety in Kotlin. We’ll see how Kotlin features promote safety and how we can use them properly. The general purpose of every item in this chapter is to produce code that is less prone to errors.
Concepts in the book are grouped into three parts:
• Good code - more general rules about writing good-quality code. This part is for every Kotlin developer, no matter how big their project is. It starts from items about safety and later talks about readability. It is not a coincidence that the first chapter is dedicated to safety. I believe that program correctness is generally of the highest priority. Another chapter concerns readability because code is not only for a compiler but also for programmers. Even when we work alone, we want readable and self-explanatory code.
• Code design - this section is for developers creating projects or libraries in cooperation with other developers. This part is about conventions and declaring contracts. The Code design chapter will, in the end, reflect on readability and safety in terms of code design. This part is a bit more abstract at the beginning, but this lets it explore topics that are often omitted in books about code quality. This section is also about preparing our code for growth. Many items are about being ready for changes in the future and are therefore especially important for developers creating large projects.
• Efficiency - this section is for developers who care about code efficiency. Most of the rules presented here do not come at the cost of development time or readability, so they are suitable for everyone. However, they are particularly important for developers implementing high-performance applications, libraries, or applications for millions of users.
Who is this book for?
This book does not teach the basics. It assumes that you have enough knowledge and skills to do Kotlin development. If you don’t, I recommend starting with some resources designed for beginners, like my books Kotlin Essentials and Functional Kotlin. Effective Kotlin is for experienced Kotlin developers.
I will assume that even experienced developers might not know some features. This is why I explain concepts such as:
• Properties
• Platform types
• Named arguments
• DSL creation
• Inline classes and functions
I want this book to be a complete guide for Kotlin developers on how to become amazing Kotlin developers.
Скачать Effective Kotlin : Best practices - Second Edition