7

What open source Java code would you suggest for me to study?

EDIT: I'm interested in the design, simplicity(?), their programming style, logic.

EDIT2: The first thing that came to my mind is JUnit source code. I started looking into it and I was impressed by how 'Money' is designed/represented. Similarly are there any suggestible open-source projects.

Walter
  • 16,158
  • 8
  • 58
  • 95
HanuAthena
  • 171
  • 1
  • 4
  • Please detail a little bit more what you want to achieve. Learn new parts of the JDK, see how a big application is designed, etc... There are millions of lines of code available on the internet. – LudoMC Mar 26 '11 at 17:12
  • 1
    In general, I don't think that is how you should go about learning programming practices. – apoorv020 Mar 26 '11 at 17:39
  • @apoorv020 On the contrary, I think that's one of the best ways to improve yourself in programming, by studying code other people have written. – Jeff Welling Mar 28 '11 at 11:14
  • Are there any questions like this but s/Java/Ruby/ ? – Jeff Welling Mar 28 '11 at 11:20

5 Answers5

4

I suggest you pickup a good design book instead. Professional code usually does not explain important details such as "this is a factory pattern.". It also often contains loosely implemented patterns (if any) and custom requirements.

Design patterns are just far too complex to just figure it out on your own. It took the Gang of Four years to lay out the fundamentals. So its better to learn to do it correctly then see what others are doing.

Head first design patterns is a solid Java dp book.

Design and simplicity do not necessarily go hand in hand. Good design is heavily focused on proven use cases for a particular pattern. Not that the pattern is simple per-se, but that it works. Simplicity is as much an art as a science. It also requires a good understanding of the business requirements, framework and the customer. Keeping it simple takes years of practice. Even then time limits and reality plays a huge role in what's possible. Remember the triangle.

P.Brian.Mackey
  • 11,123
  • 8
  • 48
  • 87
  • +1: Simplicity is very much dependent on what you already know. – Steven Evers Mar 26 '11 at 23:31
  • 4
    -1: Strongly disagree, studying code done by professionals you can learn a lot. At times more than in a book. Although it cannot replace reading books but can be done side by side – Imran Omar Bukhsh Mar 27 '11 at 20:30
  • @Imran Omar Bukhsh - 100% disagree with you Imran. I see no way that an inexperienced developer trying to learn on their own by reading code could lead to anything but confusion. Without a solid foundation the inexperienced developer will have no idea what they are looking at. Especially without a mentor (which is the ONLY way I would suggest learning from code meant for real world usage). – P.Brian.Mackey Mar 28 '11 at 00:34
  • @P.Brian.Mackey Well to be fair he *did* say "Although it cannot replace reading books but can be done side by side" and written the way he wrote it, I agree with him. – Jeff Welling Mar 28 '11 at 11:17
  • @Jeff Welling - I still disagree. I've seen too many new developers sway way off topic when going through other people's code. "It is harder to read code than to write it." This is one of the core reasons I suggest to newish developers to read or get a job coding where they can learn from the other devs. – P.Brian.Mackey Mar 28 '11 at 15:02
  • @P.Brian Why did the swing off topic to begin with? Perhaps they found a better way of doing a part of one of their projects. Or maybe they found some comment that madethem reminisce of the old days, I don't know. I'm just saying I question the subjectivity or your statement. – Jeff Welling Apr 01 '11 at 04:31
  • Also, very frequently it's really difficult for newish developeds to get a job programming, and that is why I say they should read other people's source code: said code is freely available while programming jobs are not. – Jeff Welling Apr 01 '11 at 04:33
  • Are you implying you cannot learn from other devs by reading their source code? O.0 – Jeff Welling Apr 01 '11 at 04:34
0

I would suggest you this tutorial - http://www.macs.hw.ac.uk/guidebook/?name=Using%20The%20GUI&page=1. It would be difficult to study the source code without explanations.

bancer
  • 361
  • 2
  • 6
0

If your already with a software development company you may be in a better position to accomplish this due to being able to ask for help from various mentors within the organization, but don't be afraid of jumping in to source code regardless of career choice if you want to study it.

Studying with a mentor is ideal but not always possible, one way of looking for a mentor if you don't work for a development organization is through OpenHatch.org. If you get stuck and something doesnt make sense, ask for help or clarification from the original developer or from the FOSS community at large.

For a list of some projects you can freely study, you could check out github and search for "language: java" to find all projects in Java. https://github.com/languages/Java

Jeff Welling
  • 1,289
  • 1
  • 9
  • 15
0

Look at Spring Framework's code. It is neatly designed and well documented.

To improve your design skills, step into eclipse plug-in development.This is the best place to learn design patterns and put into practice.

Adisesha
  • 101
  • 2
0

One great project to study if you really want to dive into code is JHotDraw. It's an open source graphics framework written in Java as a demonstration of how design patterns can be used in practice. A member of the GOF (Erich Gamma) is one of the authors of the framework. The main page is at http://www.jhotdraw.org/ (includes links to the source code).

Deckard
  • 3,417
  • 1
  • 22
  • 32