Archive for November, 2016

Effective low-tech alternative to @formatter:off for Java

I love automatic formatting for source code. Back in 2004 I scrapped the detailed formatting guide for the project I was running and replaced it with a single sentence: all code must be formatted by the automatic formatter using the project’s conventions. Done. Sure, manual formatting can look better, but at what cost (and tedium)?

There are some places where the automatic formatter always fails, though, for example string concatenation for SQL commands. No problem, use @formatter:off and @formatter:on and there you are – until someone comes along who hasn’t enabled the tags. And disabling formatting completely can introduce tabs where there should be spaces, for example.

Fortunately there is an effective low-tech alternative that works everywhere (cross-IDE): comments! Use line comments after each line and the formatter can’t join them:

   "select something from some_table " //
   + " where some_column = ?"

It will still handle indentation.

Categories: Java

Windows 10 update issues

With Windows 10 there is no easy way to block an update. If Windows Update thinks you need it, well then there you are. Perhaps that is good, perhaps it is bad. I don’t like it. However, it turns out to be particularly nasty if an update fails!

In my case the printer driver for HP LaserJet CM1415 had a new version, but the update consistently failed. Not a big deal, the old driver worked well – or so I thought. Unfortunately the failure to install this one update caused Windows Update to ignore all others. It would keep trying with the printer driver every and keep failing. As a result none of the really important updates got through. So, if an update fails, don’t ignore it.

When that had been solved the Anniversary Update started, but consistently failed with a black screen. It took me some time to determine why. Apparently it didn’t play well with TrueCrypt (Windows Home does not support Bitlocker). Decrypting the drive for the update solved the issue.

Categories: Windows