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

Recursive Architecture

Recursive Architecture

Josh Comer

June 04, 2016
Tweet

More Decks by Josh Comer

Other Decks in Programming

Transcript

  1. Recursions 101 Definition: see recursion Real Definition: the repeated application

    of a procedure or definition Two mirrors, fractals, etc.
  2. CS Recursion Everyone’s favourite topic in school Remember recursion ==

    iteration Fib(n) = Fib(n-1) + Fib(n-2), Fib(0)=0, Fib(1)=1 Fib is interesting case as naïve recursion leads to O(phi^n) while naïve iteration is O(n), though easy to fix.
  3. Quicksort Divide and Conquer (defn qsort3 [[pivot :as coll]] (when

    pivot (lazy-cat (qsort (filter #(< % pivot) coll)) (filter #{pivot} coll) (qsort (filter #(> % pivot) coll)))))
  4. So what’s the big deal Recursion is pure Recursion is

    clean Recursion is terse The barrier to solving a problem recursively usually means the solution has been thought through
  5. Conway’s Law organizations which design systems ... are constrained to

    produce designs which are copies of the communication structures of these organizations — M. Conway
  6. BDD

  7. Blog Driven Development Someone who is greatly influenced by reading

    a single blog post… daily ...and then changes all the code
  8. Stack Overflow Driven Development Someone who codes exclusively using Stack

    Overflow answers. I’m a SODD with bash ☺️
  9. But… Patterns all start to fall apart if everyone isn’t

    on the same page. Not everyone has the GoF book memorized
  10. Concurrency The next frontier in programing: Vertical Scaling won’t work

    anymore But concurrent programming is hard for even the best programmers Abstract away the concurrency!!! - Joe Armstrong
  11. OO Architecture Design from the abstraction towards the problem Good

    OO design requires a lot of upfront effort Distracts from the problem Harder to change (we don’t always get it right the first time)
  12. Recursive Architecture Conway’s Law We are, seemingly, naturally good at

    reasoning about systems in the large Distributed Systems are becoming the new norm
  13. Where is the recursive part? We can design our services

    using the same primitives as our platform The inside mirrors the outside
  14. TSAP We need to make something that allows us to

    store tasks in a list (sorted temporally). In addition to the task list, we want to be able to schedule actions at particular times.
  15. Building Blocks There are three main building blocks: API Servers

    -> Gen-Server Processes -> Actor Pub-Sub -> Gen-Event Supervisors Gen-FSM It’s the Erlang OTP Behaviours
  16. API Servers are key AXD301 (one of the biggest Erlang

    code bases) uses gen- servers for 63% of its behaviours APIs allow us to hide execution particulars (think façade pattern)
  17. “You know nothing API Snow” An API can hide concurrency

    (it acts as a load balancer) An API can make asynchronous calls synchronous An API can provide a translation layer An API can handle errors An API can manage resiliency
  18. Isn’t this an Interface? Not quite The API is an

    active piece of code that contains control logic For example gen-server has fns for: Sync Call Async Call Timeout Shutdown and Startup
  19. Microservices Let’s call them nanoservices Even smaller than microservices Responsible

    for an extremely small portion of logic Built to be deployed in a shared resource environment with other nanoservices
  20. Is this even a thing? Actors! Actors are back Erlang

    is making a comeback (check out Elixir) Akka or Quasar for Java Akka.net for .NET
  21. Fin