Movie: Dawn of the Planet of the Apes

This post does not contain any spoilers, unless you would consider as a spoiler my opinion on how the quality if the movie varies as the movie progresses. (Or the image below.)

Picture source: cgmeetup.com

So, I watched The Dawn of the Planet of the Apes yesterday, and what can I say, wow, it blew my mind. I started watching it having very low expectations, and I was very pleasantly surprised for about one hour and fifty minutes of its total two hour and ten minute duration, which includes the end titles. Then, starting with the "I am saving the human race" incident, it transformed into the crap that I had expected from the beginning, perhaps even worse, but that does not annul the fact that the first one hour and fifty minutes were one of the most pleasant movie watching experiences I have had in quite some time.

Read more »

The transaction pattern and the feature badly missing from exceptions

Exceptions are the best thing since sliced bread. If you use them properly, you can write code of much higher quality than without them. I think of the old days before exceptions, and I wonder how we managed to get anything done back then. There is, however, one little very important thing missing from implementations of exceptions in all languages that I know of, and it has to do with transactions.

At a high level, exception handling looks structurally similar to transactional processing. In both cases we have a block of guarded code, during the execution of which we acknowledge the possibility that things may go wrong, in which case we are given the opportunity to leave things exactly as we found them. So, given this similarity, it is no wonder that one can nicely facilitate the other, as this sample code shows:

Read more »

Bug reporting: a checklist

Here is a check list for creating useful bug reports:

  1. Before reporting, make sure that you are using the latest version of the software.

  2. Before reporting something as a bug, make sure it is in fact a bug.

  3. Before reporting, play around with the bug to identify it with at least a bit of accuracy.

  4. Report through the proper channel, usually an issue tracking system.

  5. Make sure that the bug has not already been reported.

  6. Invest some time to find a proper title for the bug.

  7. State the name of the product in which you found the bug.

  8. State the version of the product in which you found the bug.

  9. Describe your environment (Operating System name and version, etc)

  10. List the steps to reproduce the problem.

  11. State the "observed result" of following the steps.

  12. State the "expected result" of following the steps.

  13. State the reproducibility of the bug. (Or your best estimate of it.)

  14. Stick to the facts.

  15. Address only one bug per bug report.

  16. Include any useful attachments.

Here is a slightly more detailed discussion of each one of the above items:

Read more »

IntelliJ IDEA feature request: editor actions for moving the caret left & right with Column Selection

I just submitted a feature request for IntelliJ IDEA.

It can be found here: https://youtrack.jetbrains.com/issue/IDEA-132626

Feature request: editor actions for moving the caret left & right with Column Selection.

It is a fundamental axiom of user interface design that modes kill usability. Having to enter a special mode in order to accomplish something and then having to remember to exit that mode in order to accomplish anything else is bad, bad, bad user interface design, at least when there is even a slight chance that the same thing could be achieved without a special mode. (Think of VI for example: it is the lamest editor ever, and almost all of its lameness is due to the fact that it relies so heavily on modes.)

Unfortunately, programmers tend to think a lot in terms of modes, so the first time the user of an editor asked the programmer of that editor for the ability to do block selection ("column selection" in IntelliJ IDEA parlance) the programmer said "sure, I will add a new mode for this." That's how problems start.

Read more »

Why the 'final' (Java) or 'readonly' (C#) keyword is a bad idea

A quick look at the source code that I have written over the past couple of decades in various work projects and hobby projects of mine shows that the percentage of class member variables that I declare as 'final' in Java or as 'readonly' in C# is in excess of 90%. I declare only about 10% of them as non-final. By looking at parameters and locals, a similar ratio seems to apply: their vast majority is effectively final, meaning that even though I do not explicitly declare them as final, the only time I ever write to them is when I initialize them. I would have been declaring them as final, if doing so was not tedious.

Read more »

Assertions and Testing

So, since we do software testing, we should quit placing assert statements in production code, right? Let me count the ways in which this is wrong:

(TL;DR: skip to the paragraph containing a red sentence and read only that.)

1. Assertions are optional.

Each programming language has its own mechanism for enabling or disabling assertions. In languages like C++ and C# there is a distinction between a release build and a debug build, and assertions are generally only enabled in the debug build. Java has a simpler mechanism: there is only one build, but assertions do not execute unless the -enableassertions (-ea for short) option is specified in the command line which started the virtual machine. Therefore, if someone absolutely cannot stand the idea that assertions may be executing in a production environment, they can simply refrain from supplying the -ea option; problem solved.

Read more »