ClojureWest 2013: Day One Notes

Domain Driven Design in Clojure: Amit Rathore

  • read the book from eric evans
  • Lot of oop design principles carry over
  • shoot for 3-4 lines of clojure code per function
  • validateur, bouncer, clj-schema (validation)
  • if code confusing, demand simplification
  • make temp namespaces explicit: zolo.homeless
  • domain: business-important logic, not the API, not services, not validation, not talking to the db, just the stuff business people care about; should be pure
  • if you don't need it now, don't build it

RESTful Clojure: Siva Jagadeesan

  • liberator, bishop: libraries to help build proper REST APIs in clojure
  • use the status codes: 1xx - Metadata, 2xx - success, 3xx - redirect, 4xx - client error, 5xx - server error
  • 405: method not allowed
  • 409: conflict
  • 404: resource not present
  • create returns Location header with location of new resource, in addition to the 201 (created) status code
  • even better: also return a set of links to related resource (rel = self) and transitions (rel = cancel)
  • allows client to be loosely coupled from API
  • client doesn't need to know how resources move through the system (transition logic)
  • REST means using multiple URIs, HTTP status codes, and Hypermedia

Clojure in the Large: Stuart Sierra

  • def'ing refs and atoms at the top level is basically global mutable state via singletons, please avoid
  • recommend using constructor functions to *return* the state variables you want to use, then pass that state along to each function
  • easier to test
  • explicit dependencies
  • safe to reload when working at the repl
  • thread-bound state also bad: assumes no lazy sequence returned in function bodies, hides dependencies, and limits caller to using one resource at a time
  • prefer passing context around to functions
  • can pull resources out of it
  • use namespace-qualified keys for isolation
  • isn't confined to a single thread
  • still need to cleanup at the end
  • more bookkeeping
  • true constants are fine as global vars (^:const)

Pedestal: Architecture and Services: Tim Ewald

  • alpha release from relevance of open-source libs
  • use clojure end-to-end to build RIAs
  • demo: hammock cafe: clojurescript apps communicating to same back-end using datomic store
  • 2 halves: pedestal-service, pedestal-app
  • ring limits: bound to a single thread's stack
  • interceptors: map of functions, has enter and leave for processing requests and responses
  • can pause and resume along any thread
  • pushed to be as ring-compatible as possible
  • use of long polling and server-side events (requests that come in slow and last a long time, get updated as more data comes in)

Design, Composition, and Performance: Rich Hickey

  • take things apart
  • design like bartok (embrace constraints, use harmonic sense)
  • code like coltrane (constant practice, keep harmonic sense)
  • build libraries like instruments (design for players, able to be combined with other things)
  • pursue harmony
Ron Toland @mindbat