I’ve been Nestified: The Update

TL;DR version: A little pricy but I like the Nest Thermostat and Nest Protects.

In June, I installed the Nest Learning Thermostat in my house and over the Thanksgiving holiday I installed a few Nest Protects as well.  The integration of the Protects with the Thermostats and the application was really good although the install of one of the Nest Protects didn’t go quite like their install made it out to be. I could go on more about all of it but if you’ve read the reviews online, there isn’t more that I can say that hasn’t already been said.  They just work and work well.

Bullet Bros. Kickstarter

I normally don’t post stuff about Kickstarter stuff since they seem to get enough press as it is and I’m not exactly a high traffic site by any means but I just feel ashamed that the Internet as a whole hasn’t jumped behind a game as ridiculously awesome as Bullet Bros.  It’s Contra with a bit more craziness thrown in.  Here are a few videos, first the Kickstarter video and then an extended gameplay video.

Be a bro and support the game. It’s time we had another game that has the spirit of the original Contra and not all these terrible rehashes that get thrown at us every few years.

The danger of a poorly written equals in Java

Recently, I was refactoring a system at work and ran across a rather hard-to-track down bug after writing a unit test.  The data structure was an ordered list of what were essential ordered 3-tuples.  At first, the goal of the refactoring was to move classes into new packages then verify that nothing was broken.  Along the way of doing the testing I was alerted to the fact that the default set in the ordered set had changed and that needed to be updated as well and this is where the problem reared it’s ugly head.

I made the changes to the default set to mimic those on the server and then when I compared the new set to the set on the server, I was coming up short on the number of tuples.  Doing a diff of the rules showed two cases:

  1. Incorrect tuples
  2. Duplicate tuples
  3. Missing tuples

I quickly compared all the tuples I created to the tuples on the main list and verified that they were correct.  Once these were verified, I set a break point to see why tuples were missing.  As I stepped through the code I noticed that there was a point where the list stopped growing and items were being replaced when they shouldn’t have.  Obviously, this means we’ve got a problem with the equals.

Looking at the equals, the error was subtle, they attempted to use an != command on two Integer classes expecting it to compare the integer value of the class and not the hashcode.  I made the appropriate change to the equals method and re-ran the test and it passed without problems.

Of course, here I was able to write up what was basically an entire day of work in a few paragraphs… you’d think it’d be easy to spot a poorly written equals or even figure out that is the problem when you begin to see issues in production code.  However, the nature of production code and the complexities of the systems often lead you down rat holes in the search for the true problem.

Update on @Autowired considered harmful

After writing my post about the pox of @Autowired, I’ve been doing a lot of things with Spring and have softened my position a little bit.  Spring is a very powerful tool and, unfortunately, with anything that is powerful you need guidelines and constraints to keep from doing something stupid that will cause a lot of pain down the road.  Perhaps my hardline on @Autowired to not be used anywhere was a little short-sighted, however, I’m still weary of it in many cases (due to the experiences I’ve had using it).  Anyway, the new stance I have is that @Autowired should be used purely on constructors and kept away from injecting dependencies any other way.  As a wonderful side effect, this is allows you to hold true with Josh Bloch’s Effective Java rule to prefer immutability over mutability and fail fast.

Approaching the end of the line with school…

Last Friday, the 14th, I made a large step toward finishing my PhD – I passed the PhD Qualification Exam.  This means I’m now a PhD candidate and with just a bit more work I can write some more code, do some more testing, read more sources, and finally write a large document and do another presentation and after all that, hopefully be a PhD.  Or a doctor, but not the sort of doctor that helps people.