Some days, Java is all syntax and no semantics. Today I coded seven levels of indentation in twenty-five lines:
public void onLogUpdated() {
beginUse();
try {
synchronized (this) {
final SubscriberMessage next = log.getCurrent();
if (next == last) {
return;
}
last = next;
new SafeRunnable() {
protected void runProtected() throws Exception {
if (doesTone) {
soundTone(next);
}
if (doesAnnounce) {
soundAnnounce(next);
}
}
}.start();
}
} finally {
endUse();
}
}
A few lines of actual functionality and the rest is big heavy structure and great gobs of static typing. Normally when I end up with a scrappy method like this, I can see a simple way to make more understandable - but not today. Anyone have a suggestion for making this method nicer to look at?
Perhaps a cold beverage will help.