Google have a nice equals method to make boiler plate equals easier to read. Particularly good if you have many attributes in the method. http://publicobject.com/2007/09/coding-in-small-with-google-collections_8175.html
Be careful to check that your objects are consistent with equals though. I have mentioned this before.
16
2010
Google Objects.equal, useful but be careful.
6
2010
TimeUnit use it more of the Time please!
Time for my first blog of the year. Yea! Mind you its a bit small, but then perhaps that is a good thing.
Look at these two setters. Setter methods like the first example are very common. Take a look at the second its so much better. With the second the [...]
14
2009
When you can’t avoid an out parameter
We all know its a good idea to avoid using out variables in Java. In almost every case the code can be split up to avoid the situation. Its bad semantics because when reading the code its not obvious which object passed, if any will get mutated. So the reader is forced to [...]
16
2009
Test anti-patterns project, contributors wanted!
I deliberately wrote a poor quality test, so that I could show how easy it is to re-factor it to a better one. I was driven by having seen lots of such poor tests and to be honest I don’t want to see another of its ilk again. I might write a test like this myself, but I would never leave it like this. Its part finished, littered with cut and paste, poorly named methods and hard coded values.
I show how to re-factor the test using several patterns for test fixtures. The setup stage is often the worst bit of a bad test. If you want to contribute some of your own bad tests and example improvements, read the blog, download the project and contribute!
31
2009
Neat multiset in google collections API
This good thing was so small that I almost did not bother to blog it
But the devil is in the detail so here it is anyway.
I have this multi threaded application. One of the problems with integration testing it is, you can’t guarantee the order that messages will be written to a stream. [...]