Toxic Elephant

Don't bury it in your back yard!

I'm Not a Mockist

Posted by matijs 04/11/2007 at 13h56

Let’s talk about mocking.

It apparently is the hot new thing in Rails land. And like earlier silver bullets, it’s becoming a religion: Acolytes would rather write ten lines to set up a mock object than one to instantiate an actual one.

Honestly, I have tried to understand the benefits of mocking, but I just don’t see them1. Then I thought I would have to write a long article about how mocking is flawed, and would you people please all see sense already. Luckily, Martin Fowler did it for me, and with a lot more objectivity. Go read his Mocks Aren’t Stubs. In addition to explaining the difference between Mocks and Stubs (a difference often overlooked by the religious), he explains why you might not want to use what he calls “mockist testing”.

So, in the spirit of religious tolerance, I can now say: I’m not a Mockist.

My particular reasons?

  • Mockist testing is not DRY: Each class’ behavior is now defined in its code, its unit tests, and each time it is mocked.
  • Mockist testing tests a particular implementation of behavior, making refactoring harder.
  • Mockist testing makes writing your tests more work, inviting you not to test.

Next time you find yourself complaining that setting up your mock objects is such a lot of work, ask yourself: “Am I a Mockist?”. Maybe you’re not.

1 Well, one minor benifit I can see that you can start writing and testing your views before having written your models. I never seem to want to do that anyway, though.

Tags no comments no trackbacks

Undressed Ruby

Posted by matijs 14/10/2007 at 12h14

In Ruby, there is really no compile time. There is parse time, and then there is run time. All class and method definitions are done at run time.

class Foo def bar puts “Zoo!” end end

is basically1:

Foo = Class.new do self.define_method(:bar) do puts “Zoo!” end end

See, we just removed the class and def keywords from Ruby. What else? Ah yes, method calls. That’s just sending messages. In fact, you can replace any method call foo.bar with foo.send(:bar), like so2:

Foo = Class.send(:new) do self.send(:define_method, :bar) do self.send(:puts, “Zoo!”) end end

How much syntax can you remove like this? How far can Ruby be undressed? And can you come up with a macro system to put the clothes back on?

Some ingredients: Why list macros are cool, RubyToRuby.

1 Actually, it’s not the same, since the define_method way creates a closure, so you can do like this

2 Yes, I know I’m using method call syntax here. But this way I do expose the message-passing view on OO that Ruby has. If you want, you can replace it with send_message(object, method, *args), and assume Ruby defines send_message somewhere.

Tags no comments no trackbacks

We don't need another Arial

Posted by matijs 16/09/2007 at 13h00

Some time ago, RedHat released the Liberation set of fonts. They are intended as metrically identical replacements for Microsoft’s Arial, Times New Roman and Courier New fonts.

Sounds great, doesn’t it?

Well, apart from the license issues, there’s another problem: Metric equivalence isn’t everything. Arial is already the metrically equivalent substitute for Helvetica, and look at it: Arial is basically Helvetica’s ugly twin sister. So, will Liberation be any better?

Linux already has a set of fonts that are not only metrically equivalent to, but actually look like Helvetica, Times Roman and Courier: The URW
fonts
. To see them on the screen, instead of the ugly jagged bitmap versions, you’ll need to make them available to X, and turn off bitmap fonts in fontconfig1.

But the URW fonts themselves look ugly too, because their hinting is bad. Liberation would solve that, wouldn’t it? No it wouldn’t, because
Liberation’s hinting isn’t done yet:

The first release is a set of fully usable fonts, but they will lack the fully [sic] hinting capability […] provided by TrueType/FreeType technology.

So why not spend the effort on providing good hinting for the URW fonts, so we can have actual nice looking real Helvetica on our Linux screens?

1 On Debian, and probably Ubuntu, that’s

sudo aptitude install gsfonts-x11

and

sudo dpkg-reconfigure fontconfig-config

respectively. Answer no to using bitmapped fonts.

Tags no comments no trackbacks

Disqualified by Advertising

Posted by matijs 23/08/2007 at 16h36

I was enthousiastic about noobkit for about a week. Finally an alternative to the rough style of Ruby’s standard API documentation.

