Categories
Uncategorized

Greasemonkey Hacks

I’ve just gotten a copy of Greasemonkey Hacks and I’m working my way through it. The book itself is great. It’s a really good introduction to greasemonkey and what you can do with it. Eventually, I’m hoping to may my bank usable in firefox.

The only quibble that I have is the code samples. Many of them (and they appears to be the ones written by Mark Pilgrim, the author) are really difficult to read, because they idioms are wrong. For example, nearly every for loop I have seen looks like this:

  for (var i = arTableRows.length - 1; i > = 0; i--) {
    ...
  }

Which is walking through the rows of a table, backwards. Why backwards? I have no idea. I would expect it to look more like this:

  for (var i = 0; i < arTableRows.length; i++) {
    ...
  }

Aside from a marginal efficiency gain (which smacks of micro-optimisation), I don’t see what the benefit is.

And “arTableRows” is another quibble with the code. It’s filled with hungarian notation. Great if you work at Microsoft, but unreadable to the rest of the world.

Categories
Uncategorized

Beta Books

I’ve recently purchased a beta copy of Rails Recipes. It’s obviously not 100% finished, but appears to be largely complete. It’s already been really, really helpful to me, in particular the chapter on migrations.

But what’s really, really cool is the link at the bottom right of each page in the PDF. It just says “Report erratum”. Clicking it launches a web browser pointing at the erratum page for that book. It’s the easiest way of giving feedback that I have ever seen.

It’s not just erratum of course. Because it’s still a Beta Book, suggestions are also solicited. So I added a little note about how linking to the docs for migrations would be a good idea. Yes, it’s a very small point. But together, lots of people with lots of small points adds up to a much, much better book. I can’t wait to get my print copy of the final version!

Categories
Uncategorized

Perl Best Practices

Yesterday, I was reading Perl Best Practices on the train. I got nearly half way through in three hours. Then I came home and finished it off. I was completely taken by surprise as to both how readable and how incredibly useful it was.

Conway is excellent at explaining not just what is a best practise, but why. He’s certainly got me to reevaluate the way in which I work. The book made me realise that some of the ways in which I code are alright now, but certainly aren’t conducive to easy maintenance of code.

But perhaps the best bit are the sections on OO Perl. Whilst Perl has long been known for having fearsomely weird OO (in fact, Conway wrote the book on OO Perl), in Perl Best Practices, he manages to talk you, very sensibly, through something called “inside-out objects,” which are a great deal more secure than the default Perl way of OO. In typical Conway manner, he starts small, with a simple implementation, then builds on it and builds on it, until you end up with something remarkably useful. And then at the end, he says “of course, you can always download the CPAN module Class::Std to implement all of this for you.” So you’ve got the idea behind the module, but you don’t have to do any work to actually implement it. It’s a bold step, coming up with a radically different Perl OO scheme, but he appears to have done it well. Others have tried and failed, let’s hope he succeeds.

Categories
Uncategorized

Verity Stob

Now there’s a compendium of Verity Stob. She is to programmers what the BOFH is to sysadmins.