filmov
tv
From Objects to Functions by Uberto Barbini
Показать описание
Using exceptions to recover from errors in our programs goes against the principle of functional programming because it will prevent us from defining the logic composing pure functions since an Exception cannot be a valid return value for a pure function.
In this talk, I'll present some possible techniques to handle errors differently and, arguably, make our code easier to read and maintain.
Functional programming also allows us to centralize the logic to log significant events with their context. Instead of using simple string messages scattered along our code, we can define more specific domain events and log them with the full context of the error, removing the need to configure log levels.
The example code presented is in Kotlin, but applying the same techniques in Java or other languages should be easy.
Uberto Barbini
Uberto is a polyglot programmer with more than 20 years of experience designing and building successful software products in (too) many industries.
He discovered his love for programming when he wrote a video game on the ZxSpectrum in the 8-bit era. He is still very passionate about writing the best code to deliver value to the business, in the shortest time, and not only once but at a regular pace.
------------------------------------------------------------
INTRO
* visuals & editing by @Mercator
* music : Avocado by Ephixa
Комментарии