The “single implementation” paradox – redux
Following on from my previous post, my colleague, Adrian, has given the issue some thought and written an excellent post explaining his position.
His conclusion is that we should simply not be marking classes as final because it really doesn’t bring any benefits. Even if you’re trying to follow Design by Extension, the next guy is just going to remove the final keyword if it suits his purposes.
Sadly, I suspect he’s right. (Although there’s a conversation to be had here around collective code ownership, and assuming the last person did the best possible job. i.e. that final keyword is maybe there for a reason.)
Continue reading
Parallel Ant 0.9 beta released
After almost a year with no work, Parallel Ant 0.9 beta is finally released. More info on the Parallel Ant page.
The “single implementation” paradox
We got into a bit of a debate at work recently. It went a bit like this:
“Gah! Why do we have this interface when there is only a single implementation?”
(The stock answer to this goes:) “Because we need the interface in order to mock this class in our tests.”
“Oh no you don’t, you can use the FingleWidget [insert appropriate technology of your mocking framework of choice here – e.g. JMock ClassImposteriser]! I’m smarter than you!”
“Well, yes, you can. But if you’ve correctly followed Design for Extension principles, you’ve made the class final, right? And you definitely can’t mock that! Hah! I’m smarter than you!”
“Ah ha! But you could always use the JDave Unfinaliser Agent! I’m so smart it hurts!”
Continue reading
Unit testing smells
At work, we focus quite heavily on TDD and, therefore, unit testing (although our TDD extends to other levels, such as writing automated acceptance tests for a story before beginning development of the story). As is always the case with large bodies of code created by a transient group of people over a reasonable period of time, there are good bits, and there are not-so-good bits.
Today, I’d like to focus on some examples of the latter and talk about why I think they could be improved.
Continue reading
Generics and the mystical wildcard
This comes up a lot on the forums (or should that be fora?).
“I’ve got a List<?>, why can’t I put an object of type X in it?” (for any type X).
The problem here is that most people see the ? and interpret it as “anything” when in fact it means “something concrete, but unknown at compile time”.
Eh?
You heard me. You don’t have a “list of anything” there, you have a “list of something… I’m just not sure what”.
Eh?
Right then. From the top.
Continue reading