Apr 01

Chinese will build escalator on Everest is my favourite one this year. It actually got me at first. :-)

Nov 24

Driveway

driveway

Road in front of the house

road in front of the house

This last one is our new kicking ass office

office

Aug 16

I don’t like iPhoto. Functionality wise it’s a fine piece of software. But I can’t stand it storing three copies of the picture. One original, one modified and one nobody knows what it is for. Picasa, on the other hand, stores the changes made to the picture (kind of like a version control system) and applies those changes when you view or edit the picture. You also have the choice to persist the changes. Picasa was the only reason I’m not completely Windows free (Parallels has problems installing the latest Ubuntu). It’s not the case any more since I discovered Darwine a couple of days ago. As you can guess from the name, it’s a Wine port in OS X. I’m really surprised it’s not yet a well known solution for the Picasa on Mac problem. It’s easy to install. Picasa works really well with it (except for the stupid font). Here is a screenshot: screenshot

Jul 10

So Hans Reiser is guilty after all. I don’t know what to say. But I won’t stop using ReiserFS on the server where I keep all my precious files. I hope he’ll have a chance to keep contributing to the open source community during his 15 years to life time in jail (it’s not like he has anything else to do). The most interesting part of the whole thing is that he left so many obvious evidences (the car, the blood and the murder books) but he hid the body so well that the police wasn’t able to find it without his help even though it’s buried less than half a mile from where Reiser lives!

Jul 03

My coworker’s iPhone just became bricked. He brought it to the store. There was nothing they could do other than re-image the whole thing. And guess what? He’s never synced his iPhone yet. I guess there is one more thing for him to back up from now on.

As for my own iPhone, I won’t buy one unless it’s available from a carrier other than AT&T and I can simple pay 10 or 20 bucks for a data plan on top of the cheapest voice plan. Oh, it gotta be as small as a Blackberry Pearl and can be used with one hand.

Jun 21

Here is a picture of a beautiful rainbow in my backyard. Here are two pictures from our trip to Portland.

Apr 18

Seriously, why? It uses XML. So instead of

copy(dir1, dir2)

You gotta write

<copy todir="dir2">
  <fileset dir="dir1" />
</copy>

It has a useless conditional logic. You cannot just say if-else. You have to define a conditional target based on whether a property is set or not. Did they go through all these trouble just so that some incompetent developer won’t screw up? The more I use Ant the more I feel it’s not the right tool. Don’t tell me Maven. It’s better. But not too much better. It still uses XML. Why are people so possessed about XML? What’s wrong with building with an easy to understand scripting language? That way you have the power of a real language rather than a bunch of verbose XML files and a limited set of library. In fact, that’s what I’m doing now. I’m writing a Ruby script to generate the deployment descriptors for Gigaspaces (hey, I’m becoming like Alan Covington!). It’s one step further even though the main build is still Ant. But who knows, I might change all our Ant build scripts to something like Raven.

Feb 18

Just some updates about us in Seattle:

  • We finally settled down on a house with a view of Puget Sound. We are taking possession at the end of this month.
  • The job at Big Fish Games is getting better and better. It’s more intense than the days at CGI (I don’t think I’ll ever find a workplace more laid back than CGI). But I don’t really feel it because the domain is more interesting, the technology is cutting edge and I’m working with a great team.
  • I’m loving my new Blackberry Pearl.
  • And yes, if you haven’t found out from Facebook, I’m going to be a father in September!
Jan 14

Continue from the last post. Remember the JMock example I used? It’s a simple add() operation:

one (calculator).add(2, 2); will(returnValue(5));

Now, what if, just for fun, I used my own class called MyInteger instead of primitive int as the parameter for add() method? The expectation will be written like this:

one (calculator).add(new MyInteger(2), new MyInteger(2)); will(returnValue(5));

So I expect one single call to add() method with two parameters of type MyInteger. This simple expectation will fail miserably with JMock because it compare the expected parameters with the actual parameters using the equals() method. The persistence layer I’m using, like a lot of other similar products, prevents me from overriding the equals() method. So JMock is actually comparing the reference. I won’t be surprised if there is a workaround for it. But since I had SevenMock set up and running in ten minutes, I won’t spend my effort looking for those workarounds.

Tagged with:
Jan 13

I was trying out mock objects today at work. I didn’t really know which implementation to choose. Both JMock and EasyMock seemed pretty good. But I eliminated EasyMock first because I’m just not a big fan of the whole record-replay thing. Then I spent about an hour trying to make JMock work. It sort of did. But I didn’t really like its expectation mechanism. Take an example from their own tutorial. To expect one invocation of add() method on a calculator object, I need to write something like this:

one (calculator).add(2, 2); will(returnValue(5));

That is just too redundant to me. It’s also hard to return value from the method under test so that the workflow can continue. Overall, it just didn’t feel right.

Just when I was about to give up and go back to use my own stub class, I came across a link on JUnit’s site that points me to SevenMock. I spent five minutes setting it up and another five minutes to write the first test using it. And I really liked it. It doesn’t use any fancy expectation syntax and doesn’t have the record-replay feature. The expectation is defined in the form of anonymous inner class. You can put whatever you’d like to assert right in the inner class. So the above example will look like this:

mockControl.expect(new Calculator() {
  int add(int a, int b) {
    assertEquals(2, a);
    assertEquals(2, b);
    return a + b;
  }
});

Notice the return line. You can have the right logic there so that the workflow can continue. Or you can have something that doesn’t make sense at all to test the sad case.

One thing though. SevenMock can only directly mock classes. So you’ll have to create an adaptor for interface or abstract class. But I don’t think that’s a big deal. My next post will explain another reason that made me choose SevenMock: the assertion of the parameters.

Tagged with:
preload preload preload