Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 857331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:22:59+00:00 2026-05-15T08:22:59+00:00

I’m interested in how people structure their Clojure source code. Being used to Java,

  • 0

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?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T08:23:00+00:00Added an answer on May 15, 2026 at 8:23 am

    I’m from a Java background as well, along with quite a bit of Ruby and a little Go. Here’s what I’m doing at the moment, about a month into Clojure:

    • I’m thinking of a namespace as a semantic unit, it’s code that goes together for a particular purpose, like a datatype and the operations on it.

    I have two conventions for namespaces vs files:

    • For smallish units that fit comfortably in one file (I’m using ~1000 lines as the limit where a file should be split) I have one namespace per file, with the directory path plus file name the same as the namespace. This is a good thing in Java, I think, it makes finding the namespace from the file or vice versa a breeze.
    • For larger units that need several files, I’m using the Go convention: The namespace matches the directory path, and all the files in the directory share the same namespace. In these cases I normally assign a primary file with a fixed name (‘main’) that loads and interacts with the others.

    As a namespace example, I have a parser that reads a format and converts it to HTML. I have a single namespace for the parser (the semantic unit) and several files in the directory split on sub-functionality: Lexer, parser, HTML conversion and a main file that contains the primary public API for using the parser.

    I wouldn’t automatically use one namespace per datatype, it depends on the scope of the datatype. If it’s a big one, perhaps. But for a datatype like Point, with two fields and a couple of functions, I’d rather subsume it into a more general namespace like Geometry.

    Require vs. use:

    • Require with a suitably short alias almost everywhere.
    • This also allows reuse of core names: My special-purpose tree datatype has the operation “get” to fit with maps; using require there is no conflict: “get” is the Clojure core get, “tree/get” is the one for my datatype.
    • I’m using “use” only for what I consider “core extensions”, like when I make my own “map-if” which is map and filter rolled into one.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.