Archive

Archive for August, 2009

Why I think test driven development suck

August 29th, 2009

TDD - All code is guilty until proven innocentWell I figured a provocative title like that would catch your attention, so please read on to find out I am not as stupid as you might think.

Unit tests are great, they reduce unknown bugs and arguably lead to better object design. The reasons for this are simple; Well thought out unit tests will force you to think about the input and output of any method your objects may have, forcing you to correctly decomposition the needed functionality within your object, because methods that have too much responsibility are a pain in the ass to write unit tests for. Simple one task methods however are easy to write unit tests for. Because your writing unit tests you are (hopefully) actively thinking about what can go wrong so that methods can actually fail.

So taking for granted that the above is true, why does test driven development suck?
Well the answer to that is a market one and really only applies to professional business. When a client comes to your business and asks for a offer for his project, you will quote him X, where X is roughly the amount of hours it takes to create the unit tests and then fill in the code + other stuff.

A development house that doesn’t use test driven development will quote that same client only for the time it takes to write the code + other stuff. We all know that after that he will spend a few weeks/months bugfixing, but that’s not what he quotes or tells the client.

Naturally the client will more often then not choose your competitor, unless you can positively convince him that the extra hours you spend will actually save him money in the long run. Which from the clients standpoint is a bit of an unproven claim if he is not technically inclined. So from a business standpoint, test driven development sucks as a selling tool.

Secondly, while this heavily depends on the morality of your business, those bugfix hours can be profitable. Depending on how smooth your talk is, you could very well be billing the client for those hours.

Thirdly, test driven development often suffers when deadlines need to be met. We all know that estimated hours is an imperfect science and often goes wrong, be it overconfident developers or overselling sales people, deadlines tend to be missed in our industry. So when deadlines are creeping, unit tests are often one of the first things to be dropped off schedule. Yes, we all know that shouldn’t happen, but it does. Once this has happened and no extra time is allocated to bring the tests up-to-date again (good luck getting that approved), the test driven development has failed and you’re just plainly developing again.

So for these reasons I think test driven development sucks. I might sometimes use it for private projects or open-source projects (for which I think it is absolutely brilliant), but certainly not for business ones. With the possible exception of in-house developed products, but I haven’t had much experience with that.

For anyone who now still thinks TDD is a sound development methodology, I would be very interested to hear you thoughts.

PHP, software development , , , , , ,

website text writing 101

August 26th, 2009

Now when people talk about websites and usability, a lot of stuff gets mentioned. Web 2.0, ajax, usability guidelines, designs etc.. etc.. What I however almost never hear is about the text. Sure people talk about content, user generated content, tagging, searching, etc..

But what about the little things? What about the buttons, the links, the subject lines of the e-mail someone receives? Those are the most read elements on your website, yet get the least amount of love.

So today I’m going to share some of my ideas on these texts, because I think they are important and should be treated as such. It all hit me about a year ago, at the DPC08, in the closing keynote by Terry Chay. He mentioned that when they added a smiley face to the subject line of some sort of mail they sent they saw a 20% increase in clickrate. That is nothing to scoff about. This got me thinking about how important these small texts are.

Over the year I’ve found a few key ideas about these texts that I think are important to keep in mind when creating them.

Positive Association
When a user comes on a site he or she will have a lot of actions to take. Design and content placement determines a large part of what a user will do. But what about texts? Now lets say our goal is to get as many users to register. We could have a “register” link. The link is placed prominent and the design helps the user focus on it so that we are almost certain that the user will read it. So what can we now do to actually let the user click the link?

Your average register link, contains basically the word “register”. Hmmm. Now I don’t know about you, but registering is annoying. I have to fill in all kinds of info about myself and give them my e-mail address, which I don’t actually want to do.

join linkedin

It all sounds a bit too much like a command. What we want to do is create a short text that reminds us of the fun things about having an account. “Join the community”, “share your pictures”, “create your account” All much better then “register”, the text should be inviting and friendly.

Leading the Userwould you link to comment?
When users visit sites we want to be able to guide them trough the site. We can effectively do this by emphasising what we want them to do via text. A good example of this is to be found on flickr. If you are not logged in, and you are viewing a photo, the site asks you “Would you like to comment?” instead of the often seen “To comment you have to be logged in”. If you think about it, the difference is miles apart. The flickr one makes me think, ‘do I want to comment?’ the other one doesn’t. I just think ‘oh ok’.

