Загрузка...

Functional Kotlin - Conjuring Functions

Today we implement conjured items, which change in quality twice as quickly. This might have been easy, but for the store owner wanting to conjure already non-standard items. Luckily our items types are just functions, and we can compose functions, so we can compose item types. Functional Kotlin for the win!

I honestly didn't plan ahead to make this work so easily, although it is true that I put the idea of conjuring non-standard items to the owner. If you are an OO programmer used to mutating objects, it's worth considering how hard it would have been to implement this functionality with a mutable ItemType - composition and non-destructive edits definately combine to more than the sum of their parts here.

Part 22 of an exploration of where a Test Driven Development implementation of the Gilded Rose stock control system might take us in Kotlin. You can see the whole series as a playlist https://www.youtube.com/playlist?list=PL1ssMPpyqociJNwykAOB9_KEZVW7BW7m2 and the code on GitHub https://github.com/dmcg/gilded-rose-tdd

If you like this, you’ll probably like the book Java to Kotlin, A Refactoring Guidebook http://java-to-kotlin.dev. Composing functions is covered

Видео Functional Kotlin - Conjuring Functions канала Pairing with Duncan
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять