[Early Access] Advanced Kotlin
[Early Access] Advanced Kotlin
About the Book
You can be a developer without knowing those topics, even a good one, but at some point, is will start blocking you. You likely use on daily basis tools made using features described in this book - libraries based on annotation processing or compiler plugins, classes using variance modifiers, functions with contracts, and property delegates. But do you understand those features? Would you be able to implement similar tools yourself? Would you be able to analyze and debug them? This book is about to change it. It concentrates explicitly on the most advanced Kotlin topics, which are often not well understood even by senior Kotlin developers. It should equip you with the knowledge and show you possibilities you haven't seen before. I hope you enjoy it as much as I enjoyed writing it.
Bundles that include this book
Table of Contents
-
-
Introduction
- For whom is this book written?
- That will be covered?
- The structure of the book
- Kotlin for Developers
- Conventions
- Code conventions
- Acknowledgments
-
Generic variance modifiers
- List variance
- Consumer variance
- Function types
- Covariant Nothing Object
- Covariant Nothing Class
- Variance modifiers limitations
- UnsafeVariance annotation
- Variance modifier positions
- Star projection
- Summary
-
Interface Delegation
- Delegation pattern
- Delegation and inheritance
- Kotlin interface delegation support
- Wrapper classes
- Decorator pattern
- Intersection types
- Limitations
- Conflicting elements from parents
- Summary
-
Property delegation
- How property delegation works
-
Other
getValue
andsetVale
parameters - Implementing custom property delegate
- Provide delegate
-
Property delegates in Kotlin stdlib
-
notNull
delegate -
lazy
delegate -
observable
delegate -
vetoable
delegate - Map as a delegate
- Review of how variables work
- Summary
-
-
Kotlin Contracts
- The meaning of a contract
- How many times do we invoke a function from an argument
- Implications from the fact that a function returned some value
- Using contracts in practice
- Summary
-
Java interoperability
- Nullable types
- Kotlin type mapping
- JVM primitives
- Collection types
- Annotation targets
- Static elements
- JvmField
- Using Java accessors in Kotlin
- JvmName
- JvmMultifileClass
- JvmOverloads
- Unit
- Function types and function interface
- Tricky names
- Throws
- JvmRecord
- Summary
-
Using Multiplatform Kotlin
- Expect and actual elements
- Possibilities
- Multiplatform library
- Multiplatform mobile application
- Summary
- Using Kotlin/JS
- Using Kotlin/Native
-
Reflection
- Hierarchy of classes
- Function reference
- Parameter reference
- Property reference
- Class reference
- Serialization example
- Referencing types
- Type reflection example: Random value
- Kotlin and Java reflection
- Breaking encapsulation
- Summary
-
Annotation Processing
- Your first annotation processor
- Hiding generated classes
- Summary
-
Kotlin Symbol Processing
- Your first KSP processor
- Generation results are not visible by IDE
- Testing KSP
- Dependencies and incremental processing
- Multiple round processing
- Using KSP on multiplatform projects
- Summary
- Kotlin Compiler Plugin
-
Static Code Analysers
- What are Static Analysers?
- Type of analysers
- Kotlin Code Analysers
- Setting-up Detekt
- Writing you first Detekt Rule
- Conclusion
-
Introduction
- Notes
The Leanpub 60-day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
80% Royalties. Earn $16 on a $20 book.
We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $12 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them