Friday, April 28, 2006

NetBeans Plugins I Use, part 4: Auto Spell Check

WARNING: This blog entry was imported from my old blog on (which used different blogging software), so formatting and links may not be correct.

I went to the Update Center and went checking for new features. On the nbextras site I found a new feature I instantly fell in love with.

This is a spell checker which lets you register dictionaries (the English ispell one is bundled), and then your javadoc comments are checked for spelling errors while you're editing, much like the java code is checked for parse errors. Any errors found are underlined - and there's even a quick tip which lets you instantly (Alt-Enter) replace the word with similar words in the dictionary.

After installing this, I opened a couple of files from the JSR 273 project (under development), and it instantly pointed me to several typos I then fixed! Here's one of them:

The plugin is also smart enough to not report typos for names following an @author tag, and so on. And the options panel lets you register additional dictionaries. It's easy to find many free ones for ispell on the web.

Very nice! Thanks Jan Lahoda. Now where's your blog? Actually never mind, don't let anything distract you from writing plugins in your spare time...

Monday, April 24, 2006

Tabs Are Evil, Part 2: The Remedy

WARNING: This blog entry was imported from my old blog on (which used different blogging software), so formatting and links may not be correct.

A while ago I argued that you should completely avoid Tab characters in your Java source files. Use spaces for indentation. I won't repeat those arguments here. But even those arguing in favor of tab-indented source files agree that mixing spaces and tabs is evil.

