Monday, June 25, 2007

The challenges of using and reading other peoples' code

I recently came across this post by Phil Haacked, and it's very worth reading and thinking about...

I completely agree with the the point that "reading code is hard" in this big world... Especially when everyone follows different styles things for things like naming, organizing code and designing systems...

Another way of making code easier to read that Phil didn't mention and that I really like to use (and many other people like to use too) is by writing developer tests with a testing framework (any member of the xUnit family for instance...). Not only will they help you get your code "right"/working, but someone who wanted to see what your code can do can look at your tests (or write their own) to figure out what your code actually does. To me, the underlying qualities of unit tests that facilitate this are:

  • in a test, you have to explicitly create the immediate environment/context in which your code will be interacting with - in OO terms, this is in terms of the state of your objects and their collaborators
  • the interface for executing the test is standardized - you pretty much only have to learn once where to put a test so that it is recognized by a test execution tool...
  • writing tests with the intention of running them sort of forces you to write somewhat testable code
I don't think developer tests are silver bullets since they can be overused and misused, but I think they can help in a number of ways, including helping to address things like readability.

I think another point worth mentioning is that code that is written not following good coding practices and that has bad code smells (such as long methods, cryptic variable names, etc) will be harder to read - I believe Phil received enough feedback that led him to link to this post on the topic.

Will the launch of the iPhone be like that of the Nintendo Wii, Sony PS3, etc...

I've already seen a couple of newspaper articles saying that supplies of the Apple iPhone (which is about to launch on June 29, 2007) will be limited...

Hmmm... I'm wondering if people are going to react to the launch of the iPhone like they did with the Nintendo Wii or the Sony PS3 - safety (remember articles like this?), long lines, reselling them (on eBay, craig's list, etc....)

To this day, I still haven't seen a Nintendo Wii at a store while casually looking!

Anyway, I'm sure people are going to love their iPhones (I think being able to watch youtube videos feature looks fun), but for me, I'm going to wait and see for a couple of reasons:
  • cost (of the phone itself and of the service plans)
  • I have a tendency to accidently drop things like cell phones, and I can't imagine how well this kind of device would work after being dropped
  • screen scratching - It will be interesting to see how long the screens stay pristine - with users being encouraged to use it as an input device and all....

Wednesday, June 20, 2007

My thoughts on the platform war (Apple vs. PC)

I've been thinking of getting a new computer for a while...

I've convinced myself it has to be a laptop so that I can use it on BART on my way to work, and other places while I'm out and about...

