Please, please write an interface to your Grid

February 2, 2007

This is a plea to all developers out there working on apps that have a grid as their main user interface.  Please please please write an interface between your code and the grid implementation.

Grids components have loads more functionality than is ever needed in a single project, and it’s likely that you’ll only use about 10-20% of it.  Therefore, creating an interface that wraps around the grid should be relatively straightforward.  From the top of my head I can think of a few interface members:

  •  AddColumn()
  • RemoveColumn()
  • AddRow()
  • RemoveRow()
  • UpdateCell()

It may be that you have “UpdateRow()” rather than “UpdateCell()” if you change entire rows at once.

There are a couple of good  reasons for interfacing off your grid access.

  1. You can change your underlying grid implementation:
    Almost every project group I’ve joined who have used a grid say their grid isn’t fast enough.  The kind of apps I work on (processing lots of real-time financial market information) make dozens of grid updates per second.  However, moving from one grid to another has been very very hard, because the business/presentation code has been intertwined with the grid code.  If you interface off the grid access, the migration only involves rewriting the hooks from the interface into the grid.
  2. The interface makes the available functionality obvious, and it prescribes one way of performing each task.  Most grids offer at least two ways of doing each thing.

So please please put an interface between your business code and the grid.  It will make your life easier, and it will make my life easier when I pick up your code in 3 years time.

Advertisements

One Response to “Please, please write an interface to your Grid”

  1. Bil Simser said

    This is exactly what the MVP pattern is for. Rather than having an all-encompassing interface for a grid, the view is the interface and you have whatever methods/properties you need to solve the UI needs in it. How you implement it in the grid is in the view implementation and up to you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: