The Editable Grid Antipattern

“Make it look like Excel” is one of those “requirements” that wakes me up screaming in the middle of the night, in cold sweats and gibbering…

IMHO it is almost always a failure of analysis, a failure to dig deeper and discover the actual problem, a failure to “Ask why? five times” [1]

Here’s an example of what I mean, based on a real example that I have seen.

Maintaining Employee Information

Suppose I have an application for the maintenance of employee and employment information. There is a dialog that shows the employment history of the person in a grid that looks something like this:

This grid is editable. Basically they are directly editing the underlying database table.

Why?

Because we need to be able to change the dates.

Why?

So we can enter a termination date and the reason for the termination

Why?

So we can update the employment history when we terminate an employee.

Terminating an Employee

It turns out that when they terminate an employee, they go to the employee status screen, and change the status from ‘employed’ to ‘terminated’. Then they go to the employment history page and update the employment history with the new end date, and the reason for termination.

Consider the implications:

  • It is possible to change the status of the employee to terminated without having that reflected in the employment history
  • It is possible to change the employment history to reflect a termination, while the employee status still has them as employed.
  • The operation to terminate an employee is not atomic (the status field and history entries are changed independently)
  • it is possible to change the dates of an employment in the past - without any thought to the consequences.

Here’s a (hopefully hypothetical) example of the problems this may cause. Alice changes the status of Bob to ‘terminated’ but does not change the employment history. The company decides to pay a bonus based on the time that an employee has been with the company. Bob gets a gold watch in the mail despite the fact that he has been working for another company for 5 years now.

Usability Problems

Chris is new to using the system. Diana has just been re-employed by the company. So Chris goes to the employment history which looks like this:

and changes it to reflect the fact that she has been re-employed:

Diana is *really* annoyed when she doesn’t get the gold watch in the mail despite having worked for the company for over 25 years.

Complex Business Rules

Imagine the business rules that would be needed around this implementation if you want to make it reliable and keep it as is:

  • you should only be able to edit the last EndDate of an employee’s history
  • if you enter an end date you need to enter a termination date
  • the end date must be after the start date
  • the start date must be after the previous end date
  • you can only enter the end date if the status of the employee is ‘terminated’ (but i want to change the history before the end date is entered!)

Complex Requirements

Suppose someone notices that the status and the history can be out of sync - they come up with a couple of new requirements:

  • as a user, I want the status of an employee to change to terminated when I change the end date of an employee on the history page so that the status is in sync with the history
  • as a user, I want the status of an employee to change to terminated when I change the end date of an employee on the history page so that the status is in sync with the history

Not only are these business rules and requirements complex and hard to understand, they describe the system in terms of the implementation. Since the implementation (the editable grid) is directly tied to the database, you might as well describe the system in terms of changing rows in the database. There is no relationship of the requirements to the actual tasks being performed by the user (Terminate, Re-employ etc.)

Hopefully you see the problem.

Asking “Why?”

So what can we do?

If the original team had asked “Why?” a few more times then the stories might have looked like this:

  • As maintainer of the company employment records, I want to be able to terminate an employee, as of a certain date, with a reason so that we can stop paying them a paycheck.
  • As maintainer of the company employment records, I want to be able to re-employ a previous employee, as of a certain date so that we have a single record for that employee.

How would that be implemented? Maybe a “Terminate” button on the employee record screen, that pops up a dialog like this:

Simple. Usable. Atomic. Safe. Easy to implement.

So if you find yourself implementing an editable grid, I would strongly Strongly *STRONGLY* urge you to go back to your customer and ask “Why?” 5 more times.

Caveat: Sometimes, just sometimes, it may make sense to have an editable grid that ‘works like excel’. If so, use Excel. That is what it is for.

[1] “Ask why five times” is one of those many things that has entered the lexicon from Taichi Ohno, lean manufacturing and the Toyota production system.
http://www.toyota.co.jp/en/vision/traditions/mar_apr_06.html

8 Responses to “The Editable Grid Antipattern”

  1. James Crisp Says:

    Hi Chris,

    You make a convincing argument and I certainly agree that editable tables are often not appropriate plus require more development effort.

    However, I would like to suggest that an editable grid has a valuable place in the world - data entry. In the brokerage industry for example, it is necessary to enter huge amounts of information by hand. A shipment for example can have hundreds or thousands of individual products included and each of those products has quantity, weight, volume, classification, goods description, etc. An efficient way of entering this data is do do it in an editable grid. Alternatives such as clicking an add button which brings up an add form, with a save button which then updates the DB and refreshes the grid, would be a lot slower for the user with hundreds or thousands of these product lines to enter on a daily basis. On the front of addressing validation in an editable grid, I would suggest that rather than working almost directly with a database table, you introduce an intermediate domain object layer which contains validation (perhaps of declarative style) which is run before data is saved to the database.

    James

  2. Asking why five times. « Rui Silva Says:

    [...] March 3rd, 2007 in Other Today, I have found an interesting post named “The Editable Grid Antipattern”. The illustrated scenario it’s a perfect [...]

  3. Lance Walton Says:

    Agreed, Chris. It can be particularly bad when the requirement is actually expressed in terms of the underlying database tables >:-{

    Gerald Weinberg has an analytical technique similar to “Ask why? five times” which consists of alternating “Why?” with “What?”. e.g.

    “Why do you need that?”
    “What will that do for you?”
    “Why do you need that done?”
    etc.

    If I recall correctly (and I read the book 10 years ago so my memory migh be faulty), he says that you often have to ask about 6 questions to get to what he terms “The Data Question” which is where you get the information you really need.

    Regards,

    Lance

  4. Kim Says:

    I mostly agree with you, but James’ point of usability (massive dataentry) is also a factor that must be taken into consideration. One issue that I don’t understand from your post, is that you aximatically assume that any databinding must be done to the underlaying table. There’s no reason why a grid couldn’t be bound to a business object which could trap and enforce all the issues you mentioned in your post.

  5. Claus Says:

    I think the caveat at the end is better than the warning: If there’s no spec, other than (Like the stuff we’re used to) - don’t write the software. Just use the stuff they’re used to.

  6. Michael Goldobin Says:

    Hmm… Very-very familiar problems :)
    I’ve re-read the “Lean development” one more time and yes, I really missed the “5 times”. Great notion!

    Also, I finally retried your idea of reflecting on ASP.NET page to test something like validation. Your TM is mentioned :) - http://lazyloading.blogspot.com/2007/05/testing-aspnet-pages-outside-http.html

  7. Chris Barrow Says:

    I too have experienced these same problems, and have concluded that a fully featured, client-heavy grid should never be used in web apps. The alternatives are far easier to implement, maintain, and extend.

    Long live the editable grid antipattern!

  8. Olivia Smith Says:

    i applied for data entry jobs over the internet and it is also a good part time job.,;~

Leave a Reply