twitter
    musings about technology and software development..

Windows 7 Shortcuts

Just thought I'd share some shortcut keys I use all the time:

Windows + D: Show Desktop
Windows + Tab: 3D Flip
Windows + #: Runs the #'th program on your Quick Launch

And in Explorer:

Shift+Right-Click on a folder/file: Additional options like "Open command window here"
Alt+Up: Goes up a folder level in Windows Explorer (plus Alt+Left/Right for Back/Forward)

My love for dependencies ...

Once upon a time, we had a developer whose full-time job was debugging random issues in some particular feature.  That feature had a dependency on an external team who had no vested interest in this feature, and therefore using their library was a bit like using chopsticks (their library) to eat steak (of course our feature is the delicious steak).  Sure, you can use the chopsticks, but every time you do you question whether you'd be better off without them and just eating the steak with your hands.

Couldn't get any worse, right?

So, when a different team approached us with a product that was a perfect fork and knife that they used to eat steak every day for the last three years, we chomped at the bit to get a hold of it.  Long story short, their utensils were made of plastic and were constantly breaking, and now we have two developers whose full-time jobs are debugging random issues in this feature. 

We long for the days of having chopsticks to eat our steak.  Do not take dependencies lightly.

Hard Drive Backup with Live Mesh

I hope everyone out there is backing up their data.  Up until now, I've used the tried-and-true method of copying my files periodically to another drive.  Of course, in the event of data catastrophy, I would lose all my changes since the last xcopy .. which was .. about 9 months ago.  A file backup gestation period, if you will.

In any case, I'm now using Live Mesh.  It's cross-platform and you get 5gb of online storage for free (you can sync unlimited data between machines).  I've synchronized my musics, videos, and documents between all my machines which is pretty fantastic.  In case you want to try it, here's what I would have liked to know beforehand:
  • You cannot synchronize your Desktop folder.
  • Your first 5gb of synchronized files ends up in the cloud. Choose wisely.
  • You have to login with a LiveID, but it doesn't share cookies with the browser.  So, if you will ever want to sync with a friend, create a new LiveID to share.
  • When you add a folder to be sync'd, it will show up on every other machine as a virtual folder.  This can be very confusing when you've named them all "Documents" -- prefix folder names with the computer name.
My next step is to set up a sync with my a friend in another state, in case my home with all my computers burns down.  Overall, it was pretty easy to setup, although I now have a paranoia that one node will decide to delete something, and spontaneously trigger all my files to be deleted on every machine simultaneously.

Concurrency bug..

OK, spot the bug in the code:

    object m_lockObject = new object();
    object[] m_collection = null;

    public object[] GetCollection() {
        lock (m_lockObject) {
            if (m_collection != null) {
                // already initialized
                return m_collection;
            }
            else {
                // needs to be initialized
                m_collection = new object[5];
                initialize(m_collection);
                return m_collection;
            }      
        }
    }
.. the bug is that a second call could come after m_collection is new'd up, but before it's initialized, resulting in an empty collection being returned.  The first call works, the second call sometimes fails, and the third call onwards likely succeeds.  Bugs like this can be a pain to track down as, depending on what these objects do, the symptoms will appear really strange...

Managing your time wisely

I'm one of those people who strive to be “efficient”. I learned this playing games like Starcraft. To win, you have to click like a madman to control everything at once. The best players were above 200 clicks per minute. And, you better type at light speed, otherwise you will get clobbered while writing messages to your teammates. At work, this means I don't sit around for process recycle or rebuild, I always go quick-check something else while I wait. I've read that your brain thinks at around 400 wpm (words per minute), so even if you type at a zippy 150 wpm then you are wasting braincycles. When I watch people type at a very reasonable 60wpm, it takes every ounce of resistance in my body not to rip the keyboard away and type for them.

So yes, patience is not one of my virtues. As a result, I cannot believe a 3.0ghz quad-code computer makes me wait. Ever. Everytime Outlook hangs while I'm in the middle of typing my e-mail, I can't help but flip it the bird. What on earth is it doing? If not for NetBIOS name restrictions, my computer's names would be !$(^$@( and %!%^(*.

Anyways, some tips for dealing with e-mail:

  • Reply to the e-mail the first time you read it. It takes a few minutes to context switch into a problem, so make sure to only do it once. Don't “save this mail for later“, because you'll either forget, waste time reading it again, or you're making the other guy wait. Even a brief initial response is often enough for the sender to figure the problem out.
  • Delete the e-mail as soon as you reply.  Don't worry, it'll be in your trash for a while, and you have your "sent items" to fall back on too.  But the net result will be a clean Inbox which reads like a to-do list so you won't lose track of things. 
  • If your response is going to be more than a paragraph or two, go talk in person. I could not believe how long it takes to craft a well thought-out e-mail -- try timing yourself sometime. And even then, the recipient usually just asks you to schedule a meeting and it quickly becomes clear they didn't even bother reading the mail.
