Applying the State Pattern in Kotlin

Опубликовано: 01 Январь 1970
на канале: Dave Leeds
5,350
423

When our objects behave differently in different states, then it can be helpful to apply the State Pattern. Today, we'll look at code that could benefit from the State Pattern, we'll apply a traditional State Pattern from the classic Gang of Four Design Patterns book, and then we'll see how we can modernize it and reduce boilerplate by using some of Kotlin's language features.

✨ New to Kotlin? Start your journey here: https://typealias.com/start/
... or pick up the new Leanpub Edition for offline access and more! https://book.typealias.com/

🚀 Get the inside scoop on everything I'm working on - join my new email newsletter!
Sign up here: https://newsletter.typealias.com/

📺 Watch Episode #1 of the TypeAlias Show Livestream:
https://youtube.com/live/S_JKbmN_A8o

📚 Chapters
00:00 Introduction
00:16 Example Code
02:16 Classic State Pattern
06:50 Modernized State Pattern in Kotlin
11:58 Wrap-up

Correction:

11:03 Inside the `println()` on line 13, I should have printed `$it` instead of `$email`.


Смотрите видео Applying the State Pattern in Kotlin онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Dave Leeds 01 Январь 1970, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 5,35 раз и оно понравилось 42 людям.