Archive for December, 2011

The Evils of Equals and Autoboxing

December 18th, 2011 | Category: Java, Programming

This was a fun, if particularly stupid, one:

public void method check(int value){
  if(this.x == value)
    //do whatever

the previous works as long as x and value are small, but not when they are big. Why? Because x is an Integer not an int. Java helpfully autoboxes the int by building an Integer and then does a pointer comparison. This still works for small numbers because java caches the lower Integer constants rather than creating them on the fly all the time so new Integer(value) actually resolves to the same object as x, but once the number gets big enough Java has to create a new object and then suddenly the comparison fails.

I actually don’t blame autoboxing for this one. Autoboxing was a good idea. Having == mean pointer equality (or really fundamental type equality) rather than actual equality combined with not modeling all fundamental types as objects was not such a hot move.


Seniority and Age in Software Engineering (No you aren’t a senior engineer)

December 17th, 2011 | Category: Programming

I’ve been thinking about this topic a fair amount recently catalyzed by a combination of getting older myself, some of the people I’ve worked with now and in the past, and where I see myself in them.

I think that sometimes the prevalence of youth in positions of power in the industry is over-stated by a few high profile entrepreneurs, however I will say I can’t think of many other industries in which someone with 5 years of experience in one job out of college might honestly consider adding “senior” to their title.

Now I’m not completely opposed to the idea on its face. After all, being at your job for a long time in and of itself shouldn’t imply seniority. Just because you have time to learn doesn’t mean you’re using it, there is no intrinsic reason that youth precludes ability, and the idea that age independent of any actual valuable input should continue to result in more pay and better positions is pernicious and wrong-headed.

On the other hand, there is something to be said for experience combined with programming ability. Having the experience of maintaining code you wrote, or someone else wrote, for a number of years teaches you a lot. Having the experience of interacting with customers over the years does too. It teaches you something about the bigger picture, the long haul. More importantly it teaches you things that you then see younger, smart, but green developers ignoring (I know. Get off my lawn).

I understand the feeling that motivates one to add the “senior” label prematurely and I agree that much of what passes for seniority is simply age, but there is real value to experience and we shouldn’t be so short sighted as to ignore it.

For the record, Mike does not refer to himself as a senior anything in either his professional or personal life.

The Author

Michael Smit is a software engineer in Seattle, Washington who works for amazon

1 comment

What is Good Design?

December 17th, 2011 | Category: Programming

You can spend a lot of time arguing about this question and I think many of those arguments tend to miss the point: good design is a process, not a result. Why is that?
Read more

1 comment

Why Your Junit Should Look More Like Cucumber

December 17th, 2011 | Category: Programming

I’ve recently gone back to writing Java and one thing that’s really struck me again is how JUnit (and XUnit frameworks in general) don’t do much to encourage clean tests. Don’t get me wrong, I’m all about unit testing, but a lot of junit tests aren’t very helpful.
Read more

Comments are off for this post

Composition vs. Inheritance (hint: usually not inheritance)

December 17th, 2011 | Category: Java, Programming

A co-worker of mine recently made the comment that a lot of times you see Java code using inheritance where composition is a much better solution. This is very true and worth pointing out.
Read more