I have heard a lot of people saying that to be a good programmer one needs to read a lot of good code. Can you help me find some good code in Java? Thanks.
The source code for the standard Java library is often good to read, because it consists of small functions which do well-defined things.
I think you can download the source for Java 1.7 from Sun Oracle, and there are all kinds of open-source remakes of the standard Java library.
I would recommend you to take a look at various open-source projects. As their code is freely available, it tend to be of honorable quality.
To access those sources, you can go on http://koders.com or its alternatives (see as an example this question on C++)
Pick your favorite open source library and start reading that. This will have the ancillary benefit of helping you gain a deeper understanding of how the library works. Here is a pretty good list of open source java libraries.
However, I find it more useful to tackle a programming problem myself, and then afterwords see how others approached the same problem. Project Euler is a great place to do this. Just my personal preference.
I would recommend looking at the Apache Java projects and the java.net projects
Take a look to the Swing library - it uses some design patters and good object-oriented design.
Also, I used to read source code of Atlassian JIRA issue tracker, but you need special license to do that.
As an alternative or a starter: Those two books have a good reputation amongst Java programmers and help to make up your mind how good code should look like:
- Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin)
- Effective Java (2nd Edition) (Joshua Bloch)
Here is another interesting web link to a book that covers code reading: Code Reading: The Open Source Perspective
An interesting way to train your skills towards good code is exercising coding katas.
I would also read Martin Fowler's book on code refactoring ...
http://www.refactoring.com/catalog/index.html
Know the Design patterns and when and how to apply them.
Use static code analysis like PMD or another to point out some issues.
Do not ignore warnings in your own code.
I like to look through the code in Java's standard libraries too. Start off small with the methods that you actually use; then move on to classes like String, Integer, and other basic types, and move on slowly to entire packages, the Collections package, for e.g.
Looking at a method or two, is probably not going to be that enriching an experience compared to looking at different classes and figuring out the design.
Open source libraries are good too. Pick those that you actually use in your daily work and were developed by programmers/organizations you respect.
I have the Java sources installed and integrated in Eclipse, so when I'm programming and I'm using some class from Java's API I can dig into the class' source code and see how some things are implemented. Particularly interesting are the Collections and Concurrency related classes.
There are much more opensource projects source are found in SourceForge.net. Utilize them properly. If u really wanna get more follow your instinct, for what you need & want..
As far as I know if you've the real thrust you can accomplish much more, Believe that you can do and Do
All the Best
Although the code may not be legitimate, look at some MMO Private Servers' java source. They're great because the source is open, bountiful, and contains methods to concepts and actions that you can visibly see when playing the game.
I do NOT promote hosting one, though, because that is illegal in most areas, but feel free to glance at the work.
EDIT:
Important note: I don't develop games, myself, but they are great sources to understand programmer input and visual output. Look at David Brackeen's book and sources on his site. Interesting stuff, but not godly.