Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Marcin Moskała

Rating No ratings yet

No description

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A hands-on exercise book for developers who already know some Kotlin and want to sharpen their skills through deliberate practice. It covers everything from basic syntax and nullability to collections, functional programming, coroutines, flows, and advanced topics like reflection and annotation processing. 【Book Arc】 - **Opening (~0%–12%)**: Starts with essential Kotlin exercises covering `when` expressions, nullability, and object declarations. The goal is to build fluency with core language features through small, focused problems. - **Early (~12%–32%)**: Moves into functional programming and collections—observable values, collection processing optimization, recursive algorithms like partitions, and custom coroutine contexts. This stage builds problem-solving skills with Kotlin's standard library. - **Middle (~32%–52%)**: Dives into coroutines and flows with practical scenarios: simulating a cafeteria with channels, building a `NewsViewModel` with `Flow`, handling cancellation correctly, and testing coroutine-based code. Also introduces advanced topics like property delegation choices and Java interoperability. - **Late (~52%–end)**: Covers reflection, annotation processing with KSP, and generating wrapper classes. The book closes with a large set of solutions (from ~218 onward) covering functional quicksort, powerset, DSLs, scope functions, and flow utilities. 【Key Takeaways】 - **Exercises are the core learning mechanism** (Opening): Each concept is introduced through a concrete coding task with starting code, example usage, and unit tests, making the book a workbook rather than a reference. - **Progressive difficulty from essentials to advanced** (Early–Middle): The book moves from `when` expressions and nullability to coroutines, flows, and annotation processing, so readers can grow with the material. - **Coroutines and flows get substantial coverage** (Middle): Topics include context propagation, dispatchers, cancellation mistakes, testing, and flow operators—practical skills for modern Kotlin development. - **Functional programming is taught through real refactoring** (Early): Exercises like optimizing collection processing and refactoring Java-style loops into Kotlin collection functions teach idiomatic style. - **Advanced topics include reflection and KSP** (Late): Readers implement a function caller via reflection and an annotation processor that generates a measured wrapper class, bridging Kotlin with Java tooling. - **Solutions are provided for every exercise** (Late): The book includes a full solutions section, enabling self-study and verification without external help. - **GitHub project integration** (Throughout): Starting code and unit tests are available in the `MarcinMoskala/kotlin-exercises` repository, encouraging local practice. 【Reading Tips】 - **Skim the essentials if you're already comfortable** (Opening): If you know Kotlin basics, jump to the functional and coroutine sections where the real challenge lies. - **Deep-read the coroutine and flow chapters** (Middle): These are the most complex and practically valuable parts; work through the cancellation and testing exercises carefully. - **Use the GitHub repo alongside the book**: Clone the project and solve exercises locally with unit tests to get immediate feedback. - **Don't skip the solutions section**: Compare your approach with the provided solutions, especially for recursive and functional problems. - **Treat advanced topics as optional stretch goals**: Reflection and KSP are niche; tackle them if you need that specific skill. 【Coverage Limits】 The excerpts cover the table of contents and a sample of exercises from the opening through the middle, plus some advanced topics. The full solutions section and later chapters are only partially represented, so this guide may not capture every exercise or nuance.
Page 13
e -> "No idea, really" } fun main() { println(name(1)) // ? println(name("A")) // ? println(name(null)) // ? println(name(5)) // ? println(name(100)) // ? pr...
View in text
Excerpt 2
or this code to use Kotlin collection processing functions. The function is responsible for finding the best students for internships. This is what is looks...
View in text
Excerpt 3
userSettings = readUserSettings(user.id) // blocking try { updateUserInDatabase(user, userSettings) // suspending } catch (e: CancellationException) { revert...
View in text
Excerpt 4
ge and unit tests can be found in the MarcinMoskala/kotlin- exercises project on GitHub in the file advanced/reflection/FunctionCaller.kt. You can clone this...
View in text
Excerpt 5
olve this exercise locally. 171 measureTimeMillis { service.observeUpdates( filter = filter, tickers = tickers.take(70) ).take(1_000) .collect { println(it)...
View in text
Excerpt 6
nes to fit the page. In real code, I would not do that. 230 Solution: Factorial sequence val factorial: Sequence<BigInteger> = sequence { var i = BigInteger....
View in text
Excerpt 7
est fun `should collect exceptions from all coroutines`() { val fakeNotificationsClient = FakeNotificationClient( delayTime = 100, failEvery = 10 ) val fakeE...
View in text
Excerpt 8
nextInt(100) == 1) Float.NaN else \ (0..100).random(random).toFloat(), if (random.nextInt(100) == 1) -1 else (0..100\ ).random(random), if (random.nextInt(10...
View in text
Tags
AI categories
Programming LanguageKotlinEducation
Publisher: Leanpub
Publish Year: 2024
Language: English
Pages: 351
File Format: PDF
File Size: 1.7 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…