Your SlideShare is downloading. ×
Why oo
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Why oo

3,257
views

Published on

Varför kodar vi objektorienterat när funktionell programmering lämpar sig så mycket bättre för webben? …

Varför kodar vi objektorienterat när funktionell programmering lämpar sig så mycket bättre för webben?
Av Jimmy Larsosn, Valtech AB

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
3,257
On Slideshare
0
From Embeds
0
Number of Embeds
16
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Varför  objektorienterar  viegentligen?Jimmy  Larsson  -­  @jimlar
  • 2. Web  sites  are  not  aboutobjects!
  • 3. Jimmy  LarssonValtechie  since  2007Coding  my  way  through  the  last  28  years  or  soASM,  C,  C++,  Pascal,  Scheme,  Perl,  Java,  Ruby,  Python,Scala,  Clojure,  JavascriptArchitecture····
  • 4. History  made  us  do  it
  • 5. Abstracting  ComputationAlonzo  Church-­  Lamda  calculusAlan  Turing-­  Turing  machine
  • 6. EngineersJohn  McCarthy-­  LISPJohn  von  Neumann-­  Von  Neumann  Architecture
  • 7. YouarehereComputationLambda  CalculusLISPTuring  MachineAssemblerCOOLISP  Machines©  Jessica  Kerr  -­  http://blog.jessitron.com/
  • 8. Functional  Programming
  • 9. What  is  it?f(x)  =  yData  transformation(range  3)  =>  [0  1  2](map  inc  [0  1  2])  =>  [1  2  3]find  .  -­name  *.txt  |  xargs  cat  |  grep  ERROR  |  sort  |  uniq  -­c··
  • 10. The  Web  Application****   COMMODORE   64   BASIC   V2   ****64K   RAM   SYSTEM   38911   BASIC   BYTES   FREEREADY.10   LOAD   "“”DATA"“”20   TRANSFORM   "“”DATA"“”30   IF   X="“”DONE"“”   THEN   50:   END40   GOTO   1050   SAVE   "“”DATA"“”60   OUTPUT   "“”HTML"“”
  • 11. The  Code
  • 12. Loading  RDBMS  data(def  db  "postgresql://localhost:5432/food")(query  db        (select  *  :products  (order-­by  :name)))=>  [{:id  "basil"  :name  "Basil"}  {:id  "cucumber"  :name  "Cucumber"}]
  • 13. Integration  with  an  HTTP  API(def  url  "http://api.medveten-­mat.se/stock")(-­>  url  slurp  json/parse-­string)=>  {"basil"  15  "cucumber"  3  ...}                
  • 14. A  Word  On  Testability
  • 15. Creating  HTML(deftemplate  product-­template  "product.html"  [name  stock]        [:p#name]  name        [:p#stock]  stock)(product-­template  "Tomato"  7)                <html  xmlns="http://www.w3.org/1999/xhtml">        <head>                <title>Medveten  Mat</title>        </head>        <body>                <p  id="name">Cucumber</p>                <p  id="stock">15  in  stock</p>        </body></html>                
  • 16. Full  application(def  db  "postgresql://localhost:5432/food")(def  url  "http://api.medveten-­mat.se/stock")(defn  stock  [id]        (get  (-­>  url  slurp  json/parse-­string)  id))(deftemplate  product-­template  "product.html"  [name  stock]        [:p#name]  name        [:p#stock]  stock)(defn  product-­page  [id]        (query  db              (select  *  :product  (where  {:id  id}))              :row-­fn  #(product-­template  (:name  %)  (stock  id))))(defroutes  app        (GET  "/products/:id"  [id]  (product-­page  id))        (not-­found  (render-­404)))
  • 17. Tests(fact  "parse-­line  gives  empty  hash  map  on  bad  line"        (parse-­line  "")  =>  {}        (parse-­line  "  ")  =>  {}        (parse-­line  "  put")  =>  {}        (parse-­line  "n")  =>  {})                
  • 18. Leonardo  Fibonacci

×