Idiomatic approach for structuring Clojure source code

Posted by mikera on Stack Overflow See other posts from Stack Overflow or by mikera
Published on 2010-06-17T14:47:43Z Indexed on 2010/06/17 14:53 UTC
Read the original article Hit count: 248

Filed under:
|

I'm interested in how people structure their Clojure source code.

Being used to Java, I'm pretty familiar with the paradigm of one class per source code file, bundling all the data and method definitions with appropriate comments and annotations etc.

However Clojure offers a lot more flexibility, and I'm not sure how I should structure my project (likely to end up as a medium sized app, maybe 5,000 lines with three or four distinct subsystems)

In particular I'm wrestling with:

  • What guidelines should I use to determine whether code should be in a single namespace vs. separated out into different namespaces?
  • Should each protocol/datatype have it's own namespace + source file with associated set of functions?
  • When should I require vs. use other namespaces?

© Stack Overflow or respective owner

Related posts about clojure

Related posts about source-code