Until I actually wanted to use it.

Most pages have a full width block of Google ads above the main content. This is just too much. For some methods, the text is one line. The ad block then is five times as big.

I’ll go back to using the old version, thanks.

[Also, the search function is not geared towards API documentation, but instead uses a generic Google-like method. Why not highlight the search results that actually describe the method or methods with the searched name?]

Tags no comments no trackbacks

Zurich

Posted by matijs 27/06/2007 at 21h12

So, I’m reading Steve Yegge’s latest, and he drops some not so suble hints to the reader that they should apply at Google. I talk about that to my wife, how working at Google would definitely be nice, but that it would mean moving from Amsterdam (the Netherlands) to Zurich (Switzerland), because that’s where Google is in Europe. And then she says:

Zurich has the best zoo in Europe.

Tags 1 comment no trackbacks

People Ready

Posted by matijs 25/06/2007 at 20h27

First, what the hell does Microsoft’s slogan people ready even mean? The campaign’s site seems to think it means you need people to run a business. Well, I don’t see any businesses around run by small rodents, so I guess they’re right. That’s some vision

So, what’s this about? Some bloggers got paid for writing about people ready, and people got upset.
Now, some defend themselves saying they didn’t endorse anything, and some defend themselves saying of course it’s an ad box (whatever an ad box is).

Well, I don’t think this looks like an ad, and it may not be an endorsement of a Microsoft product, but it is an endorsement of a Microsoft campaign. Oh, and look at the right of the page. It says “Click here to submit your own People Ready Business story”. So, that pretty much suggests that the content on the left was also submitted the same way. But of course, it wasn’t.

Luckily, at least one of the entries seems to have been written while drunk.

People readiness is something only people that are ready for people to be ready can be ready for.

All this via Mark’s translation.

Finally, back to the meaning: “people ready” means ready for people, right? Just like HD ready means ready for HD. Well, sort of anyway. But no, it means the people are ready. See?

Campaign lame.

Tags , no comments no trackbacks

A song

Posted by matijs 21/06/2007 at 23h38

Today, at seven months and nineteen days of age, Sophia spontaneously performed her first song. It went like this:

Ba ba baa ba baa, ba ba baa ba baa.

(The bas are short, the baas are long). The piece was performed at a constant pitch. I’m still working on the correct rhythmic notation; it’s pretty complex.

Years from now, we will say: We were there at her first performance.

Tags no comments no trackbacks

How to compile TV output into the latest X.org ati drivers on Ubuntu

Posted by matijs 21/06/2007 at 12h58

The Problem

You have built a home server slash PVR that you want to hook up to your twenty-year-old television. You have gone to several shops to buy a graphics card that actually has open-source drivers for its TV output functionality (i.e., the ATI Radeon A9250). You have dodged salesmen trying to sell you something else (“No, but here is its successor the NVidia so-and-so.” “Uhm, no thanks.”). You finally succeeded by ordering it over the Interweb (and probably should have done that in the first place). Now you want to patch the driver shipped by Ubuntu to actually get TV output working.

Tags , 11 comments no trackbacks

Subversion and tagging

Posted by matijs 18/06/2007 at 14h50

I’ve been using svk for a while now, but I keep bumping into problems with the whole concept of tags being just copies.

The problem is this: In my mind, a tag should be a symbolic name for a particular revision on a particular branch. In subversion (and hence, svk), it’s not. To use a tag in place of a revision, you first have to do svn info to find the corresponding revision number, and then use that in your svn diff or svn merge or whatever.

Subversion should have had a smarter client from the start, one that emulates tags and branches and hides the implementation detail that they are ‘really the same thing’ from the user.

As it stands, subversion has no tagging.

It’s all very annoying.

Tags 1 comment 1 trackback

Outage

Posted by matijs 18/06/2007 at 13h13

Last week, I did some work on my website, upgrading to the latest Typo trunk and Rails 1.2, and changing from mod_fcgid to a Mongrel cluster.

Last Friday or so, I rebooted my server. Unfortunately, I had neglected to make the Mongrel cluster start at boot. So for the past weekend, all you have seen here is a Service Temporarily Unavailable message.

Sorry.

Tags no comments no trackbacks