Building Kotlin Applications: A comprehensive guide for Android, Web, and Server-Side Development

Building Kotlin Applications: A comprehensive guide for Android, Web, and Server-Side Development

Building Kotlin Applications: A comprehensive guide for Android, Web, and Server-Side Development
Автор: Boussetta Mounir
Дата выхода: 2024
Издательство: BPB Publications
Количество страниц: 582
Размер файла: 2,2 МБ
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы

Cover
Title Page
Copyright Page
Dedication Page
About the Author
About the Reviewer
Acknowledgement
Preface
Table of Contents
1. Java and Kotlin
Introduction
Structure
Objectives
Overview
History of Kotlin
Who is behind Kotlin, and when did it appear?
Why Kotlin?
What is Kotlin?
The name Kotlin
Kotlin versus Java
Kotlin
Advantages
Disadvantages
Java
Advantages
Disadvantages
Next in Kotlin
Conclusion
Points to remember
2. Kotlin Basics
Introduction
Structure
Objectives
Overview
Variables
Declaration and initialization
Types and cast
Integer types
Floating-point types
Numbers representation on the JVM
Character
String
String functions
Boolean
Arrays
Null safety
Creating functions
Creating and using a function
Function arguments
Variable number of arguments (varargs)
Choices and conditions
if/else-if/else
when
Loops
repeat
for loop
while and do .. while loops
Returns and jumps
Return
Break
Continue
Smart cast with Kotlin
Work with extensions
Extension functions
Extension properties
Overloading operators
Handle exceptions
Conclusion
Points to remember
3. OOP with Kotlin
Introduction
Structure
Objectives
Overview
Classes and objects
Kotlin class
Objects
Inheritance
Inheritance in Kotlin
Overriding parent class methods
Abstract classes
Properties
Getters and setters
Backing fields
Interfaces
Properties in interfaces
Interfaces inheritance
Visibility modifiers
Packages
Class and interface visibility modifiers
Types of classes
Simple class
Open class
Data class
Nested class
Inner class
Sealed class
Delegation
Type aliases
Conclusion
Points to remember
4. Generics
Introduction
Structure
Objectives
Overview
Generics
Generic classes
Generic advantages
Generic functions
Generic constraints
Upper bound constraint
Type erasure
Variance
Declaration-site variance
out keyword
in keyword
Use-site variance: type projection
Reified-type parameters
Type reification
Type checking and type casting
Conclusion
Points to remember
5. Annotations and Reflection
Introduction
Structure
Objectives
Overview
Annotations
Usage
Define custom annotation
Annotation constructor
Instantiation
Use-site target
Reflection
JVM reflection dependency
Serialization and deserialization
Serialization
Deserialization
Conclusion
Points to remember
6. Functional Programming with Kotlin and RxKotlin
Introduction
Structure
Objectives
Overview
Introduction to reactive programming
Why adopt a functional reactive programming paradigm?
Reactive Manifesto: reactive principles
Lambda expression
Declaring a lambda
Lambda type declaration
Pure function
Higher-order functions
Inline functions
noinline
Polymorphic functions
Functional data structures
Definition and declaration of the singly linked list data structure
Handling errors
Conclusion
Points to remember
7. Observables, Observers, and Subjects
Introduction
Structure
Objectives
Overview
How do observables work?
Observable factory methods
Subjects
BehaviorSubject
PublishSubject
ReplaySubject
Conclusion
Points to remember
8. Flowables and Backpressure
Introduction
Structure
Objectives
Overview
Flowables and observables
Difference between observables and flowables
When to use flowables and not observables?
Flowable from observable
Backpressure
Flowable with backpressure
Conclusion
Points to remember
9. Data Transformers and Async Operators
Introduction
Structure
Objectives
Overview
Rx-operators
Filtering operators
Transforming operators
Reducing operators
Processors
Grouping operators
Mapping operators
Error handling
Example
Conclusion
Points to remember
10. Concurrency and Parallel Processing
Introduction
Structure
Objectives
Overview
Concurrency
Schedulers
Schedulers with subscribeOn and observeOn
Conclusion
Points to remember
11. Testing Reactive Applications
Introduction
Structure
Objectives
Overview
Importance of unit testing
JUnit tests
Setting up Junit
Writing your first JUnit test
Using assertions
Writing tests for reactive applications
RxKotlin testing
Observables
Operators
Subjects
TestSubscriber
TestScheduler
TestObserver
Conclusion
Points to remember
12. Spring Reactive for Kotlin
Introduction
Structure
Objectives
Overview
Introduction to Spring Boot
Overview of Spring framework
Key features of Spring Boot
Support of reactive programming
Gradle
Getting started with Spring Boot
Spring Boot and the n-tier architecture
Creating a basic Spring Boot application
Flux and Mono
Spring Data Reactive
Conclusion
Points to remember
13. Asynchronous Programming and Coroutines
Introduction
Structure
Objectives
Overview
Why multithreading?
Reason behind multithreading use
Challenges
Solutions
Use thread-safe data structures and synchronization mechanisms
Use atomic operations
Use thread pools
Use message passing
Use profiling and debugging tools
Handling work completion using callbacks
Asynchronous programming
Asynchronous file I/O using CompletableFuture
Understanding coroutines
Jobs
UI threads
Conclusion
Points to remember
14. Suspending Functions and Async/Await
Introduction
Structure
Objectives
Overview
Suspending versus non-suspending
Non-suspending functions
Suspending functions
Some real-world examples
Creating suspendable API
Understanding suspendable APIs
Advantages of suspendable APIs
Thread safety
Testing and debugging
Async/await
Understanding Async/Await
Benefits of async/await
Deferred values
Creating a Deferred value
Error handling with Deferred values
Combination of deferred values
Conclusion
Points to remember
15. Contexts and Dispatchers
Introduction
Structure
Objectives
Overview
Task scheduling
Understanding coroutine scheduling and execution flow
Coroutine contexts and their role in determining the execution context
Coroutine builders and their impact on scheduling
Dispatcher’s types
Dispatchers.Default
Dispatchers.IO
Dispatchers.Main
Dispatchers.Unconfined
Exception propagation and its handling
Coroutine cancellation
Coroutine cancellation is cooperative
How to cancel a coroutine?
Manage cancellation
Using a try-catch block
Using a finally block
Conclusion
Points to remember
16. Coroutines Channels
Introduction
Structure
Objectives
Overview
Generators and sequences
Pipelines
Send and offer (trySend)
Receive and poll (tryReceive)
Channels versus Java queues
Broadcast channels
Producers and actors
Conclusion
Points to remember
17. Coroutine Flows
Introduction
Structure
Objectives
Overview
Data streams
Streams limitations
Handling backpressure and cancellation
Backpressure
Cancellation
Inefficient resource utilization
The need for a coroutine flows approach
Flows constraints
Conclusion
Points to remember
18. Multiplatform and Kotlin
Introduction
Structure
Objectives
Overview
Setting up the development environment
Creating a simple Android application with Jetpack Compose
Setting up the Compose multiplatform project structure
Setting up the common module
Setting up the Android module
Setting up the desktop module
Todo app in Compose Multiplatform
Conclusion
Points to remember
Index

