Friday, March 16, 2012

Writing exception messages.

I recently changed an exception message from this:
throw new IllegalStateException("It appears the init() function has not been called.");
To this:
throw new IllegalStateException("private member object 'thingamagjig' is null. Has the init(T thingamajig) function been called?");

This is because I realized that there's a variety of reasons that the 'thingamajig' might be null, aside from the init() function not having been called to initialize thingamajig.  It was more important to communicate the actual diagnosed problem and to clearly communicate the possible cause of it, than to jump right to the conclusion that init() hasn't been called.   The question is a good rhetorical cue that "maybe you should look here first" without saying "this is the cause, dummy" and perhaps being the dummy instead.

Monday, March 12, 2012

Migraine themes

I occasionally get migraines - mild enough to be livable, but harsh enough to make looking at my screen difficult.  Here are a couple things I did to improve looking at my screen.

Because this was so difficult, I think it might be worthwhile to set up an alternate login/account, or even just work from home with such an account if it's hard to get it set up at work.

Edit/Update: I've since learned you can significantly reduce the effort to invert colors by using the magnifier in Windows 7+, or inverting colors in Linux using a compiz fusion plugin that allows it.
  1. Windows 7 Theme: Adapted the High Contrast Black theme to a "Muted gray and black Migraine" theme.  Here's a link to it.
  2. Google Chrome: installed an addon called Change Colors, and activated it on all sites; 
    1. I set the colors to 
      • Background: 2E2E2E
      • Text Color: D4D4D4
      • Links color: 3283ED
      • Visited Links: 9B51DB
    • For some sites, I had to click on the addon's icon and disable it for the page or domain.
    • I also installed a theme for chrome.  Things like this one.
  3. Internet Explorer: Tools > Internet Options > General (tab) / Appearance (bottom panel) :
    1. / Accessibility (button) > Ignore colors specified on web pages
    2. / Colors (button) > adjust colors in the same ways as I did with Google Chrome.
      1. OR just check the box to use windows colors.
    3. Note, this also seems to have affected Firefox
    4. Note, these settings affected a LOT of other programs, that apparently key off of Internet Explorer.  The most notable one was Grindstone.   So don't discard these settings--they help even if you don't use IE much.
  4. Firefox
    1. Installed a plugin called "Blank Your Monitor: Easy Reading".  It worked moderately well.  I think made some mistakes with this plugin: mostly that I also configured firefox's default colors.
    2. Also, I updated the default web page colors for firefox:
      1. Tools > Options (or "firefox" menu > options)
        1. Go to the content tab (tabs listed along the top)
        2. Look at the fonts&colors panel (a heading halfway down)
        3. Click on the "Colors" button
        4. Customize the colors similarly to Internet Explorer OR click "use system colors" to use the Windows 7 theme.
    3. Install a dark-themed persona, like "dark fox"
  5. IntelliJ IDEA:
    1. I spent a bunch of time working on a color theme.
      1. It was saved in C:\Users\{my username}\.IntelliJIdea10\config\colors
      2. You can download my color scheme here.
    2. Note that IntelliJ also uses the Windows theme for many colors, and IntelliJ itself has some bugs and issues with its color scheming.  It'll never be perfect, but it can be better.   It was because of IntelliJ that I couldn't go with a straight black Windows 7 theme background.
  6. Microsoft Office Ribbon
    1. In Outlook, I went to File > Options > General > User Interface Options > Color Scheme: Black.
  7. Pidgin (my chat client)
    1. Followed the Windows color scheme.  Some buddies have clients that always set their font color to black.  I asked them to use a gray text, but I think I could have set an option to ignore formatting from buddies.
    2. If buddies use annoying formatting, you could just do Tools > Preferences > Conversations > Uncheck the box labeled "show formatting for incoming messages"
  8. Google's apps
    1. It appears gmail has a dark colored theme, but despite every effort I could take, when I compose or read messages I can't view them on a dark background.  I would suggest setting up an alternate email client to connect to gmail's POP or IMAP interface.
    2. It sometimes helps to use a "Darken" bookmarklet I found, but it often isn't very discriminating--so I don't even provide the link.

Now that I'm feeling better, I want a mid-gray color scheme.  I still don't want white backgrounds, but I'd like something that isn't glaring white backgrounds either.   As a solution, I tried these two themes:


I also wore a hat and sunglasses, inside, so I could stand to look at my computer screen.  I do NOT recommend polarized (wal-mart) sunglasses for computer screens--simple shades should work.  The hat helps fend off overhead florescent lighting and the shades just darken everything up a bit.

Some other tips I picked up in various places online, that I'd like to try next time:
  • Get a monitor with a higher refresh rate (not 60 Hz)
  • Don't work under florescent lights, especially at 60 Hz.
  • Make sure your screen and things around it are about the same brightness.