Clojure WebDevelopment   OnyCloud     江宏
Example - Trakrhttps://trakrapp.com/Web-based project management systemA product created for our own needsRequirements  Fe...
Demo
Architecture                                    MongoDB                                    (Log &                         ...
HTTP Server Structure  Ring    Middleware      Handlers    The Compojure Framework
RoutesMapping: Request -> Handler:(defroutes app-routes  (context "/users" []    (GET "/new" [] accounts/show-signup)    (...
HandlersRequest in, response out.(defn say-hello [req]  (let [name (-> req :params :name)]    {:status 200     :body (str ...
MiddlewareTransform: Handler -> New Handler(defn wrap-failsafe [handler]  (fn [request]    (try (handler request)      (ca...
TestingUnit testing with clojure.test andclojure.contrib.mockIntegration testing using WatirDemo
PerformanceNo optimization tricks (type hints, transients,etc.)Average latency ~ 70msLong tailDatabase performance can be ...
Lessons LearnedGood:  High productivity  Easy to test (dynamic binding)  Relatively easy learning curve
Lessons LearnedBad:  Ugly stacktraces.  Exposes too much Java class hierarchy.  PersistentMap, PersistentStructMap,  struc...
Thank You
Upcoming SlideShare
Loading in …5
×

Clojure Web Development

3,692 views

Published on

Slides for a talk given at the first China Clojure Users meeting.

Published in: Technology, Design
0 Comments
9 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,692
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
108
Comments
0
Likes
9
Embeds 0
No embeds

No notes for slide

Clojure Web Development

  1. 1. Clojure WebDevelopment OnyCloud 江宏
  2. 2. Example - Trakrhttps://trakrapp.com/Web-based project management systemA product created for our own needsRequirements Feature-complete for software devs Modern friendly UI Affordable
  3. 3. Demo
  4. 4. Architecture MongoDB (Log & Cache)JavaScript HTTP JSON App Server(Backbone.js) (Clojure) PostgresQL
  5. 5. HTTP Server Structure Ring Middleware Handlers The Compojure Framework
  6. 6. RoutesMapping: Request -> Handler:(defroutes app-routes (context "/users" [] (GET "/new" [] accounts/show-signup) (POST "/" [email] (accounts/new email)));; GET /users/new -> accounts/show-signup;; POST /users/ -> accounts/new
  7. 7. HandlersRequest in, response out.(defn say-hello [req] (let [name (-> req :params :name)] {:status 200 :body (str “Hello ” name “!”)}
  8. 8. MiddlewareTransform: Handler -> New Handler(defn wrap-failsafe [handler] (fn [request] (try (handler request) (catch Exception e (.printStackTrace e) {:status 500 :body "An error occured."}))))
  9. 9. TestingUnit testing with clojure.test andclojure.contrib.mockIntegration testing using WatirDemo
  10. 10. PerformanceNo optimization tricks (type hints, transients,etc.)Average latency ~ 70msLong tailDatabase performance can be improved (indices).
  11. 11. Lessons LearnedGood: High productivity Easy to test (dynamic binding) Relatively easy learning curve
  12. 12. Lessons LearnedBad: Ugly stacktraces. Exposes too much Java class hierarchy. PersistentMap, PersistentStructMap, struct_map ... (contains? (transient #{:a}) :a)
  13. 13. Thank You

×