Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Life Without Footguns (Part 1)

Life Without Footguns (Part 1)

Chew Choon Keat

March 20, 2021
Tweet

More Decks by Chew Choon Keat

Other Decks in Technology

Transcript

  1. About • Basic • C, Perl, Java • Javascript &

    Ruby on Rails for 10 years • Go and Elm in the past few years • @choonkeat
  2. About • Basic • C, Perl, Java • Javascript &

    Ruby on Rails for 10 years • Go and Elm in the past few years • @choonkeat How to do things How to NOT do things
  3. Adapters Ports Design Pattern + Best Practices Core • avoid

    shadowing variables • avoid cyclic dependency • avoid inheritance • avoid mutation • prefer explicit dependency • prefer stateless functions • pure functions are testable • … I can just apply functional techniques instead of switching to a functional language

  4. Adapters Ports Design Pattern + Best Practices Core • avoid

    shadowing variables • avoid cyclic dependency • avoid inheritance • avoid mutation • prefer explicit dependency • prefer stateless functions • pure functions are testable • … I can just apply functional techniques instead of switching to a functional language

  5. “Software engineering is what happens to programming when you add

    time and other programmers.” — Russ Cox https://research.swtch.com/vgo-eng
  6. Adapters Ports Soft Social Contract Core • avoid shadowing variables

    • avoid cyclic dependency • avoid inheritance • avoid mutation • prefer explicit dependency • prefer stateless functions • pure functions are testable • … I can just apply functional techniques instead of switching to a functional language

  7. Adapters Ports Soft Social Contract Core other people’s code urgent

    fi x • avoid shadowing variables • avoid cyclic dependency • avoid inheritance • avoid mutation • prefer explicit dependency • prefer stateless functions • pure functions are testable • … I can just apply functional techniques instead of switching to a functional language

  8. Life without Footguns Functional architecture - The pits of success

    - Mark Seemann https://youtu.be/US8QG9I1XW0
  9. Life without Footguns Functional architecture - The pits of success

    - Mark Seemann https://youtu.be/US8QG9I1XW0 How?
  10. Pure Functional Program Runtime Your Program Http request Render DOM

    Call Javascript Http response Input change Mouse move
  11. Pure Functional Program Runtime SAME callback function hooked up to

    ALL events Events in Return values Http request Render DOM Call Javascript Http response Input change Mouse move
  12. “1 big callback”? Does It Scale? onClick = helloworld onSubmit

    = helloworld onLoad = helloworld what mickey mouse app can you build?
  13. Pure Functional Program Runtime Events in Return values Http request

    Render DOM Call Javascript Http response Input change Mouse move Pure Function Pure Function Pure Function Pure Function Pure Function Pure Function Pure Function Pure Function Pure Function
  14. there’s a bug here but it isn’t clear 😖 if

    you compare to the next slide you might fi nd the problem “1 big callback” is a nightmare
  15. Pure Functional Program Runtime Your Callback Function Events in Return

    values Http request Render DOM Call Javascript Http response Input change Mouse move
  16. Life without Footguns Functional architecture - The pits of success

    - Mark Seemann https://youtu.be/US8QG9I1XW0