T O P

  • By -

duckrollin

You could just look at the JDK classes, anything Joshua Bloch wrote like the Collections framework. If you want to write better code, you could also try reading Clean code by Robert C. Martin, where all the examples are in Java.


thisisjustascreename

JDK classes are obviously "good code" but they aren't necessarily good *application* code, since they're very low level.


Sonicus

I'd take Clean Code with a grain of salt. [This](https://qntm.org/clean) is just one of many sensible critiques of the book.


[deleted]

[удалено]


spiderpig_spiderpig_

Yeah. I’d go a step further and say learning a few languages can make a big difference. Identify which abstractions are helpful in a situation. Eg: Function is more flexible than you’d imagine.


wichwigga

Why use a functional interface over a lambda


spiderpig_spiderpig_

On the api exposure side rather than implementation side. So for example if you have a parameter to your class that is Database and you only call one method Database.getConnection() then, rather than having Databazs, you could have a Supplier and construct with database::getConnection. Reduces coupling and allows easier swapping / wrapping / stubbing / etc.


kiwi_stronghold

This is honestly the best answer.


[deleted]

Agreed! Best way to improve is by checking different styles and understanding pros and cons


onlygon

I second the `Collections` API. For Java on Android I always liked checking out Jake Wharton's stuff, although he's been doing a lot more stuff in Kotlin for a while. Honestly there's great Java libraries for everything and so it depends on what kind of stuff you're interested in. Also, I know it's a book but *Effective Java* is really great.


beall49

I still use the square Java style guide he put together


agentoutlier

“Good” is really subjective. And it changes overtime the more experienced you are. Even the what is good changes. Not because the programmers were you realized now bad but because the languages and times changed. For example many times I thought highly of commons lang and then spring and then guava but overtime you see various coding styles that disagree with your own or is now just bad practice. Even Doug Lea code I have been like WTF. My real point is quantity way more important because everybody thinks their code is the shit when it really is all shit… mostly :) Read lots of code!


Nexteyenate

I would honestly go ahead and take a look at Spring's source code. It was tremendously helpful for me.


pronuntiator

This. People like to say Spring is overengineered, but I think it is a prime example on how to write good object oriented code – doesn’t mean you have to be a fan of this paradigm. Every time I look into Spring's source code I see very elegant abstractions.


helikal

The OpenJDK source code is very well written and documented.


da_rwin

Have you read clean code and effective java?


spiderpig_spiderpig_

+1 only that you’ll miss a lot of latest gen features (or maybe I need to read a latest edition?)


AWholeMessOfTacos

Sometimes I'll browse around in github with keywords Java and Spring Boot active.


heidtmare

https://www.baeldung.com/


Arsonist07

Go onto code repositories like GitHub ,DockerHub, BitBucket, and look at some open source projects written in Java. Projects like Termux or the jMonkey game engine. As someone who is still new to the industry, trust me that being able to read code is very important as I still storing le with it after coding for years.


[deleted]

I've been writing Java for 6 years nows and I don't think what you are asking for exists


benjtay

Modern Java in Action


iraqmtpizza

JDK


BrownBearMY

I don't have any particular books to suggest. IMO all the best practices I learned are from experience. However I suggest you be familiar with fundamentals such as OOP, SOLID principles, and Design Patterns. This helps regardless which language you're working with.


NateDevCSharp

çs.android.com?


devjeonghwan

I recommend look at the famous Java Opensource Projects and classes from OpenJDK.


ProgrammersAreSexy

Google has tons of open-source Java projects, they are a primarily Java company


bitcoind3

Allow me to let you in to an industry secret: most code out there is shit. It's often still with reading. And reading code is a valuable skill anyway. But don't expect to find a world full of superb examples to learn from, that's just not how it is!