Kotlin is a modern, expressive, and concise programming language popular among developers for its many benefits. These include its interoperability with Java, ability to build native mobile and web applications, and support for functional programming.
This book provides a comprehensive introduction to Kotlin, covering everything you need to know to start building Kotlin applications, regardless of your prior programming experience.
You'll start by learning the basics of Kotlin, including its variables, types, functions, and control flow statements. Then, you'll explore more advanced topics such as object-oriented programming, generics, coroutines, RxKotlin, and multiplatform development. Once you have a solid foundation in Kotlin, you'll learn how to use it to build real-world applications. You'll start with a simple Android application and then move on to more complex projects, such as a web application and a desktop application.
By the end of this book, you will have a deep understanding of Kotlin and be confident in your ability to use it to build robust, maintainable, and scalable applications.

What you will learn

  • Learn Kotlin syntax, type system, and basic concepts to write idiomatic, expressive, and safe code.
  • Build robust and scalable applications using Kotlin, including web, mobile, and desktop applications. Use reactive patterns and frameworks such as Spring Boot to design highly scalable and resilient applications.
  • Apply best practices and design patterns to write maintainable and reusable code.
  • Write code that is reliable and easy to maintain.
  • Become a more productive and efficient programmer.

Who this book is for

Building Kotlin Applications is for anyone who wants to learn how to build modern and scalable applications with Kotlin. Whether you are a software engineer, mobile developer, web developer, or student, this book will teach you everything you need to know to get started with Kotlin.


Похожее:

Список отзывов:

Нет отзывов к книге.