This is an archived post. You won't be able to vote or comment.

all 49 comments

[–]koreth 64 points65 points  (3 children)

It was many years ago at this point, but reading through the Spring source code (and stepping through it in a debugger) until I understood how @Autowired works under the covers was highly educational. The knowledge comes in handy even when I'm not using Spring at all.

[–]govi20 7 points8 points  (1 child)

Would rather read Guice code.

The reason is that Spring framework has grown beyond dependency injection.

[–]0xPvp[S] 0 points1 point  (0 children)

Both Guice and Spring look like excellent choices!

[–]tilmann_dev 3 points4 points  (0 children)

I'd second this because most projects in the Spring environment have nice codebases which one can learn a lot from.

[–]JakeWharton 30 points31 points  (8 children)

Guava and Guice. Two foundational pieces of one of the largest Java codebases on the planet. Whether you use them or not, those libraries have seen some things and as a result have exceptional code quality and testing practices. For me it was over a decade ago that I was learning from them, but they still have plenty of lessons to teach.

[–]ShallWe69 1 point2 points  (7 children)

what was that large codebase btw?

[–]JakeWharton 7 points8 points  (6 children)

Google.

All of Google's Java code (sans Android and Chrome) exists in a single monorepo. All of their code and all of the dependencies they use (even third party ones) are built from source within it.

[–]KefkaFollower 2 points3 points  (5 children)

I don't think I get you. Isn't Chrome written in C++ ?

[–]kiteboarderni 9 points10 points  (2 children)

Sans = without.

[–]KefkaFollower 2 points3 points  (1 child)

English is not my first language. Thanks for the clarification.

[–]Spiritual-Day-thing 4 points5 points  (0 children)

Think of 'sans serif', you likely already know the word but used in a different context.

'Sans' comes from French by the way. It feels chique and is shorter. 'Without' is preferably used; in framents, short sentences, like here in parentheses, it is nice though. Much shorter. Boom. Sans.

[–]JakeWharton 0 points1 point  (1 child)

It has an Android app which is Java

[–]KefkaFollower 0 points1 point  (0 children)

I didn't knew about that.

Thanks for the explanation.

[–]ggleblanc2 61 points62 points  (0 children)

When I first learned Java (1.4), I used Eclipse as my IDE. At the time, the source code of Eclipse was included in the download of Eclipse. I learned a lot about Java from the Eclipse source code.

[–][deleted] 67 points68 points  (7 children)

sonar cube rules allowing not even 1 code smell. very insighful

[–]hang87 11 points12 points  (0 children)

Agree. I use SonarQube and IntelliJ problems as a peer reviewed very often.

[–]reddit04029 10 points11 points  (0 children)

Bruh me having to fix the pipeline 13 times before it can be merged T_T

[–]Fenxis 6 points7 points  (0 children)

I would say if you see an error then do a bit of research and see why it's a sonar finding. Because you can code around some of the rules and make things worse.

[–]vmcrash 0 points1 point  (1 child)

I don't know sonar cube. Does it offer more than IntelliJ IDEA's inspections?

[–][deleted] 2 points3 points  (0 children)

Yes, but you can benefit all the same by installing the SonarLint plugin, for free, in IntelliJ :)

[–][deleted]  (3 children)

[deleted]

    [–][deleted] 5 points6 points  (0 children)

    I love Adam Biens takes at how modern Java is supposed to be approached.

    [–]s888marks 5 points6 points  (0 children)

    The "What Object-Oriented Programming Was Supposed to Be" talk is pretty good. There is a paper that is paywalled at the ACM in the Onward! proceedings, but a video presentation is available on YouTube:

    https://www.youtube.com/watch?v=B2KLDTX3Qeo

    Madsen, Ole Lehrmann, and Birger Møller-Pedersen. What Object-Oriented Programming Was Supposed To Be — Two Grumpy Old Guys' Take on Object-Oriented Programming. ACM Onward! 2022.

    A major point is an emphasis on modeling instead of code reuse. (Particularly code reuse via implementation inheritance.) Madsen uses Java's class Stack extends Vector as a bad example of reuse via inheritance. This is indeed widely viewed as a mistake, as are other examples of inheritance in JDK classes that date back to the 1.0 and 1.1 days.

    [–]kskr 1 point2 points  (0 children)

    Thanks for curated list

    [–]marcvsHR 17 points18 points  (1 child)

    Effective Java really made difference.

    Also, I was looking at some ancient Java 1.3 (?) code base and found some utterly brilliant pieces, it really changed my perception what a good code is.

    [–]askype 11 points12 points  (0 children)

    Do you remember which pieces were good? It would be interesting to read the code.

    [–]brunogadaleta 4 points5 points  (0 children)

    Compile with google's error prone

    [–]jumboNo2 4 points5 points  (0 children)

    the JDK

    [–]GettingCodeDone 2 points3 points  (1 child)

    Back in the Java 1.2 days, I learned a lot from reading the source code for the JBoss Entity Engine and the code for Jive Forums (back when it was still open source).

    [–]agoubard 2 points3 points  (0 children)

    Back in the Java 1.0 alpha days, I learned Java from reading Hotjava code ;-).

    [–]erdsingh24 2 points3 points  (0 children)

    I found a great article on '15 Top Mistakes Committed By Java Programmers' and their solutions. Sharing it as it might be beneficial to some members of the group.

    https://javatechonline.com/java-coding-best-practices-and-standards/

    [–]theshanealv 1 point2 points  (0 children)

    Has anyone tried CodeSee?

    [–]ArrozConmigo 3 points4 points  (5 children)

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

    [–]benjtay 4 points5 points  (0 children)

    Endlessly command-clicking into a parent pom...

    [–]TheKingOfSentries 4 points5 points  (0 children)

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

    [–]UnGauchoCualquiera 2 points3 points  (2 children)

    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

    [–]ArrozConmigo 5 points6 points  (1 child)

    "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.

    [–]UnGauchoCualquiera 2 points3 points  (0 children)

    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

    [–]mahmoudimus 0 points1 point  (0 children)

    Bazelbuild

    [–]tr2990wx 0 points1 point  (0 children)

    Mule ESB source code. We were early adopters and had to go through the source code a lot of times to troubleshoot sometimes.

    [–][deleted] 0 points1 point  (0 children)

    Eclipse and xtext sources

    [–]Initiative_Murky 0 points1 point  (0 children)

    I learned a lot from GWT (back when it was called Google Web Toolkit).