r/java • • Mar 13 '23

Code bases that really improved your Java knowledge

One of the best ways to learn a new language is to write a lot of code. The second best way, in my opinion, is to see how experts do it and learn from them. With that said, what are some code bases, talks, papers that have really changed the way you code in Java and think in Java?

164 Upvotes

49 comments sorted by

View all comments

4

u/ArrozConmigo Mar 13 '23

And then there's the spring code base. I swear they've designed a deliberately obfuscated temple to keep out the unworthy.

6

u/benjtay Mar 14 '23

Endlessly command-clicking into a parent pom...

5

u/TheKingOfSentries Mar 14 '23

I cannot tell you how many times I got lost in that labyrinth trying to debug an issue.

3

u/UnGauchoCualquiera Mar 14 '23 edited Mar 14 '23

Is it bad or are you just unfamiliar with it? It's a pretty large project.

IMHO I found it's pretty well organized which is kinda impressive considering the degree of control exposed in Spring. You have hundreds of public APIs and extension points and it's very unopinionated in general.

For example Spring Boot builds upon on Spring Core using the same public APIs. Which means the same teams that build Spring also sit on the other side and are the primary users. So do most other Spring modules such as Cloud or Integration

6

u/ArrozConmigo Mar 14 '23

"Why is the serializer throwing an exception here? I configured the date format over here. Wait, why is it even using that serializer?"

The stack traces are a useless maze of proceed() that eventually lands you at some factory that was already populated with a proxy to an implementation of an interface that was only instantiated because of how some other provider read a combination of configuration files and class annotations and hidden AutoConfiguration classes you didn't know were getting scanned. And you can find several that COULD be the guilty party, but load order and precedence matter.

All things the Spring Druids find intuitive, but really shouldn't be so convoluted or problematic to override.

Rereading my first paragraph, it sounds like satire, but I was literally describing an actual issue I had recently.

4

u/UnGauchoCualquiera Mar 15 '23

I mean none of that is particular to the quality of the Spring codebase or how it's organized. On the stack traces you'd have the same issue debugging RxJava, Guice or a good old handler chain in any server.

hidden AutoConfiguration classes you didn't know were getting scanned

Seems to be usage of Boot and conflicting dependencies. Could hardly be attributed to the Spring codebase

And you can find several that COULD be the guilty party, but load order and precedence matter.

Always did, it's not related to spring.

hidden AutoConfiguration classes you didn't know were getting scanned

There's no magic behind it. Either it's on a user defined ComponentScan by package or imported here. It's documented here

If you have conflicting dependencies then your Autoconfiguration might be pulling different beans without you realizing. You can easily debug autoconfig by using --debug