2009-12-21

code complete 2 sucks

I've been on a bit of a non-fiction book bender recently.

After reading a number of the books on Coding Horror's Recommended Reading for Developers including:
The Mythical Man Month
Peopleware
The Pragmatic Programmer
as well as:
Facts and Fallacies of Software Engineering
As well is the often referenced Godel Escher Bach,
All of which I've enjoyed, and found relevant to my work and software interests.

I thought, Code Complete 2 would be worth a look.

I can't believe how wrong I was.

After reading something as deep an complex as GEB on the train to and from work everyday, I figured I could read anything.

Again, I can't believe how wrong I was.

I've found it dull, obvious, pointless and most of all overly specific.
Maybe the book just isn't aimed at me. I've had a few years of full on develpopment in a number of OO languages, with pretty comprehensive testing layers.
I haven't been able to get passed the third chapter due to extreme bordem.

I would not recommend this book to experienced developers.

Being a fanboy really does work

I've recently realised that I am a scala fanboy.

When people complain about some problem in their chosen language/framework, my first thought is, "in scala they've solved that problem with _ .".
When I was writing the above sentence, my first instinct is to use the underscore character _ to match whatever scala feature it was I was thinking of. ( _ is a scala idiom which matches anything)
During a "Design patterns" study group, my reaction when I start to understand a pattern is, "oh, that's how people get around not have scala_feature_x".

But it was when I started vocalising these thoughts, that I realised that I was a fanboy.

The suprising thing is:

it actually works.

People are actually listening to my constant "scala, scala scala".

There's at least 4 solid Java developers I know who are now interested enough to start playing around with the language.

I always thought that fanboys were people who just didn't understand that noone else cared about what they cared about, but it turns out that there are people out there listening to fanboy rants.

The other alternative is that I'm actually a scala 'evangelist', but I think you have to get paid for it to be called an evangelist.

anyway, read this:
http://www.codecommit.com/blog/scala/roundup-scala-for-java-refugees

and this excelent book:
http://www.artima.com/shop/programming_in_scala

I'll probably have to buy the t-shirt, AND the mug; but I'm not quite ready for the hat though:
http://www.scala-lang.org/shop

oh yeah, scala rocks!

Update:
While I was writing this, yet another of my Java Developer colleges showed interest in scala, and mentioned having to look at it further :)

2009-10-25

The logically impossible is possible

In Java, how do you avoid a NullPointerException?
Easy, you test if an object equals null before trying to call any methods on it. Any idiot could tell you that.
What do you do when that null check is what is throwing your NullPointerException?
That's not so obvious ...... you fix your classpath.

So I'm running some JUnit tests in eclipse, and a particular test is throwing a NullPointerException.


Line 53's throwing NPE I think to myself, easy I'll just add a check for null. The problem was, that line was already a null check. So I fired up the debugger to try and work out what was happening. The eclipse inspect feature is great, so I put a breakpoint on line 53, and inspected the variable, yup it's null. I then inspected the null test, and it resolves to true.



So why is it throwing NPE when it's executed? What the hell is going on here?
After double and triple checking that I wasn't just going crazy, I sat back and brain stormed some possible causes for a check for null actually causing a null pointer exception.


nothing.


I've been in a similar position a few years ago; I was debugging some code and it seemed that eclipse was telling me that true == false. Yep, despite what I learned in philosophy, the logically impossible actually is physically possible. It turned out to be a combination of null values, autoboxing, default values for Booleans and eclipse's inspect function. 


With that memory I started making random changes to the variable and surrounding code, to see if anything would change the behaviour. Finally I made a change that removed the references to the null object, and found that I was still getting the NPE. This shouldn't have happened. Somehow my changes had no affect on the outcome. Then it hit me, the file I was modifying wasn't being used in the classpath. I checked my eclipse classpath, and for some bloody reason, someone had put a pre-compiled jar of the very source code I was modifying into the eclipse classpath. That jar was needed at deploy time and was built by our ant build scripts, but shouldn't be referenced by eclipse as you can just reference the project itself. I removed the jar from the classpath, and all was well.


The question is, why would the debugger take me to that source code instead of to the class file in the jar that was actually used at run time? I guess eclipse was confused by having multiple versions of a class, only one of which had source code.


I'm sure there's some kind of moral to the story here, "think outside the box", "rely on your experience", "nothing is impossible",
but it's probably something more mundane like don't screw up up your classpath or even better null is evil.

2009-09-28

Sending drunken, slightly irate, awkwardly worded, overly formal emails of complaint really does work!

Remember that great album you heard or had years and years ago? You know, the one that you can't find anywhere. For some reason no one has it, or even heard of it.

I was thinking about an album like that a while ago, and after a few beers decided to send one of those ill advised drunken, slightly irate, awkwardly worded, overly formal emails of complaint, to the artist.

Hello,
Many years ago I heard an album by a group called "Itch-E & Scratch-E".
I very much enjoyed listening to this album, and would much appreciate doing so again.
I have looked and looked, and cannot find said album anywhere on the inter-web.
Can you please direct me to a proprietor that has, in stock; the album "Itch-E & scratch-E and friends",
This album had songs with themes ranging from "wolves howling" to "space station number 5".

Thank you for your time, and consideration,
Having completely forgotten about the whole thing, I went on with my life.
7 months exactly (to the day) later I actually got a response:

We are in the process of making this album available in itunes.

Keep an eye on http://www.paulmac.com.au/ for updates.

Kind regards,
Adele.

 Yay! At the time, I couldn't find a single reference to the album, and soon it's going to be on iTunes. Yes you heard it here first: "Itch-E and Scratch-E ... and friends"cira 1994, will soon be available on iTunes! Pity I don't/won't/can't bring myself to ever use iTunes. oh well.

So the moral of the story is that I should send drunken emails, (especially to "famous" people) complaining about random crap that I can't even find a reference to more often ....