Philosophy

Why Barnark works the way it does.

Barnark is built on a few decisions. Each one refuses something common in how a project’s architecture is kept, and each shows in how the tool behaves.

The software must never break what a team has built #

A team that makes a mess of its own template is responsible for that. But if a team builds a fine architecture of its own and a new version of the tool tells them their whole codebase is wrong, that is the tool’s fault.

So Barnark copies and never refers. Cloning a template makes a template of your own, under a name you give it, with nothing tying it to the one it came from. When a later Barnark ships a changed Domain Driven Design, yours doesn’t change. The shipped templates are read-only, and nobody calls their project “Domain Driven Design”, so a shipped template’s name can’t be used for one of yours.

No style is privileged #

Barnark keeps a catalogue: Domain Driven Design, Feature Based Architecture, Model View Controller, Library and Package App. None of them is a belief. A catalogue entry is a starting point, and you decide what your project’s shape is. Where a shape suits a kind of project, the description says so, and no more.

A template says only what folders there are. It never says what code goes in them, so Barnark is not a linter, and it has no opinion on your files.

Conformance is derived, not asserted #

Nobody declares a codebase well architected. template:check compares the project’s folders with its template and reports where they differ, as missing or unexpected. It comes back clean or it doesn’t.

When someone changes folders by hand, the check shows it. For each unexpected folder you either take it into the template, saying what belongs there, or leave it showing as an issue. Nothing is silently accepted, and nothing is silently undone.

The template and the folders change together #

A template that describes folders which are not there, or folders that the template doesn’t know about, is not much use. So when you add a member to a collection, such as a new Context, the template records it and the folders appear on disk at that moment. Using Barnark keeps the two consistent.

A decision keeps its history #

A template is kept as revisions, and none is changed in place. Its first revision is the copy. Adding or deleting a member, adding a folder and changing what a folder means each make a new revision, with a reason Barnark writes, such as “Added Context/Reservation.” A revision can be looked at later as a read-only tree, so the current shape is understandable together with how it came to be.

Restrictive on purpose #

Every member of a collection has the same shape: every Context has the same Domain, Application, Infrastructure and PublicApi. Barnark doesn’t let you change one member alone, or add a folder inside one, because then it would no longer match its kind. If a member needs a different shape, it is a different kind of folder, and is one the template should say so about.

What it refuses to be #

  • A code generator. It never creates a file in your folders, apart from a .gitkeep so that git keeps an empty folder.
  • A judge of existing code. It is for keeping a new project well shaped from the start.
  • Tied to one architectural style, or to one language. A template is folders.
  • A tool that guesses. Where it cannot be sure, it refuses and says why.

Next: the quick start, or templates, bound and unbound in detail.