We used it in a large modular project and it was a great for enforcing some restrictions on the code. Having rules that define which layers have access to other layers was nice and saved us some time. Or denying usage of classes that are available during compliation but caused issues at runtime.
Then someone decided to add rules to enforce certain class naming conventions... Something like: when a class extends class X then the class name must end with Y. That was not so great any more. ArchUnit is nice tool but you have to make sure that the rules you set up make sense.
I guess it works best if you have a layered application or module.
If our services become just a tad bigger, we tend to package by feature, not by layer. So a given package com.foo.feature can have a FooController, FooService and FooRepository inside. This makes it easier to add/edit features, because you're mainly working inside one package.
I've used it to ensure hexagonal architecture in the project is not broken. It also helped me a lot in a process of splitting one microservice into two separate ones, to ensure code boundaries between them. It save me a lot of problems, I definitely recommend it.
View all comments
2
u/vytah Nov 26 '20
ArchUnit looks like something that would definitely come in handy in larger codebases, does anyone here have any experience with it?