you must be logged in to leave a commentThe bit under both those texts is of course the same “sign up or login”. The difference however, is that after I’ve read the “Would you like to comment?” I actually either have decided I want to comment, or not. While with the other, I have no incentive at all to sign up or login. Or at least not if I wasn’t already planning to comment. Basically the flickr one reminds me that I can comment, and I even might want to comment.

Don’t Lie
It is however important not to lie. Every time a users gets confronted with something they did not expect, a percentage of them will quit. So for instance, in the positive association part I wrote “share your pictures” as text example for a button to sign up. But that’s of course not what the user expects. We promised the user they could share their pictures when they clicked that link.

So to take that as an example, we should make sure that after the user clicks that link we present the user with more text that reinforces that they will be able to share their pictures, just after filling in a few details.
That way we have given the user a clear incentive to register. This however often gets abused, I should make very clear that the page the user gets to see should not be a registration page, but a picture sharing page where you register. The actual sharing of pictures could of course be a step two of a wizard type structure.

usability , , , , , ,

Setting up simple but easy to work with LAMP development environment

August 13th, 2009

I’ve recently changed the way I work so I figured I would detail it here.

First off all let me describe the setup. Basically all my code resides in a subversion repository on server X. My development environment is a virtual server run on virtualbox, a default ubuntu server with a LAMP stack. On my client I run the PDT edition of eclipse with subclips installed.

The client side:

  • Install PDT eclipse, you can download it from http://www.eclipse.org/pdt/downloads/.
  • Go to http://subclipse.tigris.org/ and follow the text to install it into your eclipse installation.
  • In your eclipse choose import from the file menu and select “checkout project from SVN”
  • You now should have a checkout on disk inside a project to work from in eclipse

Development environment side:

  • Create and setup a LAMP based virtual server. (I’m going to assume ubuntu because that’s what I’ve used)
  • Create a virtual host for your project.

The actual interesting bit:

Now the above is really standard stuff, so that’s why it’s a bit brief, but now comes the interesting bit.

What we want to do is mount the code checkout from your client machine as the serving directory of your development environment. Because I’m lazy I want to be able to do this with one click of the button, so we are going to break some security things to be able to do this via the browser.

We want the apache user (www-data in my case) to be able to mount via sshfs and unmount. This will enable it to mount the checkout from my client pc to the serving directory of apache on the virtual server.

First we want to add www-data to the fuse usergroup, we do this via the following command.

sudo usermod -G fuse www-data

Now the www-data user will be allowed to use sshfs.

Next we create the file /var/www/index.php and put some code into it. The following code is really simple and could probably be made more elegant but currently I don’t care :)


<?

if ($_GET['mount']=='myproject' )
  `sshfs user@192.168.1.20:/home/demo/workspace/myproject /var/www/myproject`;

if ($_GET['umount']=='myproject')
  `sudo umount /var/www/myproject/`;

if (is_file('/var/www/myproject/index.php'))
{
?>
myproject is currently mounted -- <a href="?umount=myproject" />umount</a>
<?
}else{
?>
myproject is currently not mounted -- <a href="?mount=myproject" />mount</a>
<?
}

What this allows us to do is to go to the default hosts index.php and remotely tell the server to mount or unmount the environment. There are a few things we need to do to actually make the above code work though.

First the mounting.
sshfs uses ssh, so since we want to use it without user interaction we need to create a private and public key for www-data.


sudo su - www-data
/bin/bash
ssh-keygen

After that you should have a set of keys, then copy the public key to your client and add it in ~/.ssh/authorized_keys of the user you need to log into.

Now the mounting of the repository should work.

However for the unmounting we need to use sudo to get the rights to do that. So for that we need to edit /etc/sudoers on the virtual server and add the following line somewhere.

www-data ALL = NOPASSWD: ALL

Yes, it would be much safer to not allow ALL, but only the umount, but for my virtual development box i’m really not concerned with security, I just want a trouble free and quick fix.

So now I created a simple script that will let me mount and unmount my working copy of the code on the virtual server.

I typed this all up rather quickly so if anyone wants some parts explained in some more detail just leave a comment.

apache2, PHP, software development , , , ,