<span><p><b>Improve the scalability and maintainability of your applications by implementing a variety of design patterns using Kotlin</b></p><h4>Key Features</h4><ul><li>Understand traditional and modern design patterns to improve the design of your application</li><li>Combine the benefits of objec
Kotlin Design Patterns and Best Practices: Build scalable applications using traditional, reactive, and concurrent design patterns in Kotlin, 2nd Edition
β Scribed by Alexey Soshin
- Publisher
- Packt Publishing
- Year
- 2022
- Tongue
- English
- Leaves
- 356
- Edition
- 2
- Category
- Library
No coin nor oath required. For personal study only.
β¦ Synopsis
Improve the scalability and maintainability of your applications by implementing a variety of design patterns using Kotlin Design patterns are well-known solutions to common architectural problems as they allow you to solve many problems efficiently and create a shared vocabulary between developers. This book shows you how easy it can be to implement traditional design patterns in the modern multi-paradigm Kotlin programming language, and takes you through the new patterns and paradigms that have emerged. This second edition is updated to cover the changes introduced from Kotlin 1.2 up to 1.5 and focuses more on the idiomatic usage of coroutines, which have become a stable language feature. You'll begin by learning about the practical aspects of smarter coding in Kotlin, and will understand basic Kotlin syntax and the impact of design patterns on your code. The book also provides an in-depth explanation of the classical design patterns, such as Creational, Structural, and Behavioral families, before moving on to functional programming. You'll go through reactive and concurrent patterns, and finally, get to grips with coroutines and structured concurrency to write performant, extensible, and maintainable code. By the end of this Kotlin book, you'll have explored the latest trends in architecture and design patterns for microservices, as well as understanding the tradeoffs when choosing between different architectures. This book is for developers looking to apply design patterns they've learned from other languages in Kotlin to build reliable, scalable, and maintainable applications. Prior programming knowledge is necessary to get started with this book. Experience in Java or design patterns is helpful, but not mandatory.Key Features
Book Description
What you will learn
Who this book is for
Table of Contents
β¦ Table of Contents
Cover
Title page
Copyright and Credits
Dedications
Foreword
Contributors
Table of Contents
Preface
Section 1: Classical Patterns
Chapter 1: Getting Started with Kotlin
Technical requirements
Basic language syntax and features
Multi-paradigm language
Understanding Kotlin code structure
Naming conventions
Packages
Comments
Hello Kotlin
Understanding types
Basic types
Type inference
Values
Comparison and equality
Declaring functions
Null safety
Reviewing Kotlin data structures
Lists
Sets
Maps
Mutability
Alternative implementations for collections
Arrays
Control flow
The if expression
The when expression
Working with text
String interpolation
Multiline strings
Loops
for-each loop
The for loop
The while loop
Classes and inheritance
Classes
Interfaces
Abstract classes
Visibility modifiers
Inheritance
Data classes
Extension functions
Introduction to design patterns
What are design patterns?
Why use design patterns in Kotlin?
Summary
Questions
Chapter 2: Working with Creational Patterns
Technical requirements
Singleton
Factory Method
Static Factory Method
Abstract Factory
Casts
Subclassing
Smart casts
Variable shadowing
Collection of Factory Methods
Builder
Fluent setters
Default arguments
Prototype
Starting from a prototype
Summary
Questions
Chapter 3: Understanding Structural Patterns
Technical requirements
Decorator
Enhancing a class
The Elvis operator
The inheritance problem
Operator overloading
Caveats of the Decorator design pattern
Adapter
Adapting existing code
Adapters in the real world
Caveats of using adapters
Bridge
Bridging changes
Type aliasing
Constants
Composite
Secondary constructors
The varargs keyword
Nesting composites
Facade
Flyweight
Being conservative
Saving memory
Caveats of the Flyweight design pattern
Proxy
Lazy delegation
Summary
Questions
Chapter 4: Getting Familiar with Behavioral Patterns
Technical requirements
Strategy
Fruit arsenal
Citizen functions
Iterator
State
Fifty shades of State
State of the nation
Command
Undoing commands
Chain of Responsibility
Interpreter
We need to go deeper
A language of your own
Call suffix
Mediator
The middleman
Mediator flavors
Mediator caveats
Memento
Visitor
Writing a crawler
Template method
Observer
Animal choir example
Summary
Questions
Section 2: Reactive and Concurrent Patterns
Chapter 5: Introducing Functional Programming
Technical requirements
Reasoning behind the functional approach
Immutability
Immutable collections
The problem with shared mutable state
Tuples
Functions as values
Learning about higher-order functions
Higher-order functions in a standard library
The it notation
Closures
Pure functions
Currying
Memoization
Using expressions instead of statements
Pattern matching
Recursion
Summary
Questions
Chapter 6: Threads and Coroutines
Technical requirements
Looking deeper into threads
Thread safety
Why are threads expensive?
Introducing coroutines
Starting coroutines
Jobs
Coroutines under the hood
Setting timeouts
Dispatchers
Structured concurrency
Summary
Questions
Chapter 7: Controlling the Data Flow
Technical requirements
Reactive principles
Responsive principle
Resilient principle
Elastic principle
Message-driven principle
Higher-order functions on collections
Mapping elements
Filtering elements
Finding elements
Executing code for each element
Summing up elements
Getting rid of nesting
Exploring concurrent data structures
Sequences
Channels
Flows
Summary
Questions
Chapter 8: Designing for Concurrency
Technical requirements
Deferred Value
Barrier
Using data classes as barriers
Scheduler
Creating your own schedulers
Pipeline
Composing a pipeline
Fan Out
Fan In
Racing
Unbiased select
Mutex
Sidekick channel
Summary
Questions
Section 3: Practical Application of Design Patterns
Chapter 9: Idioms and Anti-Patterns
Technical requirements
Using the scope functions
Let function
Apply function
Also function
Run function
With function
Type checks and casts
An alternative to the try-with-resources statement
Inline functions
Implementing Algebraic Data Types
Reified generics
Using constants efficiently
Constructor overload
Dealing with nulls
Making asynchronicity explicit
Validating input
Preferring sealed classes over enums
Summary
Questions
Chapter 10: Concurrent Microservices with Ktor
Technical requirements
Getting started with Ktor
Routing requests
Testing the service
Modularizing the application
Connecting to a database
Creating new entities
Making the tests consistent
Fetching entities
Organizing routes in Ktor
Achieving concurrency in Ktor
Summary
Questions
Chapter 11: Reactive Microservices with Vert.x
Technical requirements
Getting started with Vert.x
Routing in Vert.x
Verticles
Handling requests
Subrouting the requests
Testing Vert.x applications
Working with databases
Managing configuration
Understanding Event Loop
Communicating with Event Bus
Sending JSON over Event Bus
Summary
Questions
Assessments
Index
About Packt
Other Books You May Enjoy
π SIMILAR VOLUMES
<p><b>Make the most of Kotlin by leveraging design patterns and best practices to build scalable and high performing apps</b><p><b>About This Book</b><p><li>Understand traditional GOF design patterns to apply generic solutions<li>Shift from OOP to FP; covering reactive and concurrent patterns in a s
Design patterns enable you as a developer to speed up the development process by providing you with proven development paradigms. Reusing design patterns helps prevent complex issues that can cause major problems, improves your code base, promotes code reuse, and makes an architecture more robust.
ive deep into Kotlin design patterns, explore idiomatic functional programming, and master microservices with frameworks like Arrow, Ktor, and Vert.x. Key Features Start from basic Kotlin syntax and go all the way to advanced topics like Coroutines and structural concurrency Learn how to select
<p><b>Get the deep insights you need to master efficient architectural design considerations and solve common design problems in your enterprise applications.</b><p><b>Key Features</b><p><li>The benefits and applicability of using different design patterns in JAVA EE<li>Learn best practices to solve