Wednesday, May 21, 2008

You need to think like the user

In software development, it is necessary to think of all the actions that the user would perform with your software. This is so that you can fix any bugs or inadvertent situations that might arise before it goes over to the user.

Software professionals refer to this as 'thinking-like-the-user'. Like Joel Spolsky says in this article, you need to create imaginary users in your brain and think of them exercising your software. This usually reveals scenarios that you might otherwise have never thought of. Personally, I have always striven to think like the user in all situations, whether I am writing a full-fledged application or just changing a block of code.

For the past few months, we have been maintaining some code written many years back. Recently, I found one 'bug' that illustrates what happens when you fail to think like the user. I have not taken screenshots of the application, but the screenshots you see below are similar.

We have a screen where the user can searc
h for groups.


Now the Find Groups button lists all groups if the user does not enter anything in the text box. However, if he does enter something, then clicking the button lists all groups starting with that text.

Usually, I would just press the Enter button and move ahead. On this particular day, I used the mouse to click on the button.

And I got this...




I analyzed the code to see what the developer had done. Here it was:

<script>
function validateIt() {
//If the value entered is of zero length, then show an alert message.
}
</script>

Then a few lines down....

<html:form action="some.do">
<html:submit value = "Find Group" onclick="javascript:validateIt();"/>
</html:form>


So basically the developer had written a script to validate the text entered by the user in the field. This would fire when the user clicked the button. But the control which fires this event is a submit button, which can be activated by pressing the Enter key. However doing so does not fire this script - for that to happen, you would have to write an onsubmit event handler.

So now you have a case where clicking on a button to submit the form is considered erroneous, while pressing the Enter key to do the same thing isn't.

This thankfully was an internal application - people probably didn't care that much about quality. The application has more of these annoyances, but the users probably grind their teeth and worked away, since they needed this application for their daily work and also because they had no other choice.

What would have happened if this was part of a product? And in a market where you have competitors?

No comments: