Design Patterns in Kotlin: 23 Classic Templates
300 pages
English
PDF
4.5

Design Patterns in Kotlin: 23 Classic Templates

Design Patterns in Kotlin: 23 Classic Templates

Author:

Year:

Summary:

This book is a practical guide to applying 23 classic design patterns (GoF) in the Kotlin language. Unlike abstract theoretical descriptions, the author offers concrete implementations of each pattern, leveraging the capabilities of modern Kotlin: extension functions, lambdas, sealed classes, coroutines, and null-safety.



The book is structured from simple to complex and covers all three groups of patterns:

  • Creational Patterns — Singleton, Factory Method, Abstract Factory, Builder, Prototype. Special attention is given to implementing Builder via Kotlin DSL constructs.
  • Structural Patterns — Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy. It shows how Kotlin delegates simplify the implementation of Decorator and Proxy.
  • Behavioral Patterns — Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor. The use of coroutines for implementing asynchronous versions of patterns is discussed in detail.


Who this book is for:

  • Kotlin developers transitioning from Java who want to write more concise and safe code
  • Backend engineers working with Spring Boot and Ktor
  • Team Leads responsible for microservice architecture
  • Students and novice developers learning Kotlin


What you will learn:

  • How to adapt classic patterns to Kotlin's functional capabilities
  • Practical examples from real projects: from simple utilities to microservice architecture
  • How to combine patterns to solve complex problems
  • Common mistakes and anti-patterns when implementing templates in Kotlin
  • How to use coroutines and Flow together with behavioral patterns


Each chapter contains complete Kotlin code, UML diagrams (PlantUML), tests, and a section "When to apply and when not to." At the end of the book, there is a checklist for choosing a pattern for a specific task.



The book is suitable both for learning from scratch and for use as a reference during development.

Recommendations