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.

6f6dc1b13fd3fe35d36db3adafcb0c8e?s=128

Michał Płachta

November 09, 2016
Tweet

Transcript

  1. I can haz no Futures? Michał Płachta @miciek

  2. The Journey Ahead of Us WHY? REFACTORING ACTOR SYSTEM REFACTORING

    ADD FUNCTION
  3. Complexity is the root cause of the vast majority of

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

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

    CRM system... QUIZ Accidental Complexity Essential Complexity
  6. “ 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
  7. Managing Complexity Live coding examples

  8. def add(Int, Future[Int]): Future[Int] Let’s start with a very simple

    case... LIVE CODING #1
  9. Palindrome Checker Actor Length Calculator Actor String Stats Calculator Actor

    def stringStats(String): Future[StringStats] External Stuff We Can’t Touch LIVE CODING #2
  10. ANY QUESTIONS? @miciek www.michalplachta.com/contact Thanks!