Monday, November 30, 2009

Unit Testing as an afterthought

Something you hear a lot in the development world is "We'll write unit tests if we have time," which usually means "we'll go back and take a look at the huge stack of code we are about to toss over the wall to QA and try to write tests for all of it." Quite often it is the case that some tests are better than none, but as part of a mature development process, this is the wrong way to view unit tests.

If your motivation for writing unit tests is that you do it so that you can put a check mark on a development process list, you are missing the point of writing the tests in the first place. Writing the tests as you go (as mini test harnesses to help quickly test and guide development, or immediately along with development to test edge cases and cyclomatic complexity pathways) helps you to write more accurate code more quickly, which is what most people would say their goal is in the first place when they set out to commit acts of programming on their trusting clients' code bases.

Very often it is the case that writing tests for a given piece of code leads to a much better understanding of the code under test, which helps to a) write the correct code and b) be able to explain and understand it later when you need to look at it again, or when a colleague or QA tester comes calling.

Writing unit tests is like showing your work in elementary school -- the point is not to write down an answer, it is to work through the process so that you understand what you actually are doing. And with unit tests we have an added bonus: the tests are repeatable and automatable, and they inform future developers (including the author of the code) of the intent and purpose of the code under test quickly and clearly, in a way that just reading the tested code alone cannot.

Sunday, September 13, 2009

Safari performance problem fix

I found the fix for the horribly-slow performance of Safari on the Mac: google chrome.

I'm a relatively new Mac OSX user so I am still getting used to the feel of things, but after upgrading to Snow Leopard last weekend the Mac mini has been noticeably slower, especially when using Safari. I check every now and then for Chrome on the mac and until today always hit a dead end. But, there now is a pre-beta version available for public consumption (google calls the early-access release levels "Dev Channel" and "Beta Channel," where "Dev Channel" roughly equates to "alpha.")

The difference is immediately noticeable: no more wait icon when trying to create a new tab, no more waiting while the tab contents are grayed out when choosing a previous page, etc., and switching tabs is snappy. From google's description of the Dev Channel it sounds like what is reasonably stable today could at any time become unstable, but the build I am using right now is working great, so no complaints at all.

Tuesday, June 23, 2009

iPod Playlist Genius ain't so smart

If the iPod playlist genius is so smart, how come it's always repeating songs from playlist to playlist?

Thursday, May 14, 2009

Thursday, April 09, 2009

Momus Iratus

I discovered a new blog the other day in the same vein as Violent Acres; if you like that, you'll love this one too. It's written by a mom who has a few things to say, and she's not afraid to say them!

I present to you: Momus Iratus. I recommend you give it a read, she has a great writing style and a natural talent for blog-post-sized story telling.

Wednesday, April 01, 2009

FSX pushback bug?

I haven't had a lot of time for PC gaming this year but when I do it's all Microsoft Flight Simulator for me. I got a copy of Flight Simulator X (FSX) for Christmas and it really is fantastic in terms of airports, scenery, and realism. The developers even wrote a patch that allows the game to utilize multiple CPU cores if your PC has them, which really boosted performance from the original version.

Anybody who has played the game or some previous version of it knows that even though it is fairly realistic, there is a certain level of suspension of disbelief at work that you need in order to have a good experience. For example, if you play the Caribbean Landing mission you'll notice there is an airliner holding short for the runway while you land. If you taxi clear of the runway rather than just ending the mission after a successful landing, ATC will clear the airliner for takeoff and you can watch him leave. As he is climbing out and turns away from the runway heading, he magically flies right through the mountain in front of him rather than crashing into it and comes out just fine on the other side. The same thing sometimes happens with floating runway lights, bouncing airport trucks, etc. These kind of things obviously are collision-detection (in the pixel sense, not the aircraft sense) related and don't really detract from the game.

The other day, though, I found something that felt like a bug in the gameplay: I was playing the African Relief mission (no spoilers here so don't worry if you haven't yet played it) and overshot the runway on my first landing on the dirt strip because I was carrying too much speed and couldn't brake in time before rolling a little way down the hill at the end of the strip. Not one to give up easily I tried to turn the plane around and taxi back up the hill but it was no go -- I was stuck. An alternative occurred to me: turn back around and try taking off down the hill and coming back around for another landing attempt. But, I didn't have enough energy even to turn around and the plane wasn't rolling back on its own. Just for grins I hit Shift+P, the keyboard command for "request pushback," normally used when you are parked at the gate and need a tug to back you up at an airport. To my surprise it actually worked! Out in the middle of nowhere Africa, on a hill past the end of the dirt strip I had skidded off of, an invisible tug started pushing me backwards and I was able to turn the plane around and attempt a takeoff. I botched the takeoff with a nasty bounce/stall/crash combination but I managed to refly the entire mission successfully the second time around.

So I wondered: was it really a bug, or is it plausible that when I requested pushback a bunch of the guys who were based at the strip ran over and started pushing us backwards for the takeoff attempt? I guess that explanation is believable and not totally out of line with other events that happen where you can't see the actors, but it seemed a little fishy to me.

Wednesday, February 18, 2009

Found key -- an ethical conundrum

Tonight after dinner I was talking on the phone with my daughters, pacing back and forth on the sidewalk near the restaurant where I had eaten, because it's agin' the law to talk on the phone without a hands-free setup while driving in California. While pacing I happened upon a key, not a car key, but the kind that goes to a building door lock. It had nothing no identifying information on it, and I felt like I couldn't just pocket it without someone stressing out big time if it was a lost key, so I had to come up with a plan.

Being the kind of person who thinks way too much about this kind of thing, I analyzed the situation and my options for how to dispose of said key:

1) Try all the business doors and loot, loot, loot! This has obvious negative repercussions, and, lack of religious beliefs notwithstanding, I'm not the stealing kind.

2) Truck on over to Ace Hardware, where the key evidently was duplicated, which I brilliantly deduced by reading "Ace" on it. This would require either a) walking across the street, which I think also is against the law in California and at any rate would take longer than just driving over there (no joke -- I tried it once), or b) driving there -- but that felt like just a bit more than I was willing to do, even given my strong feelings that I needed to do *something*. Plus, I doubt they would know to whom it belonged, so that seemed like a dead end.

3) Keep the stupid thing and not worry about it. I think I've already established that this was not an option I considered for very long.

4) Toss it through the mail slot of the door in front of which I found it with the hope that it either belongs to that business, or that they would find the rightful owner.

In the end I opted for number 4. What would you have done? Was it a copout and did I only succeed in making it someone else's problem? Genny suggested I return during business hours to inquire about whether the key made it home, which I thought was a good idea.

Only one room number has a locking cover on it

I'm staying at a hotel in the Bay Area this week and my room is on the fourth floor. One of the rooms I walk past to get to my room has a locking cover on it, like so:

It struck me as funny, in an oxymoronic way, to think of an herbalizer who is motivated enough to steal a 420 sign. It must be a problem, though, and it got me wondering how many other hotels have the same kind of problem.

10 points if you got the drug reference (minus 5 points for getting the drug reference; shame on you!).

100 bonus points if you get the nerd reference to my room number: 414.