Archive for November, 2007

Understanding Web Design

Thursday, November 22nd, 2007

http://www.alistapart.com/articles/understandingwebdesign

Architecture (the kind that uses steel and glass and stone) is also an apt comparison—or at least, more apt than poster design. The architect creates planes and grids that facilitate the dynamic behavior of people. Having designed, the architect relinquishes control. Over time, the people who use the building bring out and add to the meaning of the architect’s design.

In other words – it’s about you as much as it’s about me.

Incorrect Test Fixtures lead to Weird Testing Results

Friday, November 16th, 2007


After recently praising test fixtures as an important (but time-consuming) part of building your tests, there is something to watch out for.

If you get one of your foreign key references wrong in your fixture data you can get odd results. In particular I had a test that passsed when run using ruby test/unit/my_test.rb but failed when run using rake test:units.

The cause? Simple. I had two fixtures files, :orders and :work_items – where work_items have a detail relationship to orders (with a foreign key order_id). My orders fixtures looked something like this:

daves_first_order:   
  id: 1  
  some_field: whatever
daves_second_order:   
  id: 2  
  some_field: thingy
georges_important_order:  
  id: 3  
  some_field: wotsit

My work_items fixtures looked something like this:

first_line_of_daves_first_order:
  id: 1
  order_id: 1 # daves first order
  some_field: fish
second_line_of_daves_first_order:
  id: 2
  order_id: 1 # daves first order
  some_field: gerbil
first_line_of_georges_important_order:
  id: 3
  order_id: 4 # georges important order
  some_field: giraffe

Spot the error? It took me a while – and as I say, the only symptom was this odd behaviour where the test passed in one case but not in the other.

It turns out that the fault was this – one part of the test was creating a new order from scratch and assigning work_items to it. When run via rake the test database was torn down and rebuilt, matching the structure of the development database. Also meaning that every time the test was run, MySql new to give the next record in the orders table an id of 4. So the typo in the work_items fixture file (where first_line_of_georges_important_order has an incorrect order_id of 4) meant that the work_item pointed at the wrong order – leading to a cascade of further failures. For some reason, when run without rake the test passed as the order_id of 4 actually resolved to :georges_important_order (although I’m still not sure why).

The moral of the story? If you get odd behaviour, where your tests behave inconsistently, then examine your fixtures files in great, great detail.

Dog by kufrik

Test Driven Development is not about testing

Wednesday, November 14th, 2007

http://parlezuml.com/blog/?postid=517

People who practice test-driven development are doing design. It’s important – actually, it’s critical – to understand that. If you fall into the trap of thinking that TDD is about unit testing, then you’ll probably miss the point.

Too many teams believe they’re doing TDD, but are actually just writing unit tests for code they’ve already written, or writing one unit test and then writing 500 lines of production code before they move on to the next unit test.

Absolutely. Applications that have unit tests written before the actual code tend to have looser coupling, cleaner design and concentrate purely on what is required (rather than evolutionary dead ends).

Psychology of Entrepreneurship

Tuesday, November 13th, 2007

or why you should call a slut a slut

Do you think it’s because I said ‘slut’? Are people really that conservative? Maybe I should tone it down a bit. But if I tone it down a bit, I won’t be being myself. I don’t want subscribers who don’t like me for who I am. Then again, I want to write a book. I want people to buy it. I don’t care who they are. Am I pissing off the Bible belters?

Naomi’s a fantastic writer, linking red wine, sluts, naked men and balls into a series of articles about business. Recommended.

Tiny Details

Saturday, November 10th, 2007

I’ve said before that it is often the tiny details that make all the difference.

And Euan has found one such detail:

It knows that my home number is used by both my wife and I so when I get a call it says it is from Penny OR Euan

UPDATE:

Whereas the genius that is Stephen Fry says:

In the end the iPhone is like some glorious early-60s sports car. Not as practical, reliable, economical, sensible or roomy as a family saloon but oh, the joy. The jouissance as Roland Barthes liked to say. What it does, it does supremely well, that what it does not do seems laughably irrelevant.

However it’s not as good a Fry quote as:

I was walking through a field the other day and stopped to pick a buttercup. Although quite why someone had left their buttock lying around I will never know.

Death to Professionalism

Friday, November 9th, 2007


It’s now three months since I quit my full-time job and became a free-lancer and/or mercenary contractor (depending upon for whom and why I am working).

It’s odd.

Where I was before, I had been there for nine years. Everyone knew me. I could string together long sequences of swear words without anyone batting an eyelid. I could insist that I work in Ruby on Rails when everyone else was in .Net. I could dress how I wanted. I could put offensive slogans on my screen-saver. No-one batted an eyelid cos they knew I was good at what I did.