Some tips for software development:
  • Invest in your development environment.  Spend time learning all the shortkeys, discovering ways to customize the tools you use every day, and get the hardware that will make you most productive.  Start with a new monitor. A big one.
  • Given that your typing speed is a constant, reduce the amount you have to type. I create batch files for everything -- "n" for notepad, "d" for diff, "b" to rebuild, shortkeys to take me directly to common directory paths, etc. I ditched my hardware KVM switch because of the two-second switching lag -- using software to swap desktops is instantaneous. It may not sound like much, but instantaneous is an order of magnitude better and can change the way you work.
  • Automate repetitive tasks. If you find yourself doing the same thing over and over, you can save tons of time by automating it. I've written tons of tools that do repetitive, labor-intensive tasks automatically, and your peers will appreciate it too when you share it with them.
Strategies that haven’t worked out for me:
  • Closing the door doesn’t prevent people from stopping by, and it shouldn’t. The fact that they invested the time to pay you a visit, means that it must be important to them. Ignoring them may only save you five minutes, but cost them an hour.
  • Having separate dedicated boxes for coding and e-mailing doesn’t allow me to focus single-mindedly on programming. It just makes me switch between machines all the time.
  • When I come in early in the morning, I don't get any additional work done. If I don't get sleep, I will spend the morning sipping tea and reading the news. Even more than usual.
What strategies work for you?

Communication patterns and diversity

Someone recently sent me a tool which measures whether your brain is left/right-hemisphere dominant, and auditory/visual. I am left+visual, and prefer logic and visual patterns. In a discussion I will find myself going to the whiteboard, even sometimes when it's not necessary, and highly prefer people draw their ideas out because I like having something to stare at.

Anyways, this sort of thing gets interesting when you have two people at the opposite ends of the spectrum. When they are trying to communicate, the visual guy may be drawing a diagram and asking "Why can't you see this?" to the auditory guy, who is thinking, "Why can't you hear what I'm saying?". Other communication examples are where one person wants to discuss big picture and the other wants to start with the details, or where one person prefers face-to-face and the other prefers e-mail discussions.

With a diverse group of people, the challenge is understanding everyone's points of view and having both sides alter their behaviors to accommodate each other. I've heard someone tell me that each slide in a presentation should have at most one sentence or picture, and bullet-points are the work of the devil. But I think a good presentation should appeal to both auditory and visual people, and not just one half or the other. As another example, a meeting with documents sent beforehand, provides face-to-face time via the meeting while allowing people to send questions/comments via e-mail. Small behavior changes like these make all sides feel comfortable and help everyone communicate successfully.
If you think Microsoft code is bad, you should read DailyWTF.  It has great coding patterns like:
   try
   {
     int idx = 0;
     while (true)
     {
       displayProductInfo(prodnums[idx]);
       idx++;
     }
   }
   catch (IndexOutOfBoundException ex)
   {
   }
And sweet UI dialogs like:
   Cancel print job?
     OK | Cancel
And stories about "C-Pound".  Yes, geek humor.

Writing Office client code

Writing Office client code is ... an experience.

First, everything is in unmanaged code, which means each line of code takes 5 minutes to write.  Why?  Because you have to check the APIs every time, to make sure you know who owns the memory and what the exact parameters are.  If you don't, you will get an intermittent AV or corrupt the heap and crash the app.  And, since none of the APIs are documented, you have to go trolling through the sources to figure out what the hell's going on.

Second, you get to use classes with interesting names.  For example, their web service APIs are still called things like HSUser -- long live HailStorm!  Then you've got funny ones like “BpscBulletProof”, obscure ones like “MsoGelIInsertSortPx”, and classes like “MSOGRFXMLNS” (buy a vowel?).

Third, Office has wrappers for almost everything.  I started by writing everything in standard C/C++, and it all worked beautifully.  But that was a big mistake, because none of it worked once I tried to merge it into the code depot.  I wasted the better part of a week translating ATLSoap to CBaseHSUser, vector to MSOPX, CMap to LKRHash, RegQueryEx to MsoRegReadWz, CString to CMsoString, and the list goes on. 

Fourth, the wrappers are actually pretty neat -- until you have to debug one.  Good luck figuring out what the author's intention was for “const WCHAR* const *rgwzArg” or “MSOPFNSGNPX pfnSgn” (I couldn't make that up even if I tried).  The time I saved using a “convenient wrapper” is quickly negated by having to figure out why my memory keeps getting wiped out.  It's like that movie Memento, but with a lot more swearing.

I think that's enough ranting for one post, back to work.

OK, now this is getting ridiculous..

Last time, they tore apart the roof and put it at my front door. This time, they got rid of the door!



In it's place was a tarp that was stapled on all sides to the frame. The problem is, this is the only way out! Trapped inside, I mulled about, ate breakfast, checked my email, but still my door was not to be found. Figuring I had to leave for work, I eventually pried the tarp off and crawled underneath. None of the workers seemed bothered -- did they expect everyone to do that? Strange..

My roof, my roof, my roof is on ... the ground?

I don't really know what goes on in my neighborhood, mainly because I never make it to the 7pm home owner meetings.  One morning, I was awoken by a loud pounding that shook the whole room.  When I opened my front door, this is what I found:


Apparently, a huge pile of my roof was lying there -- about two feet high... I hope it doesn't rain this week?