Nov 302007

A Mind of Its Own

Uncategorized Comments Off

I’m reading the book “A Mind of Its Own”, by Cordelia Fine. I sometimes find it hard to make headway with this kind of material and put it down after the first couple of chapters, but for whatever reason this one has gripped me.

It’s all about the strange tricks that the brain can play on itself, and the things that people do as a result. Particularly, we become blindsided to our own faults.

Then I came across this perfect example, in an article about Donald Trump’s plan to build a £1 million golf course being turned down by Aberdeen council, with the help of assorted committees, protesters and a fisherman:

Sorial defended accusations the Trump team had been "arrogant and patronising" in its approach. "There’s a view we are arrogant. We are not arrogant. We set certain standards. It may be incomprehensible to smaller minds, but we have always set high standards. We presented them with a plan and hoped they could open their minds, but it was too much for them."

I can’t understand how anyone could misconstrue such grace and humility. Shocking. Chalk one up for the Aberdonians.

Nov 192007

After my last post, Negin and I were quite pleased that we’d got as far as we had.

So was our Business Analyst. “So, this story that was estimated at 3 days,” she said. “Can I say it’s only taken one?”

“No! We’re not done yet!” I protested.

“Really? It looked like you were almost done on Friday… what happened?”

Oh, well. At least we know it looks good.

Nov 162007

Today, Negin and I paired on a brand new piece of work.

“We’ll need to create this domain object,” she said, “and a database table.”

“I don’t want to do that,” I said. “I’d rather fix the stuff that’s broken.”

She looked puzzled. “What do you mean? We haven’t written any code yet.”

“Well, we know that if you go to the URL, you should see the form. But when I go there I get a 404 error.”

“Well, yes. We haven’t written any code yet.”

“So, it’s broken. It doesn’t work yet. We should fix that.”

So we wired up the container and knocked out a controller. We restarted the server and refreshed the URL. Spring told us we had left out a couple of things. We fixed those.

Negin tapped something into the template and refreshed the URL again. “We have a page. It says HELLOOOOO! across the top. Now what?”

“Well, we got rid of the 404 error. But the page doesn’t look right.”

“Of course not. We haven’t written the form yet.”

“We should fix that.”

We wrote the form. It didn’t look right, so we added the styling. Our business analyst peered over our shoulders at what we were doing. “Looks like you’re doing well. Why doesn’t the drop-down have my data in?”

Negin said, “You’re right. We should fix that. This is fun!”

“It is,” I said. “Don’t you just love that we get paid for this?”

Nov 142007

Crazy like a fox.

bdd Comments Off

At my current client, everyone loves BDD, and everyone starts their tests with the word ’should’, describing the behaviour of the associated class. I’m currently looking at this code:

public class PrimaryMixingIteratorTest extends EasyMockObjectTestBase{
    public void testShouldIterateLikeAFox() throws Exception {
        //...
    }
}
public class SecondaryMixingIteratorTest extends EasyMockObjectTestBase{
    public void testShouldIterateLikeABadger() throws Exception {
        //...
    }
}

Once I’ve remembered how foxes and badgers iterate, this code might make more sense to me. Remind me to run that ‘should is not a silver bullet’ brown bag soon…

Update: If you tied a fox and a badger together and dropped them into the corner of a square pond, they’d make a splash. Imagine that splashes happened in squares instead of circles, and that the quarter of the concentric square formed by the fox and badger started at the top-right then went to the bottom-right then bottom-left. Now imagine that the fox shouts out which row the splash happens in, and the badger shouts out the columns.

It’s a way of combining the values of two infinitely-sized lists for an arbitrary number of combinations, without loading the lists into memory. Makes so much more sense. Hold on, I’m getting a phone call from the RSPCA…

Nov 132007

When do I refactor code?

Uncategorized Comments Off

This question has kicked around a bit at Thoughtworks lately, sparked by this article:
http://blogs.construx.com/blogs/stevemcc/archive/2007/11/01/technical-debt-2.aspx.

