Leaving side effects aside: the quest for functional purity and the perils of object-orientation
Believe it or not, side effects are behind most of the software headaches you suffer at work: if you can't easily reuse, test, optimize, compose, or understand some piece of software, chances are that it's contaminated with side effects, i.e., that it's not made of pure functions. Yet we may think of side effects as necessary evil, since calls to the database, web server, logger, tracker, etc., have to be placed somewhere in your code.
So, the problem we face as designers can't be their full removal, but their maximum isolation. In this talk we compare how effective functional and object-oriented patterns are in this segregation or purification process. We show how functional abstractions allow us to extend the realm of purity in our code, far beyond what we can achieve with object orientation. We show how easy we can do that using Scala and the scalaz library, and explain in simple terms the role that monads play in this process. Last, we argue that no matter how hard you try with maps, flatmaps, filters, immutable values, and so forth, if side effects are not properly tamed, you won't get the benefits of functional programming: you won't be able to easily accommodate changes in the way your effects are executed (e.g. asynchronism, NoSQL persistence), perform mock-free unit testing, keep business logic strictly decoupled from non-functional concerns, etc., etc.
Slides:
https://docs.google.com/presentation/d/1RsCnD7tVOxlCrhpqbdmqpksHs7vHstpgVxEIxvSnl1Y/edit