Upgrade to Pro — share decks privately, control downloads, hide ads and more …

I can haz no Futures?

I can haz no Futures?

You will learn how simple functional patterns can be used to make your business logic cleaner and more testable.

Asynchronous programming brings a lot of Futures to your code. Bad news is that they are not essential to what your application really does… You end up with Futures of assertions in your unit tests or, even worse, with Await or expectNoMsg calls.

This is a live coding talk. First I will code an application using Futures in both business logic and unit tests. Then I will get rid of Futures without losing asynchronicity. In the second part, I will do a step by step refactoring of a simple Akka actor system. In both cases I will use typeclasses from Cats library.

Michał Płachta

November 09, 2016
Tweet

More Decks by Michał Płachta

Other Decks in Programming

Transcript

  1. Complexity is the root cause of the vast majority of

    problems with software today. “
  2. Essential ▪ The “heart” of your system ▪ The WHAT

    Complexity Accidental ▪ The least important part of your system ▪ The HOW and WHEN
  3. Future[Option[Customer]] Here’s a return type of a function in a

    CRM system... QUIZ Accidental Complexity Essential Complexity
  4. “ We have to keep it crisp, disentangled, and simple

    if we refused to be crushed by the complexities of our own making… Portrait by Hamilton Richards - manuscripts of Edsger W. Dijkstra, University Texas at Austin, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=4204157
  5. Palindrome Checker Actor Length Calculator Actor String Stats Calculator Actor

    def stringStats(String): Future[StringStats] External Stuff We Can’t Touch LIVE CODING #2