Now, I’m starting over every time. No swearing. Dressing smart. Doing as I’m told (yeuch). All in the name of being “professional”. Wife left you? Keep it quiet and get on with it. Cat run over? Put on your best suit and smile at the client.

What does “professional” mean?

At its simplest it is doing something because you are paid for it. If you ask me that does not mean leaving your emotions, your personality, who you are at home. If who you are does not help you do your job then you should probably try a different job. It does not mean that you become an automaton, leaving yourself at home as your trudge to the office.

So if you hire me this is what you will get:

* My emotions will not be held in check. If I care about something I care about it. If I’m having a bad day and I ignore what is going on in my head, I will do shit work and have to redo it tomorrow.
* I will swear. Tough shit. I like it. I’m good at it. Twatbag.
* I will dress badly. Obviously I think I look fantastic. No-one else agrees. I like my three suits. My wife thinks I look good in them. I don’t wear them.
* I will be between 5 and 10 minutes late for every meeting. I always try to leave five or ten minutes earlier. I don’t manage it. I have no idea why.
* I will write beautiful code. It matters to me. It makes me feel good. It is important (see emotions, above).
* I know what I know – I also know what I don’t know. I have no illusions as to my areas of expertise. But what I know, I really, really know.
* I will be polite. “Please” and “Thank You” are important. More important than swearing? I can’t answer that.
* I work hard. Always. I was once told by my aunt “you realise that because you are brown you will have to work twice as hard to achieve the same … think that’s unfair? I’m a brown woman – I have to work four times as hard“.
* My family comes first. My girl has a hospital appointment? Your stuff will have to wait. I will make up the time (see above).
* I can talk to you about technical stuff. You will understand what I am saying. No jargon, no gobbledygook. It is, in fact, absolutely vital that we communicate clearly and so I will make sure that I put in the effort. But I am an introverted geek – so I’m pretty crap at small talk (as opposed to Smalltalk). Sorry.
* I will deliver something that does what is needed, in a reasonably stylish way. It may even make you smile. But you won’t be disappointed.

I guess that makes me “not professional” to many people. I don’t care. I’m not a zombie and you don’t want to hire one.

Business Card by xlucas

rake db:fixtures:load

Friday, November 9th, 2007

rake db:fixtures:load is probably one of the most useful commands I have used recently.

You see, I was meeting some people about some potential work. They wanted to see an example – preferably related to payment systems. I had some code but unfortunately, the service that is part of had been switched off (a number of reasons, none of which connected to my supreme stylings). I had a copy of said code on my machine, but no database and I had no time to prepare.


So how could I demo it? Easy peasy.

cd ~/Source/my_apprake db:migraterake db:fixtures:loadruby script/server

And then start Camino.

Because the application had been developed test-first I knew that there was a decent set of data within those fixtures. Data designed to show all the edge cases, all the complexities of the application. From users and logins through to payment records and customers.

It is fair to say that when writing your applications, test-first, the fixtures are the hardest thing. It can take ages and it is detailed, painstaking work. Especially if you are trying to build a narrative (:dave logs in, selects a :cucumber, goes to the :checkout, pays with his :expired_credit_card which is rejected).

But the benefit is there. Building a narrative helps you when you come back to the code in six months time. Defining a wide-range of test fixtures helps you when you make changes and need to ensure that it won’t break a feature over there. And it helps you demo your code in front of a prospective client when faced with the unexpected.

Data Highway by KLatham.

If you find this useful then please take a look at some of my other writing – or recommend me on Working with Rails. Cheers.

Mobile networks: the state’s new bloodhounds?

Sunday, November 4th, 2007

http://www.theregister.co.uk/2007/11/04/location_information/

A pre-paid SIM, paid for in cash, should be standard-issue for anyone planning a crime spree, though few criminals have the foresight for such an investment, and forwarding your old number to it would be something of a giveaway.

Turning off your mobile, and removing the battery for the properly paranoid, should be good enough to ensure you’re not being tracked.

If it’s already too late, your only hope is that your crime doesn’t warrant enough budget to track you down, or that no one notices it for the 12 months the network operators are hanging onto their data.

More Fire and Motion

Thursday, November 1st, 2007

http://www.userscape.com/blog/index.php/site/google_is_genius_and_everyone_else_is_stupid/

By building lots of apps they get people scared. Google is entering my market.. ahhhhhhhhhh. The distraction factor is huge. The more time and resources companies spend on fighting Google on these fake fronts is less time and resources on the only one that matters, search.