Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lmller/gof-in-kotlin

Gang of Four patterns in Kotlin.
https://github.com/lmller/gof-in-kotlin

kotlin patterns

Last synced: about 2 months ago
JSON representation

Gang of Four patterns in Kotlin.

Awesome Lists containing this project

README

        

![pull requests welcome](https://img.shields.io/badge/pull_requests-welcome-green.svg)

#### Gang of Four patterns in Kotlin.

Inspired by https://github.com/mariofusco/from-gof-to-lambda

Blog posts:
- Part 1: https://dev.to/lovis/gang-of-four-patterns-in-kotlin
- Part 2: https://dev.to/lovis/gang-of-four-patterns-in-kotlin---slight-return

Watch me talk about it: https://youtu.be/xxGCVVtMVn4 (2018 @code.talks hamburg)

| Pattern | Kotlin |
| --- | --- |
| Builder | `apply` function / named constructor parameters |
| Decorator | Extension Functions / function composition |
| Interpreter | `sealed` classes |
| Iterator | operator functions |
| Observer | observable delegate |
| Prototype | Data class |
| Singleton | `object` declaration |
| Strategy | functions |
| Template Method | (top-level) functions |
| Visitor | Pattern Matching / `when` |

ℹ️ If you import the project into intelliJ, make sure to **un**check "Create separate module per source set"!