Setter injection sucks
I know it’s not trendy to re-hash old java programming discussions - I should be discussing some new amazing functional language, however I’m in a grumpy mood. I have a beef with what appears to be the dominant trend of using setter-based dependency injection. I’m an old-skool dependency inject-er - I started with picocontainer when Spring was unheard of (well at least by me). What I particularly like was the way it changed the way I designed my java code. (For the spring-kiddies, PicoContainer *only* supported constructor injection)
A common complaint I hear about constructor injection is “I don’t like having so many constructor arguments”. Yup this crossed my mind when I first came across it too - then it dawned on me: perhaps having too many dependencies injected into a class is a code smell? How many other classes should this class be collaborating with? Am I missing an abstraction in my model? Many times I’ve looked at a class and simply by looking at it’s constructor signature I’ve had a nagging doubt about it’s hygiene.
A big reason I prefer constructor injection is that I can ensure that when an [...]
Danger Will Robinson
I wrote my previous post about running linux on my desktop a couple of weeks back and realise I didn’t put a disclaimer on the post, so here it is…
IF IT ALL GOES HORRIBLY WRONG DON’T BLAME ME!
What I didn’t mention in my post is that the first time I installed vmware and loaded up the windows partition it worked great. Then I was tooling about in windows (I think uninstalling some cruft) and it required a reboot. No worries, but then my attention drifted and I went off to another desktop on the linux host. When I looked back a few minutes later I realised in great horror that the vm had automatically booted via GRUB into the ubuntu partition. I was looking at the ubuntu login screen, in a vm running on the same ubuntu install. Nasty feeling. Power off button on the VM.
Too late - everything in the running host OS started to unravel and I quickly crashed and burned. Someone in the audience will probably pipe up at this point and say “you could have recovered by xyz” but after a couple of people had a poke around with no success I took the quick [...]