So I'm thinking to myself, "Mac or PC?". I've never owned a Mac. (wayyyyyy back when I had an Apple //c and Apple ][ + but never and Apple IIe or an Apple IIGS)...

A lot of things about a Mac Book Pro laptop looks great (can run windows, can run UNIX / Mac OS X, etc) BUT... only 2 (not 4) USB ports, 7200 RPM drive optional (not standard), and no button mouse (i'm not a big mousepad fan) **AND** a (relatively) huge price tag ($2000+ AND $300 for applecare). That's WAY expensive compared to *many* PC laptops selling for at least half of that!!!

(AND BOY AM I GLAD I DIDN'T GET A MAC LAPTOP WITH 802G BUILT IN... They just started rolling them out with 802N, and from talking to someone at an Apple store, apparently it might not be easy for someone with 802G to upgrade to N later down the road)

Don't get me wrong, a Mac seems to have a lot more soul than a PC (and running a more stable OS than windows), but 2k USD + for a machine with essentially wintel type hardware? Something doesn't make sense.... Sure there's cheaper Mac Books out there (used, smaller screens, etc), but when you're using a program like Live, you want all the horsepower and screen space you can get...

Ok, there's probably going to be a cheaper regular 15 inch mac book, but are prices going to drop on everything else too??? It's also perplexing considering that the iMac prices are relatively more reasonable compared to PC prices.

I really hope MacBook Pro prices drop a lot!!! (i.e. from "starting at $2000" to say, starting at "$1000"), otherwise, I can see myself doing a bunch of homework, getting a PC laptop with a built in webcam and an extra HD to do some OS swapping, and buying and loading Mac OS X on it myself (think OSx86). I just wonder what the guy at the Apple genius bar is going to think when he sees a *PC* running Mac OS X!

Tuesday, June 19, 2007

Welcome to my blog!

After reflecting on what I wrote about in my first couple of posts to this blog, and what I named this blog, I thought I should dedicate a post now to welcome you, the blog reader, to this blog...

This blog is the result of a couple of things, I think some of them good, some of them bad...

I still need to reassemble my domain, www.binaryshift.com, and a la 43 things I thought creating a placeholder blog would motivate me and make me accountable to bring my domain binaryshift.com back to its "glory days" (and maybe even surpassing them...)

Also, some of my blogging coworkers have been wondering why I haven't been blogging for ages (I've been lazy)

Anyway, what really led me to start a new blog (I've blogged a bit in the past, and I'll explain later why I stopped blogging where I was blogging) was a little while ago, I saw someone reading a newspaper article on how Google had just introduced software that would enable web applications to run offline... I was a little bit curious and that day read about Google Gears....

So I'm reading about Google gears and I'm thinking, "wow this is soooo cool... offline web applications are going to be huge.... so they've released the API that enables you to do this, but are there are any starter apps out there?" Come to find out Google Reader is the first big gears enabled google web application, and now I'm thinking, "wow, now I can start reading blog postings on BART"... Now you're probably thinking "I've been able to do that with x (y and z)", which is probably true, but I work on a bunch of different machines (3 at home, 1 at work, a different one on the way to work), and I never invested the time to figure out an infrastructure to read blogs and stay in synch... So anyway, a couple of days go by, I do the occasional synch and set up the odd blog or two, and one of them happens to be the official google test automation blog (which I had never heard about)... I saw that one and I'm thinking "oh yeah, this is a maven trap (ala "Tipping Point") since I'm test infected! So I see the a posting on "TotT" and figure out that means "Testing on the Toilet", and it just happens to be non-work day for me, so then I'm thinking "oh yeah, my co-worker just set up a blog for ASP.NET technical questions with blogger, maybe I should just set up a blog there too", and the rest is history... (blog created, posting with link to testing on the toilet created).....

Fastforward a few days, and I'm talking to another co-worker, and he's basically asking "do you like testing?" and I essentially said, "I see it as an essential part of developing software"... (and when I say developing in that last sentence, I am referring to the "coding" aspect)...

I see testing (especially automated testing) as a way of measuring progress, giving you the tools to that can enable you to say "I'm done this (for now)", giving you confidence that you haven't broken anything (by enabling you to re-run existing tests), and creating feedback loops... However, I'm not surrounded by co-workers that have the same view or passion...

Anyway, this is part of the chain of how this blog came about... It's time I share some of my thoughts again with the world, and the coming together of a day away from work, blogging, toilets, testing helped a bit too...

While I've been making a living as a software developer for a number of years now (and have explored things like Agile methodologies and some of the coding related XP practices including continuous integration, TDD and refactoring), I (unfortunately) haven't worked in what I consider a true XP shop (yet)... that is, one that includes other practices like story cards, pair programming, and iterations, etc...

I have spent a little bit of time here and there with Ruby on Rails, and have used pure Ruby and PERL to automate certain tasks at work while working on PowerBuilder and .NET projects at work

As of late, since I'm working at an Investment Advisory firm, I've taken some business, finance and accounting classes to build up some financial and business knowledge. These classes are offered either online or at night time at UC Berkeley Extension in San Francisco. I've met some nice people (teachers and classmates), and have definitely learned a thing or two. I'm 2.5 courses away from completing all the courses required for the Investment Management finance certificate.

In my (limited) spare time, I love to do racewalking, ride my bike, and tinker around with a very special, revolutionary music making program used by some very cool artists (many mentioned here)

I think that I now have the thoughts, energy, and means to do a post a day (my current goal). To remind myself, and to inspire others, my sources of inspiration for postings will include:

- the ideas in my mind that I've wanted to put down (and not just on testing)
- my reactions to other peoples' blog posts and web pages
- conversations I have with other people
- comments on links from my online bookmarks

Thanks for reading, and I hope you find this and my other upcoming posts entertaining and informative!

"The Secret" worked for me today!

I woke up a little bit later than usual this morning, and as a result also left for a work a little bit later than usual - however, since I take BART to go to the city, one of the problems I've run into is not getting a parking spot (this has happened to me before), at the station usually go to, which means either parking somewhat illegally at the station, or having to drive to another station and being even later for work....

To those outside the San Francisco Bay area, I will explain a few of the terms I used above:
1. BART is essentially a "commuter train" - but unfortunately not as fancy as Caltrain
2. "The City" is the common name around here for San Francisco

Well, this morning, as I was driving, following the advice of the Secret (which I guess is no longer a secret to those that care or watch Oprah or both), I told myself (over and over) "The parking lot is probably almost full right now, but don't worry, there's going to be a spot for you"...

[I know very little about the Secret - I've heard mentioned that it has to do with the law of attraction - if you think something... it will happen... I've also talked to some people who think it's a scam to make the creator rich... I'm open minded, but I can understand that kind of point of view too.]

Well, the parking lot was full, but there's a couple of side streets that I know you park at all day and not get a ticket, and guess what.... I start driving down one of those streets, and there's cars lined up on both sides, and I'm thinking "this secret stuff didn't work for me this time, crap"... and then halfway down the street, lo and behold was *my* parking spot *waiting* for *me*. All I thought was "wow, maybe the secret does work after all" (only once in a while?)

I haven't used the Secret too many times now (only once or twice in weeks maybe), but maybe positive feedback loops might encourage me to use it more....

Which now brings me to thought that just came through my mind - I saw a little bit of the 20/20 segment on ABC which was on luck, and one of the segments was on a guy named Scott - the guy who prides himself for wearing a nametag all of the time. After doing a little bit of research, I found his website to be mynameisscott.com - one of the thing he wrote that I read about is how he even started wearing a nametag - he said he had been to some function that required him to have a nametag, and he left that function with his nametag on, and he struck up a bunch of conversations with total strangers (about his nametag?) - well it sounds like he did some interesting math and thought that if wearing the nametag (making him approachable, a conversation starter, etc.) would lead to x number of conversations in one day, it could lead to x or more conversations each day he wore the nametag - another feedback loop.

Thinking about these things really makes me want to become more aware of more of feedback loops that we all experience, and their powers.

Sunday, June 17, 2007

Google Testing Blog: 8-year-old exploratory testing

This (Google Testing Blog: 8-year-old exploratory testing) is an interesting posting I came across today on exploratory testing... It made me want to write a few words...

First, I noticed that when I Googled "Exploratory Testing" today, the first adsense link was for jobs at Google (i.e. www.google.com/jobs) - which I think is a subtle hint that Google takes this kind of testing seriously ;)

You can also find a decent article on Exploratory Testing by James Bach, which I skimmed through and found quite interesting (www.satisfice.com/articles/et-article.pdf)...

Back to that blog posting (http://www.cs.nyu.edu/%7Emichaels/blog/?p=15) was also a good read... I remember Logo being one of the first programming languages I used (after basic) - it would be so cool to make that turtle move around!

Anyway, I thought it was cool that an eight year old could bring down logo, but I think it's debatable whether this is actually exploratory testing... I don't think he/she actually meant to crash logo, or say "I'm going to put on my Exploratory Testing hat on for a minute".

To me, one of the best things about exploratory testing, is it can be done both at the white box and black box level, and that if you do your homework (structure your code properly, etc), you could write developer tests (the term I prefer for xUnit "unit tests") to make sure you deal with things like bad user input properly.

Another interesting thing that this posting brings up is the fact that even though something may have been around a long time (I played with logo back in the mid 80's) and be relatively stable, it doesn't mean there isn't a chance you might unexpectedly find yourself in an exploratory testing situation.

How much testing should software undergo? Does software undergo enough testing? These are things I'll be pondering... (and I hope you will too)

Thursday, June 14, 2007

Google Testing Blog: TotT: Extracting Methods to Simplify Testing

Here's something I came across that was amusing....

Google Testing Blog: TotT: Extracting Methods to Simplify Testing

I figured out that TotT means "Testing on the Toilet"

There's a link to a PDF that you can print and leave in different places (including the toilet I guess) to share some good programming tips :)

I'm surprised that Marin Fowler's book "Refactoring" was not mentioned, but maybe previous installments, which I'll look for mention that book.