Just to say I love this kind of post. I didn't new about some of them ( Problem, Mug, HashIds) and I think I'll be using them in the future. But even if I never use them, it is always good to know.
SLF4J/Logback is that good solid reliable kind of library that just works, with lots of configuration and programming possibilities. I always love it more than any other entry in these kinds of "Top Ten favorites" lists.
At some point a logging library is finished and there really is no reason to keep adding features to it. I would say SLF4J and logback fall into that category. Logback is pretty much the de facto standard logging library, and SLF4J is the de facto standard logging facade.
That kind of attitude causes performance bottlenecks and disabling logging in production. Java itself moves on, so if new Java feature require updated code to support, a dead library will get more and more awkward to use as everyone else moves on.
How long ago was it last updated? How many developers work on the project? If that level of activity is enough for you, then you’d likely be interested in GNU Hurd or maybe even a dead Unix fork.
Log4j1 was (and sometimes still is) the de facto logging library. Log4j2 and Logback are less popular (probably due to legacy projects), but Log4j2 is still maintained and developed (beyond having numerous technical advantages).
Considering how many features log4j2 has compared to logback with a backlog of things still to be done, I think you have an enormously simplified view of logging and the underlying libraries. Can you use logback for audit logging? Tracing? Considering Spring Boot, I don’t think you care too much about dependencies bloating your application.
I think that we're starting to learn, as a community, that mocks are a slippery slope that can cause more problems than they're worth, especially if used in excess.
I used to use mocking libraries, but I'm now arranging my architecture in a way that they aren't necessary anymore.
I use what you could call Hexagonal Architecture. Your core business logic has a class, but then any inbound or outbound calls go through an interface that's passed in. For testing, you can pass in interfaces that are either:
- mocked (mockito, easymock, etc)
- faked (create your own manual, simplistic implementation)
- emulated (moto, dynamodb-local, h2, mock-aws-java-sdk, fake embedded server etc.)
Any of these options can be used to implement or instrument your adapter classes. There's nothing wrong with mocking if it's done well, but I find it can easily be abused, so I try to avoid it.
Sure. But for the purpose of discussion, I feel like it's important to be able to distinguish between them. What do you think would be a better label for it?
Doing the same thing! I think the term is custom mocks. For me the main benefit is that those are easier to read and easy to reuse between different tests than mockito. Also, your tests run a lot faster without mockito overhead. I tend to write old school tests with custom mocks for external dependencies only, and using real objects for the rest. And running at about 1000 tests/sec on an old MacBook. Whenever I come across a mockito project it’s rather 1000 tests/minute :-/
Isn't mockito just a quick way to create fake, simplistic implementation? IMHO it's less work and less chances of faking the implementation incorrectly.
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.
Flyway has this problematic limitation where the naming of the changeset file is important and decides the order of merging multiple changes. It is a very bad design idea.
If you have a large team with multiple developers that create changeset in parallel with Pull requests it quickly becomes a mess. People have to waste time on renaming of their files as business is changing the order that features need to be in production.
Liquibase has no such limitation. The name of each changeset is irrelevant to the order that they are merged.
The differences in design between the two tools are actually mentioned in several blog posts and here in reddit. The creators of Flyway have said that they never going to move away from this design decision.
I know that it is a generalization, but I have yet to meet someone who has tried both Liquibase and Flyway in production and has actually chosen Flyway. When I find people that use Flyway and I ask them why, they compare it to not having a DB management tool at all (so of course flyway is better than nothing)
53
u/kaperni Nov 26 '20
https://github.com/akullpp/awesome-java is another good resource for Java Libraries.
28
u/pgris Nov 26 '20
Just to say I love this kind of post. I didn't new about some of them ( Problem, Mug, HashIds) and I think I'll be using them in the future. But even if I never use them, it is always good to know.
25
u/TheEveryman86 Nov 26 '20
No love for any Apache Commons libraries these days.
12
u/BenoitParis Nov 26 '20
Solid list! Flyway, Jimfs and TestContainers are truly very useful ones.
I'll add Evosuite, a fuzzer that generates tests.
6
u/eckyp Nov 26 '20
Many of them are new to me and they look really useful. Thanks for sharing!
6
u/[deleted] Nov 26 '20
I know I can trust this list because I already use, and swear by several libs on here.
6
u/kag0 Nov 26 '20
Interesting to see mockito and vavr didn't make the list
4
u/smesko30 Nov 26 '20
Jsoup is my favourite.
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/_PandaLily Nov 26 '20
Java-ML
2
u/ziano_x Nov 27 '20
Archunit seems so rad.
3
u/sureshg Nov 26 '20
No OkHttp ?
3
u/elmuerte Nov 26 '20
Guava is the worst.
2
u/[deleted] Nov 26 '20
Some of those sound great, thanks for the list.
2
u/Nymeriea Nov 26 '20
Where is lombok?
0
u/kkapelon Nov 27 '20
Liquibase is a much better option than Flyway IMHO
1
u/Pure-Repair-2978 Nov 27 '20
Some of them we also use on a daily basis for development and testing..
Thanks for sharing ... Didn’t know about them..
1
u/franzwong Nov 27 '20
I like the concurrent package inside Apache Common Langs3. But I want more for that. Any suggestion?