The problem is that sometimes you're not aware that you're working on source with mixed tabs and spaces. This can happen easily if you edit the source files with an editor that has the wrong (as far as you're concerned) handling of Tabs.

To help avoid this you can use a simple NetBeans module I just committed into CVS, under contrib/fixtabs. You can grab the NBM file here and install via Tools | Update Center. I'll submit it to soon so you can get it there later.

Here's what the module looks like in action. If you for example open the JDK JTable class and look at the constructor, you'll see something like this (click for full size):


When you encounter files like this, you can go to the edit menu and select the action to convert the tabs to spaces. You can also turn off Tab highlighting here.

(Update 4/28/06: I changed this such that the "checkbox" toggle is now in the View menu, along with other view states you can enable and disable, and I moved the Convert action to the Source menu along with other source transformation actions.)

The module is similar to one of my favorite modules (which I guess I haven't described yet) - the "stripwhitespace" module. That module highlights trailing whitespace in the current source file, and lets you remove these. Not only is the fixtabs module similar - it's heavily based on the same source code.

Let me know if you encounter any bugs.

Tuesday, April 18, 2006

Learn Twice As Much With Same Effort

WARNING: This blog entry was imported from my old blog on (which used different blogging software), so formatting and links may not be correct.

You may be familiar with the
Universal Law of Gravitation.
And in schools and other auditorium settings, you may have observed the "Second Law Of Gravitation":

Students will gravitate towards the back of the class room. The seats in front
fill up last.

Perhaps students are afraid to be picked out by the teacher to answer questions. Or perhaps they are afraid to be seen as eager to learn.

However, at some point in college I discovered that actually picking those undesirable seats up in front
was a good idea. I've stuck by it ever since. In presentations at work I always beeline to
the seats up in the front. Why? I discovered that lectures actually seemed more interesting that way.
Perhaps there were fewer distractions between me and the instructor. Perhaps being up close
let me see and hear everything clearly, and perhaps occasional eye contact with the instructor
kept me from pulling out alternative reading material (e.g. computer books) if I got bored.

It turns out that if you sit in the center front, you will actually retain more
of the material. Research shows that if people are placed randomly and then
presented with information, people in the front, and people in the center,
can recall a lot more of the presented information than listeners to the sides
and back. And we're not talking 10% more. We're talking twice as much.

Retention in a class room based on seating positions [Source]














This has been called the "Attention Zone" by some, and the "Action Zone" by others. (Information retention is just one aspect we can measure; verbal interaction is another.) This has been studied in depth because it has implications for
class room design and student seating assignments.

Taking a seat in the front is a simple tip you can use to start enjoying lectures more. And you'll probably learn more. It's not exactly one of my
coding tips, but potentially much more useful.

Wednesday, April 12, 2006

NetBeans plugins I use, part 3: Quick File Chooser

WARNING: This blog entry was imported from my old blog on (which used different blogging software), so formatting and links may not be correct.

Don't get me wrong: I generally love the OSX user interface. But the one thing I can't stand is the file chooser. On other platforms, you can usually type the path you want to go to, but on the Mac, you have to drill down, with a mouse*, from one of the "root" directories - e.g. home, Desktop or Documents. Yuck.

If you're a keyboard guy like me, there is a solution: The Quick File Chooser. This plugin registers an alternate file chooser with the IDE, which is then used everywhere a filechooser is used.

The plugin is named the "Quick" file chooser for a good reason. Not only can I type in a path to a place I want to go more quickly than I can drill down to it with a file chooser (especially in directories with lots of files, such that I have to scroll to find the next intermediate folder to click on). But it also has additional shortcuts.

First, I can press the Tab key to force automatic completion. This works the same way as in modern Unix command line shells. If I've typed "P", and the only file in this directory that begins with a "P" is named "Projects", pressing Tab will update the path to "Projects". When there are multiple matches it will expand as far as possible.

Second, I can use environment variables again! Yipee!! I've really missed this feature. I used to do all my navigation with environment variables when I was an avid Emacs user. I had defined important directory locations with environment variables. For example, $D would point to the main debugger source directory; $E the editor, and so on. I could simply hit C-x C-f to open a file, and enter the path as $D/ to open the Breakpoint class. With the Quick File Chooser, you can again embed environment variables within the path, and everything is substituted correctly.

Here's a screenshot of the plugin in action. As you can see I've typed in an environment variable to jump to my NetBeans source tree, and I've started typing a path - and all the files are filtered down to the possible matches so far:

Thank you, Jesse and Tim!

If you want to get this module, go get it from The instructions for how to connect to it via the NetBeans Update Center are here.

*: There is an unintuitive way to jump to an arbitrary directory, in some applications, by going to the Search field and starting to type a path. Provided the first character is "/", this will cause a dialog to pop up where you can type the directory. But this is not a decent workaround, because it only works for absolute paths, there's no tab completion etc. And worse yet, many applications (including NetBeans) don't include a Search button next to the directory dropdown.

Tuesday, April 4, 2006

The year 2038 Problem

WARNING: This blog entry was imported from my old blog on (which used different blogging software), so formatting and links may not be correct.

I usually never care about post dates, but the time event tonight is too symmetrical to miss:

01:02:03 04/05/06

(This is assuming the American format where the month number is listed before the day number: hh:mm:ss mm/dd/yy.)

Remember back six years ago, when "millenium babies" were all the rage? People
were trying to time it such that their babies would be born right at the turn of
the millenium (and please don't post comments about millenium starting 1/1/2001, not

We didn't schedule our kids by desired birthdates, but my middle son ended up with an interesting
birthdate anyway: 101000. Okay, I admit that the date is interesting in a very nerdy sense...

Time events like 1:2:3 4/5/6 are significant only in that they have
a nice ring to them. Just like the switch from 1999 to 2000: three digits
in the current year changed. In an absolute sense the event has no significance: it's
only a round number relative to the point we designated as time 0.
And let's not forget the historical fudging with the dates... take a look
at the source code for the GregorianCalendar class in java.util for example and
look for October 1582...
Or just cheat.

Many unix systems use a millisecond counter to represent time. The designated begin time, zero on this counter,
is January 1, 1970.
Unfortunately, when older systems that still use 32 bit integers to hold this counter
reach the magical moment when the bits all roll
over, there's the potential for Bad StuffTM to happen. Which brings me back
to another millenium craze: y2k. It was a giant flop - or a resounding success,
depending on your perspective.

When we reach the millisecond timer limit in January of 2038, however,
we've got a whole new set of challenges to look forward to: the y2.038k problem.
And perhaps, lots of IT spending and OS upgrades. (64-bit Solaris uses 64 bits for time_t and has no
year 2038 problem.) Here's
more on the year 2038 problem.

And of course, year 2038 will bring a chance for truly nerdy parents to have a child with a birthdate
of 0, when expressed in unix milliseconds, truncated to 32 bits. Take that, millenium babies!