Blog Posts

How are we gonna keep 'em down on the farm?

Whenever I listen to old fashioned media business types, I find phrases like “Shutting the stable door after the horse has bolted”, “How are we going to keep ’em down on the farm now they’ve seen Paree?” and “Pissing against the wind” running through my head.

The basic assumptions on which media companies are built - Talent is hard to find; distribution is hard - have become self-evident bollocks. Media have changed. Back in the “Home Taping is Killing Music” days, recordings were often passed around between friends, samizdat fashion, but the process was self-limiting. Quality degraded with each generation, and every recording required a lump of stuff that had to be paid for. An nth generation tape recording might well convince you of a band’s merits, but it sounded crap. Your motives for buying your own legitimate copy were both selfish - “I want to hear this properly” - and altruistic - “artists deserve to be rewarded”.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley on , updated

Read more…

Catching up with Dominus

Several years ago, Mark Jason Dominus gave a lightning talk entitled ‘Design Patterns’ Aren’t. I didn’t see the talk, but I did come across his writeup not long after I first discovered the Gang of Four’s Design Patterns book. In that talk, Mark put his finger on an issue that had almost subliminally bothered me: many (possibly all) the patterns in that book weren’t really patterns. At least, not in the way Christopher Alexander - the architect who invented the form - described them. Alexander asserts that:

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley on , updated

Read more…

Holy wha?

Okay, so I know GUI coding’s a pain in the bum. I know that the windows libraries aren’t the most friendly. I know it’s not fair to point and laugh.

But… -> IronPython Hello World Tutorial

Bwah hah ha ha.

Of course, I don’t doubt that huge amounts of the boilerplate hoopage in the code shown can, and will, be abstracted away. But right now it’s just painful.

IronPython’s one hell of an achievement though. If there’s any justice in the world, it deserves to get out there and kick C#’s arse good and proper, at least in the .NET context. But still.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley on , updated

Read more…

Yes... that would be me

In my semi regular trawl of the searches that bring people here, I was surprised to discover that someone had arrived searching for piers cawley nottingham university.

What do you know, they probably found the right person.

If you’re thinking that I’m more than a little curious about who has been searching for me, you’d be right.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley on , updated

Read more…

Reasons to be edgy...

I’ve been busy with a new experimental branch of typo that plays well with edge rails, in part because I wanted to move to a more RESTful URL scheme for Typo.

But then I took a look at some of the things going on in Rails Core and my nipples exploded with delight. For instance, there’s now a ResourceFeeder helper that pretty much magically deals with Atom and RSS feeds for Rails Resources, which would allow us to eliminate a whole pile of ugliness in the Typo source. So that’s a win.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley on , updated

Read more…

Capturing a rant

There was a session at EuroOSCON on ‘Music 2.0’ and very good it was too. However, during the Q&A, I found myself ranting about how the model of music as product is dead. About the only specific thing I can remember of what I said was “I make music because I must. I record it because it helps me improve. And I distribute it because I can.”

If anyone reading this was at the session and can remember what I said in a little more detail, I’d love to hear from you. It’s amazing how quickly things fade from the memory.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley on , updated

Read more…

Lightning Lightning talks

This year’s EuroOSCON had no lightning talks scheduled. Then, late on Wednesday night, I noticed that a talk had been cancelled. Aha! I thought. I asked around a few people I knew who normally go for the lightning thing, got a critical mass of interested parties, went and found Nat and we were good to go.

And it was good. Even if we hadn’t organized the session at less than 12 hours notice it would have been good.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley on , updated

Read more…

Crossing the Rubicon. Again

In 2001, using an idea from James Duncan, who blames Damian Conway for getting him thinking on the right lines, I wrote a proof by implementation of the Extract Method refactoring for Perl. Though I say so myself, this was a Big Deal - Martin Fowler calls Extract Method the Refactoring Rubicon - once you have a tool to help you do that refactoring automatically, you can probably implement the rest of the Smalltalk Refactoring Browser and free yourself to think more about the interesting aspects of programming.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley on , updated

Read more…

Did I really just say that?

So, I heard myself telling a bunch of people at RailsConf Europe that the buzz about Ruby and Rails is the sound of “a bunch of Java programmers finally discovering how cool Perl is.”

Which is normally the sort of remark I keep to myself.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley on , updated

Read more…

What we have here is an opportunity to accelerate

Joel says Ruby is slow because it’s dynamic.

Avi explains that dynamic languages don’t have to be slow and points out at cunning trick pulled by the Strongtalk VM to avoid hitting (slow) vtables on every method call. A trick which Ruby fails to pull.

Joel declares victory.

Hang on a minute… #

Maybe it would be victory if Ruby were already pulling out all the stops, including trick Avi mentioned, and was still slow. In fact, Ruby is slow because it’s using naïve dispatching techniques. Something which can be pretty easily fixed by someone who does the C thing.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley on , updated

Read more…

Have you ever eaten a meal that made you laugh?

