Skip to content

Instantly share code, notes, and snippets.

@jamesgary
Created April 29, 2013 22:31
Show Gist options
  • Save jamesgary/5485331 to your computer and use it in GitHub Desktop.
Save jamesgary/5485331 to your computer and use it in GitHub Desktop.
Object-Oriented Lessons for a Service-Oriented World - Chris Kelly (@amateurhuman) - RailsConf 2013

Object-Oriented Lessons for a Service-Oriented World

Chris Kelly (@amateurhuman)

  • Works for New Relic as Happiness Engineer

  • These aren't hard principles, mostly ideas for now

  • Monorail - Monolithic Rails App

  • Network-based application software instead of SOA

  • (not necessarily building 'service')

  • Monorail (which is a mess) <-> Cache <-> Database

  • Your app is a special snowflake that breaks every time something changes.

    • Apt metaphor: Crystaline architecture shatters when a small thing changes
    • Lots of dependencies & coupling
  • Object: mostly behavior, some state

  • Passing messages back and forth

  • We want something more modular: Outside world <-> Behavior <-> State

    • Instead of OW <-> Behavior AND OW <-> State
  • We're talking about REST when we talk about http apps as objects

  • Lotsa good OO principles

    • Single Responsibility
      • Do the smallest thing possible, and nothing more.
      • Cohesive: everything it does should be related to its purpose
    • DRY
      • Where does knowledge exist?
    • Depend on behavior, not state/data
    • Dependency Inversion
    • Law of Demeter
    • Dependency Injection
  • Cache is King

  • In OO, classes are nouns, and our messages are often verbs

  • HTTP has CRUDdy verbs

  • But if we stick to those, we're stuck to just those handful of HTTP actions

  • What about hypermedia?

  • It's a series of constraints built on top of REST

  • This ain't your Rails' REST

  • Hypermedia combines Media Type and link relations

  • (Examples...)

    • Contains behavior (links point to self, next, find) and state (_embedded has the data AND more links)
  • See github's hypermedia...

  • The Good: Link relations are already appearing in media types

  • The Bad: You can implement custom media types

  • The Ugly: The necessary HTTP verb is a missing

  • Hypermedia is like self-documenting API, no need to worry about versioning

  • It's a behaviorial API

  • NOTE TO SELF: Look into this shit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment