architecture 2023-08-06

This is more a code architecture question, revolving mainly around @hiredman's approach of "single file projects" I have a code base I tried organizing both split in files and in a single namespace and dammit, I'm unhappy with both. I have protocols, types, core functions, protocol extensions, what goes where? In what order? How will that affect the final project API for users?

Do you have a link to that "single file projects" approach?

What's your pain point with multiple files? Sometimes it can indicate some weak spot in the editor or tooling side

It's more about how to organize (e.g. split) code across those files

I've been very happy with "300LOC max per ns" rule of thumb. (It also keeps tools.namespace snappy) A longer count tends to indicate a mixing of concerns

👍 1

Also, an api.clj/impl.clj separation tends to bring lots of clarity. That way I can learn about the important bits of a project very quickly Also good for testability - impl.clj fns are not private, so I'm not guilt-tripped into not testing them.

When I find time I need to upload my experiments maybe you'll be able to point out the right line of concerns separation

👀 1

Text is always like several dimensions less than reality. It's like trying to spot a trend in two dimensions from reading the data expressed in one. That's my headache. Fixing that usually requires tools to match the problem and i don't think file organization plays a role in that directly.

I leave files long until I have to do more than a second or two of searching to find the right section. That can be 200 lines or 1k, just depends on the project and problem domain.

Time to search is also a function of screen size 😞

👍 1

What's nice about the single ns, is that the order becomes that of dependency. What is used by things after comes before.

So the question of "in what order" is answered by it.

Then, when that gets too big, you know how to move things out, they're in the same order.

💯 1
➕ 1

@ben.sless is this for a library or for an application?