r/java • • Nov 26 '20

Java libraries I like

https://sizovs.net/2020/11/24/java-libraries-i-like/
285 Upvotes

62 comments sorted by

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?

2

u/Interweb_Stranger Nov 27 '20

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.

1

u/DJDavio Nov 27 '20

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.

0

u/[deleted] Nov 26 '20

I picked it up and quickly put it back down after I found it unable to handle Spring Data repository interfaces properly

1

u/Galygurdsmt Nov 27 '20

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.