In search of good design...   // When I wrote this code, only God and I understood what I was doing   // Now, God only kno...
ABOUT ME                        TWITTER.COM/FAUST45                          GITHUB.COM/FAUST45Monday, October 8, 12
What is programing about?                Goal of program convert input to reasonable output.                We calculate s...
What is programing about?                               temp            temp         complete                             ...
What is programing about?   Program     State                               temp            temp         complete         ...
What is programing about?   Program     State                               temp            temp         complete         ...
What is programing about?   Program     State                               temp            temp         complete         ...
Looks simple?   Program     State                               temp            temp         complete                     ...
Lets add some complexityMonday, October 8, 12
Lets make                        control order layer                        hard to understandMonday, October 8, 12
Let’s split                           control order layer                        and hide in Calculate unitsMonday, Octobe...
Who can help us?Monday, October 8, 12
GOTOMonday, October 8, 12
Lets do the same with                         state manages layerMonday, October 8, 12
Lets make                        state manages layer                        hard to understandMonday, October 8, 12
Lets split                           state manages layer                        and hide in Calculate unitsMonday, October...
ExampleMonday, October 8, 12
Example                                  Will never                                  happensMonday, October 8, 12
Happy debugging suckersMonday, October 8, 12
Any part of the program can                        rewrite state, and its not easy to                           tell where...
Unit tests don’t save us                                   Unit test passed success.                                 Only ...
Thats most popular                        programing style, for                              today.                       ...
Where the answer?Monday, October 8, 12
Functional ProgrammingMonday, October 8, 12
Functional model   Program     State                               temp            temp         complete                  ...
You construct program                    from units of pure                       calculationsMonday, October 8, 12
Units of pure calculations            have no direct access to                  program stateMonday, October 8, 12
You pass a pice of state in                    params           function send_money(sender_account,                       ...
and return result of                         calculations, some                         new pice of state    function send...
Calculations depends only                 from params you passed,                      nothing hiddenMonday, October 8, 12
Functional    Program      state                              Pice of program                                    state    ...
Imperative    Program      state                                               Pice of program                        dir ...
Rich Hickey               Creator of clojure, language with immutable               data by default.               Dialect...
Model where you don’t                    rewrite values but                   produce new valuesMonday, October 8, 12
Clojure introduce fast                           immutable data                              structuresMonday, October 8, 12
Implemented with                            Binary trees                                and                         struct...
Monday, October 8, 12
Mutable dataMonday, October 8, 12
Resources                ★       “Out of the Tar Pit”                ★       “The Art of Unix Programming”                ...
Upcoming SlideShare
Loading in …5
×

In search of good design...

469 views
425 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
469
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

In search of good design...

  1. 1. In search of good design... // When I wrote this code, only God and I understood what I was doing // Now, God only knowsMonday, October 8, 12
  2. 2. ABOUT ME TWITTER.COM/FAUST45 GITHUB.COM/FAUST45Monday, October 8, 12
  3. 3. What is programing about? Goal of program convert input to reasonable output. We calculate something and storing temp results in vars, until we can produce complete result.Monday, October 8, 12
  4. 4. What is programing about? temp temp complete results results result Calculates Calculates CalculatesMonday, October 8, 12
  5. 5. What is programing about? Program State temp temp complete results results result Calculates Calculates CalculatesMonday, October 8, 12
  6. 6. What is programing about? Program State temp temp complete results results result Calculates Calculates Calculates Layer control order of calculationsMonday, October 8, 12
  7. 7. What is programing about? Program State temp temp complete results results result Layer manages access to program state Calculates Calculates Calculates Layer control order of calculationsMonday, October 8, 12
  8. 8. Looks simple? Program State temp temp complete results results result Layer manages access to program state Calculates Calculates Calculates Layer control order of calculationsMonday, October 8, 12
  9. 9. Lets add some complexityMonday, October 8, 12
  10. 10. Lets make control order layer hard to understandMonday, October 8, 12
  11. 11. Let’s split control order layer and hide in Calculate unitsMonday, October 8, 12
  12. 12. Who can help us?Monday, October 8, 12
  13. 13. GOTOMonday, October 8, 12
  14. 14. Lets do the same with state manages layerMonday, October 8, 12
  15. 15. Lets make state manages layer hard to understandMonday, October 8, 12
  16. 16. Lets split state manages layer and hide in Calculate unitsMonday, October 8, 12
  17. 17. ExampleMonday, October 8, 12
  18. 18. Example Will never happensMonday, October 8, 12
  19. 19. Happy debugging suckersMonday, October 8, 12
  20. 20. Any part of the program can rewrite state, and its not easy to tell where its happening.Monday, October 8, 12
  21. 21. Unit tests don’t save us Unit test passed success. Only when you run all program you can touch the bugMonday, October 8, 12
  22. 22. Thats most popular programing style, for today. ImperativeMonday, October 8, 12
  23. 23. Where the answer?Monday, October 8, 12
  24. 24. Functional ProgrammingMonday, October 8, 12
  25. 25. Functional model Program State temp temp complete results results result Layer manages access to program state Calculates Calculates Calculates Layer control order of calculationsMonday, October 8, 12
  26. 26. You construct program from units of pure calculationsMonday, October 8, 12
  27. 27. Units of pure calculations have no direct access to program stateMonday, October 8, 12
  28. 28. You pass a pice of state in params function send_money(sender_account, receiver_account, amount_to_send)Monday, October 8, 12
  29. 29. and return result of calculations, some new pice of state function send_money(sender_account, ...) return how_sender_account_looks_after_money_was_sendMonday, October 8, 12
  30. 30. Calculations depends only from params you passed, nothing hiddenMonday, October 8, 12
  31. 31. Functional Program state Pice of program state Calculate return resultMonday, October 8, 12
  32. 32. Imperative Program state Pice of program dir state ect acc ess Calculate return resultMonday, October 8, 12
  33. 33. Rich Hickey Creator of clojure, language with immutable data by default. Dialect of Lisp on top of Java Virtual Machine He was inspired by paper “Out of the Tar Pit”Monday, October 8, 12
  34. 34. Model where you don’t rewrite values but produce new valuesMonday, October 8, 12
  35. 35. Clojure introduce fast immutable data structuresMonday, October 8, 12
  36. 36. Implemented with Binary trees and structure sharingMonday, October 8, 12
  37. 37. Monday, October 8, 12
  38. 38. Mutable dataMonday, October 8, 12
  39. 39. Resources ★ “Out of the Tar Pit” ★ “The Art of Unix Programming” ★ “Functional programming is a ghetto” (blog bost by Michael O.Church) ★ Rich Hickey videos ★ Stuart Holloway videos - “Simplicity Aint Easy”Monday, October 8, 12

×