13. Further reading

further reading

You can never get a cup of tea large enough or a book long enough to suit me.
— C.S. Lewis

Further reading

Further exercises: https://www.4clojure.com/

Clojure for Java Programmers - Rich Hickey

Best practices

  • Write tests

  • Write expectation strings for tests

  • Use lein-test-refresh

  • Keep functions short and focused

    • Extract sub functions

    • Compose functions

Best practices

  • Keep namespaces short and focused

    • Extract related functions into new namespaces

    • Write doc-strings for namespaces

  • Write doc-strings for functions

  • Write doc-strings for defs when appropriate

  • Follow the Clojure style guide

Tips

  • Build bottom up

  • Start with data

  • Create functions to operated on that data

  • Eastwood can give hints on better expressions

  • Read source code (Clojure, libraries, open source projects)

Tips

  • Most problems can be solved with a function

  • Scientific method:

    • Think of things that could possibly be wrong

    • Isolate a small test case

    • Test one hypothesis at a time

  • Finding Clojure libraries https://www.clojure-toolbox.com/

Workflow

  • Editor + Test refresh + REPL

  • Reading stacktraces

    • Try line 1

    • Scan down for your namespace

  • Small functions

  • Test as you go

  • Print things

  • Test assumptions/hypothesis

Editor customization

  • After you feel comfortable with Clojure

  • Paredit

  • Parinfer

  • Send file to REPL

  • Send form to REPL

Learn the many Clojure functions

  • Set aside some recuring time to bite of bits of the API

  • Clojure word of the day: https://clojure.me

Read Clojure code

  • Clojure source

  • Clojure libraries

  • Open source projects

  • Check the source on anything new you use

Style guide

Eastwood

Produces suggestions on how to write idiomatic Clojure

$HOME/.lein/profiles.clj

{:user {:plugins [[jonase/eastwood "0.2.5"]]}}
$ lein eastwood

Get help

Practice

Thank you

@timothypratley

End Further Reading