From Objects to Functions by Uberto Barbini

preview_player
Показать описание

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
Рекомендации по теме
Комментарии
Автор

Thanks for the video Uberto, I love that you are sharing the things you learn from concrete experience. The advice around logs is solid gold! In my last project we had a different approach, we logged everything that went well and we logged it to DB tables, because it was a very useful tool for business people to debug transactions that didn't go well from a domain POV. In this case, logging was a requirement not just a debugging tool for engineers

MatteoVaccari