I’m guessing that, if you answer ‘yes’, you’ve been for a meal at The Fat Duck at Bray, El Bulli or some place that does the Molecular Gastronomy thing with similar élan.

We’ve just celebrated our tenth wedding anniversary a day early at the Fat Duck and… wow.

I first got the giggles when we were given a small ‘Fat Duck’ cereal packet which contained some very lovely flakes of, we were assured, parsnip. We both of us hate parsnip, but this was delicious.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley on , updated

Read more…

Linguistically motivated refactoring

When naming a variable, method, parameter or class, give it a name that fits well with the language and concerns of the scope in which you are using it.

Here’s some Ruby code:

def test\_can\_load\_unique\_articles
number\_of\_iterations = 8

articles = create\_articles(number\_of\_iterations) do
create\_valid\_article
end

assert\_equal number\_of\_iterations - 1, articles.first.related\_articles.size
end

...

def create\_articles(number\_of\_iterations)
...
end


What do you notice about `number_of_iterations` in the definition of `test_can_load_unique_articles`? I notice that it's wrongly named. The name has been chosen to make sense in the context of the loop in the middle of the method, rather than in the assertion at the end - the clue is in the name of `create_articles`'s parameter. In a test method, it seems to me, one of the most important things to do is to ensure that the assertions read as clearly as possible.

Consider:



def test\_can\_load\_unique\_articles
family\_size = 8

articles = create\_valid\_article\_family(family\_size)

assert\_equal family\_size - 1, articles.first.related\_articles.size
end

def create\_valid\_article\_family(size)
create\_articles(size) {create\_valid\_article}
end

def create\_articles(number\_of\_iterations)
...
end


Look at how the assertion becomes clearer. In a family with n members then obviously any member of that family will have n - 1 relations. I've also interposed a helper method between the test and `create_articles`. The idea is to make the language used within the test method internally consistent so the test can be read quickly to understand its intent, before chasing down any method definitions whose behaviour isn't immediately apparent.

I've found this sort of linguistically motivated refactoring to be a very handy practice for increasing code clarity. I should do it more often.

With apologies to [Paul Ingles](http://www.oobaloo.co.uk/articles/2006/08/23/the-importance-of-language) - who must be getting sick of me bashing on this particular chunk of code by now. The article I took this code from makes a good point about striving to keep the language within your code relevant to the problem domain, and how different programming languages make that easier or harder.

And now I really am gone fishing.
    
  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley on , updated

Read more…

Gone Fishing

Well, not fishing, but…

See you all in a fortnight.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley on , updated

Read more…

EuroOSCON on a shoestring, ctd.

Mmm… Priceline doesn’t suck does it? I’m now booked into a 4 star hotel about a mile from the conference and it’s costing me £33 + tax a night. Which is rather better than the best price I found anywhere else (including in the rather splendid sounding Chao Chow Palace on the outskirts of the red light district.

I quite liked the idea of starting my day with noodles and a bowl of Congee.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley on , updated

Read more…

Exactly how photogenic is Damian Conway?

I’ve been catching up with James Duncan Davidson’s blog and one entry caught my eye, coming as it did with a fabulous black and white photograph of Damian Conway

<typo:lightbox img=“197468370” thumbsize=“small” displaysize=“medium” caption=“Damian Conway by James Duncan Davidson/O’Reilly Media”/>

It’s a fabulous photograph. Gorgeous light, great composition, lovely. (Being an old film fart, I do miss the grain though. Digital noise just isn’t the same). It’s also a great example of why candid portraiture is so good; it would take a fair amount of skill, to get lighting like this deliberately.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley on , updated

Read more…

EuroOSCON on a shoestring

“Good news! Those lovely people at Fotango, grateful for the use of the photo of their MD I took, have offered to pay for a EuroStar ticket to Brussels for EuroOSCON.”

“Bad news! I still can’t afford to stay in a hotel.”

So I’m going to play the shamelessly cheeky bugger card. If any of you fine readers is going to EuroOSCON and has a hotel room floor/unused half of a twin room/sofa where I can crash, then I would be delighted to hear from you.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley on , updated

Read more…

Mmm... I got my theme back

It may not be a nice theme, but it’s my theme. Look! There are adverts again!

Why not click on some of them?

Ahem. Sorry about that. I shall shortly return you to more usual fare.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley on , updated

Read more…

Applying design patterns unconsciously

I just realised something about the workings of new style Typo Sidebars: it’s just an application of the Parameter Object design pattern; the render_sidebar helper method takes a Sidebar parameter object and produces a chunk of HTML. The fact that we persist the parameter object using ActiveRecord is almost beside the point - the persistence is more important to the render_sidebars method than anything else.

Old style sidebars couldn’t really be called an application of any design pattern. Maybe that’s what bugged me about them, they lacked the Quality Without a Name. I’m not sure that the new sidebar architecture has the Quality either, but it’s much nearer to having it.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Written by Piers Cawley on , updated

Read more…