ArchUnit: enforce architecture in Java codebases

Today, I came across ArchUnit which lets you enforce architectural choices on any Java codebase. For example you might want to enforce that certain domain object methods are only accessed by the persistence layer classes, but not in, let's view-related classes, with the exception of tests. This can be helpful to avoid spaghetti code, with all classes depending on each other. Java packages can help in this regard, but they are a rather coarse filter.
Additionally, a unit test adds an immediately clear and conspicuous layer of intention to the codebase by expressing certain design choices that might be otherwise overlooked, unless a careful code review catches them.

It's pretty clear to me that Java, even with all its shortcomings and despite Oracle efforts to sabotage it, offers the best development environment in terms of tooling, IDEs, support, and libraries.

Notice that in the video, the host Ted M. Young is wearing the Change Behavior beanie, the other beanie is Refactor (change structure) 😆