Tuesday, September 8, 2009

Programming in the Holy Land

My visit in Israel is drawing to a close. The only reason I haven’t been updating my blog lately, is that I was having too much fun doing other things :)

For the last month I’ve been meeting friends, ex-colleagues and potential customers at an average rate of 2 meetings a day. There are several cafés around my apartment where waiters now recognize me by name :)

Since this was mostly a work visit, I’m actually spent a large chunk of my time programming and communicating. Other than the challenge of communicating with customers who are 7 or 10 hours behind (boy, the shoe is really on the other foot for me), I also ran into several development challenges that reminded me of my early startup, 14-hours-a-day, days. Here are 3 basic development truisms that I learned the hard way before, and I’m relearning again:

  1. Your chances of making errors after 2am are close to 100% – I had a call with a Californian customer at midnight Israel time, and just had to finish his class before going to sleep.

    From 1am to 1:52am I wrote and tested a class. At 1:53am I accidentally deleted the class, by pasting the contents of another file into the class file. At 1:54am I uploaded the faulty class to the server, found out it was faulty and spent 5 minutes realizing I just erased all copies of my last 2 hours’ work in a second.

    The time from 2:01am to 2:05am was spent cursing in every language I know (and believe me, I know a couple of bad words in quite a few languages).

    At 2:10am I arrived at the conclusion that this was a sleep deprivation mistake. But did I go to sleep it off? Noooooo. I spent the next couple of hours re-writing and re-testing the class from scratch (even made it better the second time around). I just can’t go to sleep with an open problem – but those were 2 hours of my life I could have saved had I let the problem wait till morning.

  2. An extra pair of eyes for 5 minutes saves 5 hours - when you code alone you might make tiny errors/omissions that are immediately obvious to someone else on first sight, but which you may fail to see even after checking your code a 100 times. I spent a few hours looking for an issue (see #3 for description), but as soon as I discussed my frustration with another developer, 5 minutes into the conversation he already put me on the right road to the solution. I guess everyone needs a sounding board once in a while.

  3. There is such a thing as “too thorough” – this section is directed at the idiot developer who decided Ajax calls should be cached in IE8. [Feel free to skip the nxt paragraph if you're not interested in the nitty-gritty].
    Explanation: Ajax (Asynchronous JavaScript And Xml) is a web programming technique that allows getting data from the web server to a web browser without refreshing the entire page. It’s meant to allow developers to update parts of the page dynamically, without requiring the user to refresh his browser (think of stock tickers, or news headlines that change constantly, while you watch). I emphasized the word “dynamically”, because it contradicts the word “cache”.

    While caching pages, images, scripts and style sheets on the client side improve performance and make sense, caching dynamic requests makes no sense at all. And every browser maker in the world knows this – but Microsoft. IE8 caches Ajax calls - meaning that if you call the same URL over an over again, every call past the first will return the same data – regardless of the fact the data has changed at the server.
    I just couldn’t understand why I’m getting the same data when another open IE tab displayed different data from my server.
    The person who assisted me (thanks Dror!) pointed me to this trick. Basically, you add a random number at the end of the URL, thus “cheating” IE8 to think it’s different than last call, and going to the server to get the results rather than the cache. Upon further research, I discovered that since I’m using jQuery’s $.ajax() function to make my ajax calls, I can simply pass it a parameter {cache: false} and get rid of caching in IE8. What I later found out is that all this parameter does is add a random number at the end of the URL behind the scenes… :)

    Oh well, guess we’ll have to cheat IE8 until IE9 comes out.

Finally, I wanted to report that less than a year after reporting on the early beta of Windows 7, I finally installed the RTM version and it’s up and running nicely on my T400 (in fact, I’m using it now to post this). Even the virtualization features work nicely – albeit slower than VMWare. So on the OS front, hooray to Microsoft!

My only beef is with the lazy engineers at Lenovo who apparently didn’t have enough time to develop all the necessary drivers, despite having access to a version of Windows 7 for more than a year…


Gal Granov said...

next time u come for a visit, drop a line and maybe we can say hi.

btw; did u check out our new blog: (me and kfir bloch's)


avi said...

I found that 2AM (and 6AM, as well) are the most creative hours. They are by no means the most productive hours, though.