I thought I’d blog what I do, since a few bits of feedback lead me to believe I might be good at it.

I don’t refactor when…

…I spend five minutes on it and realise I’m not getting anywhere. I can always think about a more incremental approach and come back to it later.

…I don’t understand the benefit that the code provides. Sometimes it turns out that it doesn’t provide any; I usually double-check that assumption before I delete the code. I might talk to the person who wrote the code to get their ideas.

…I am technically ignorant. I might give it a go, especially if my pair knows how to help – it’s an opportunity for me to learn something new – but I’ll usually timebox it, and revert if I take too long.

…I’m under pressure of time to get something done… but it’ll be on my todo list, and I won’t ask permission to finish it off properly once the pressure’s less (and if you don’t like that, give me another reason not to do it).

…it’s hard, and I don’t need to. If it’s someone else’s code and no one’s using it, reading it or changing it, the time saved won’t pay itself back any time soon. If it’s my code, it got that way because it’s built on top of someone else’s, and I need to sort that out first. This is how tech debt arises. If it turns out that it’s holding us back, and it’s time to pay for it, then I might volunteer to be part of that pair.

…someone absolutely forbids me from doing it, notwithstanding the above. Anyone doing this is letting themselves in for my ‘told you so’ when it comes back to bite. If it’s going to take less than an hour, you might as well let me go ahead and do it anyway – we’ll spend half an hour arguing, and (even though I no longer sulk about it) I’m far less productive when you kill my spontenaiety.

I do refactor when…

…it doesn’t fall into one of the above. This includes easy refactorings that I don’t need to make. If I’ve seen it, something must have sent me there! That means the chances of someone else reading it are reasonable.

I should mention that I’ve never been forbidden from refactoring anything. I’ve seen it happen once. Two pairs both tried to use the resulting mess. The refactoring would have taken one pair two hours; the mess caused each of two pairs a full day. There were definitely some ‘told you so’ moments, which is why I think the arguments are worthwhile.

I have, in the past, made huge and significant mistakes while trying to refactor! This learning experience has helped me become better at it. Everyone should have that opportunity.

Nowadays, I rarely ask permission. I justify my time by the time it’s likely to save in the future – whether in related code, similar code or simply because people (including me) are learning from good habits. If I can’t justify the time, I don’t refactor!

Nov 132007

Lotus Notes: Making mail quotas meaningless

Uncategorized Comments Off

There are at least three good reasons why we’re using Lotus Notes, so mostly this post is just here to make me feel better. Thank you for sharing my pain; please comment with any solutions you’ve found for this problem.

Today, I decided that I would delete all my old Lotus Notes mails that have been building up. This is partly because I’ve been getting warnings for the last three weeks about my quota, and partly because I remember my empty inbox with fondness.

I click my Inbox on the Workspace.

I start at the bottom, with my mail from way back in 2005. I can’t just shift-select a ton of mails – I have to individually tick every single one. I have a preview window; of course, this means that if I accidentally click on something large, Lotus Notes carefully loads the attachment into memory before allowing me to delete it. (I have no idea why it does this, since it loads it all over again if you actually open the mail. And again if you decide to open the attachment.)

I tick a screenful of mail, press delete, and get the “Type Mismatch” dialog:

I don't know whether Lotus Notes still thinks it's being helpful here or not.

All the mails now have crosses against them, but haven’t actually been deleted.

Why does Lotus Notes think this is helpful?

I figure that maybe, just maybe, Lotus Notes will do this if I log out. So, I quit Lotus Notes. When I open it again, all the crosses have gone and the mails are still there.

So, I try again. Tick. Tick. Tick. This time, I just close my inbox. Lotus notes kindly asks me, this time, if I want to delete 77 mails. Absolutely I do! But apparently, Lotus Notes exists in a different timezone to us mere mortals, and it’s too early:

This is Lotus Notes being surreal.

Hm. My mails are still there, and the crosses have gone again.

I have spent hours now trying to delete my mail. Of course, now I remember why they were building up in the first place…