Wednesday, July 02, 2008
Posted on Wednesday, July 02, 2008 12:00:37 PM (Mountain Daylight Time, UTC-06:00)  Comments [3] | 
Categories: .NET | Fundamentals | SQL Server | Virtual Earth

A reader recently asked me to expand upon the "Keep it Simple" advice in the fundamentals section of my web site. Just like my advice, I had kept this section pretty lean...

Keep it simple

Anybody can build complex software. Creating simple software that can accomplish the same task is much more difficult. In the end though, the simpler it is, the easier it is to test, which makes it easier to maintain, and easier to extend.

To illustrate the idea, I'll talk about a project that I'm working on right now. Basically I'm helping / mentoring a team through a short term project to build a data viewer application based on Virtual Earth, Dojo, ArcGIS Server (9.2) and ASP.NET.

One of the user stories in this project is:

As an administrator I want the Data Viewer to be database agnostic so that I can easily configure it to pull point data from SQL Server, Oracle or file based data sources.

Now, this is a great idea, and certainly possible. In fact it ends up being very interesting to design (plug-ins, configuration sections and Inversion of Control oh my!).

Simple works...

In looking at the project (it's very short term) and the team (new to web development) and the current problem they are trying to solve (display data from SQL Server), my recommendation to the team is that we "keep it simple" for now, and just address the SQL Server data source.

While we could define a set of interfaces, build out a whole configuration model, and create the actual data access objects for these various data sources, in the context of this project it's extraneous. To be "successful", we need to display the current data in Virtual Earth. With tight time frames and limited resources, I believe the tradeoff between building for an unknown complex future need, and applying time and effort to the core objective, is a good one. The team will be able to get the database access tier of the system completed in a short time, and it will be very simple to understand - parameters are passed to a class, which calls a stored procedure, which returns the point data. Simple, clean, and working.

But what about the "can accomplish the same task" bit? Good question - I'd suggest that in this situation, with the current data is in SQL Server, you are doing the same task - just using a simpler design to achieve the goal.

Add Complexity when it is Needed

If / when a need arises to add data from Oracle, it will be a very simple task to create another class which mimics the SQL Server class, with the only difference being that it uses the Oracle data connection classes. Should this Data Viewer become a huge hit, and is used so extensively that it must become configurable by non-developers, it could then be refactored to add in the additional complexity required to support configuration sections and a plug-in data provider model. But for now, the much simpler solution works just fine.

So - to summarize: Make choices which trend towards keeping the code as simple as possible. Don't add extra features or design elements to handle unknown or fuzzy future requirements. Add complexity only when it's really needed. While it's fun to monkey with internal design optimizations etc, keep your eyes on the prize: software that works for the user. And keep in mind who will be maintaining the software over the long haul - while you may be a whiz at generics (for example) keep in mind that for many people they tend to make understanding the code more difficult.

That's pretty much my take on this, but I'd love to hear your thoughts on keeping software "simple". How do you decide when to add complexity? How do you define complexity?

Other thoughts on Simplicity:

Joel On Software: Simplicity

The Fourth Law of Software Design: Complexity vs. Ease of Maintenance

Various Quotes on Simplicity in Software Design

Monday, July 07, 2008 5:06:07 AM (Mountain Daylight Time, UTC-06:00)
Hi Dave. Interesting blog - I'm a database developer taking some time out to train in GIS, so this is useful stuff to me! Right now as part of my MSc project, I'm implementing a simple web-based map query interface to assorted spatial data held in shapefiles, TIFFs, databases etc. I'm hiding all the DB-specific stuff behind GeoServer, which means I only have to configure each data-source in GeoServer instead of writing my own code for the interface. GeoServer then provides a standard OGC interface that I could query from all kinds of clients - I'm using OpenLayers because it does all I need right now, but if necessary it should be pretty easy to re-implement the GUI for GE, VE etc. And I could also swap out the OGC server and use e.g. MapServer if necessary, without having to change the interfaces. Meanwhile, the server code(PHP) is pretty simple because GeoServer does all the spatial stuff. DRY and all that. This seems to be a fairly common approach (it's not like I'm smart enough to invent all this stuff myself!), so I'm curious as to why you appear to be re-inventing this particular wheel instead of grabbing something like GeoServer or MapServer to do it for you?
Cheers, Chris
ChrisW
Monday, July 07, 2008 9:01:03 PM (Mountain Daylight Time, UTC-06:00)
I think it's always a good idea to keep design patterns in mind, which will keep applications extensible for future enhancements and makes applications easier to maintain. Also keep in mind projects already out there, like feature data objects which provides a number of database and file providers.

Friday, July 11, 2008 5:34:32 PM (Mountain Daylight Time, UTC-06:00)
Great post - the simplicity/complexity dilemma is something I've been wrestling with a lot over the years (I'm an Air Force officer working on military comms & intel systems - talk about complexity!). I'm a big fan of Agile practices as well, and am trying to push & encourage the DoD to do more of that kind of thing.

I also wanted to invite you to check out a (free!) book I wrote on the topic. It's titled The Simplicity Cycle, and it's a visual exploration of the relationship between complexity, goodness and time. I think you might find it interesting and useful. You can download the PDF at www.lulu.com/content/877467 (or pay $10 for a hardcopy if you really want to... but I'd recommend the free version).
Comments are closed.