Missing OO in Java

Stumbled across this post by Dave Churchville where he argues that J2EE has killed of OOP. I find it pretty close to the truth with the web applications we build. We don’t get to build a whole lot of first class objects. I find many of my developers haven’t grokked OO all that well, because J2EE largely allows them to ignore most of OO.

Learning A Language Through Unit Tests

Over the Xmas break I finally freed up enough time to do a shallow dive into Ruby via the Pickaxe book. So far it’s very enjoyable for a variety of reasons.

This is the first completely new language I’ve tried to learn after becoming test infected. It’s nice to do really simple things and keep executable tests around as a learning tool. So even very simple things like how Ruby handles escapes in single versus double quoted strings becomes

1
testSingleVersusDoubleQuotes

:

def testSingleVersusDoubleQuotes
  assert_not_equal("This line has a\n carriage return",
                   'This line has a\n carriage return')
end

I’ve seen Mike Clark take this approach to learning Ruby and Jeff Langr take this approach with Java 1.5, which is part of what gave me the idea.

Then there’s the shiny new toy aspect which is so far pretty obvious. Ruby is the new cool language. I think one advantage to this that I’m experiencing is that the Pickaxe book is a very good intro text to a language. I remember not really being happy recommending an intro book for Java programmers until Head First Java came out about 2 years ago.

Finally, there’s the simplicity aspect I find very appealing. Java and its associated frameworks, libraries, and tools has grown into a complex mix no one could ever expect to fully master. Ruby is at this point pretty simple. I haven’t even really looked at Ruby on Rails, but one web framework versus the plethora in Java does sound enticing.

Anyway it’s a good time of year to play with shiny objects.

Checkstyle Reporting Custom Exception Errors

For a while now I’ve seen the following error show up in our Checkstyle reports:

1
java.lang.RuntimeException: Unable to get class information for DataAccessException

There was a pattern to this where any custom exception couldn’t be looked up. After about 30 minutes of googling about usually just finding people’s checkstyle reports I came across the suggestion to take out</p>

1
RedundantThrows

</a>. That solved the problem.

Unit Tests Catch NPEs

A developer admitted today, after finally getting back to writing tests, that:

I’m finding a lot of places where we should have checked for nulls in our code.

I may point the developer to the Introduce Null Object Pattern tomorrow since it may avoid having to check for nulls all over the code base. Eventually we’ll write the tests first, but this is progress.

Slow Progress with TDD and Clover

As I’ve mentioned before our adoption of TDD is going slower than I would have anticipated. I’ve actually been religiously posting unit test counts on the wall of my cube for an entire Sprint now and we’ve gone from zero to 39 unit tests in that amount of time. Since that amounts to about a 10% unit test coverage in Clover we have a long way to go.

I don’t think the daily chart has done much to accelerate things, but now that the two developers on the project have a chance to catch their breath, I have seen that they’re paying a bit more attention to the clover reports especially the green bar. Now they’re saying they want to get to at least 50% on the reports and move the green bar up from it’s current lowly 10%. It’s even occurred to them that they can boost their percentage on Clover by setting a lot of properties in the beans. This isn’t exactly the outcome I want, but it does show they’re starting to think about how they can increase their unit testing coverage.

Similar to the short cycles of TDD itself, we’re starting to make those baby steps.