

Ask HN: Have you seen some beautiful Java Code? - beagle3

Recently I've been working in Java, on a project started years ago. All the code I see, whether developed inside this project or in external libraries, is horrible.<p>It is almost devoid of content -- hundreds of classes, each doing a few assignments and logging some data, and then deferring to another class.<p>I've seen some beautiful C code, e.g. the LuaJit2 compiler written by Mike Pall. I've seen beautiful C++ code in the FLTK project. I've found beautiful Python code e.g. in apenwarr's "bup" and "redo" projects.<p>But I've never seen any beautiful java code that gets something done clearly. Did you?
======
j_baker
I'm not a Java fan, nor have I read much Java code at all, but I'm willing to
go out on a limb and say that somewhere there exists beautiful Java code. Even
if for no reason that there's been enough of it written that somebody wrote
beautiful Java just by sheer luck.

~~~
beagle3
I'm sure there is. I want links I can review, because Java sucks the joy of
programming out of me.

~~~
gruseom
_I want links I can review_

What do you think of this? <http://sourceforge.net/projects/timeandmoney/>.

I haven't used the library, but its author (Eric Evans) is an old Smalltalker
who wrote a good book, _Domain Driven Design_ , in which the examples are in
Java. The book is immersed in OO but also kind of points the way beyond OO
into something more like "how to develop domain languages", which I find more
interesting.

------
slindstr
Yep, though it was internal to the company I used to work for. The project I
was on had probably one of the best teams I will ever be on - everyone (for
the most part) followed coding standards and if someone didn't then they were
called out on it. It was a pretty mature project, and though the source code
we inherited had been thrown together in haste, over time we refactored a good
deal of that code.

Whenever we had to write new code, we had to propose to our peers what we
intended on doing and how we intended on doing it. Keeping senior members of
the team in the loop kept the younger guys (like myself) in check when it came
to implementations and design pattern usage.

On top of that, a handful of the people on my team were RELIGIOUS about
writing comments first and then coding to the comments. All in all, it was a
great experience for me having been fresh out of undergrad.

------
jefflinwood
I've been developing in Java for a while, and a lot of Java code is ugly
because the "patterns" developers use are ugly. That's not to say that you
can't write great code in Java, but compare a Java app with JavaBean
getter/setters to Spring JDBC Template DAOs to a Rails app with ActiveRecord,
and it's no contest. Another source of ugliness is logging - logging libraries
that abstract away other logging libraries.

It was worse when EJB2 was the standard.

Take a look at the Play framework for some modern, non-enterprisey Java.

<http://www.playframework.org/>

