Twitter GitHub Facebook Instagram

Daniel Irvine on building software

Simplifying data flows

11 June 2012

In a previous post I talked about keeping data in a data store valid by refusing to accept any invalid objects as input and ensuring all existing objects stay valid.

One of the objections that came up was this: it’s better to be forgiving when accepting user data, since the user isn’t likely aware of all the validation rules that apply to your system. Forcing them to adhere to validation rules only hinders them, and that’s the last thing you want.

I agree with this in that you really don’t want to hinder the user, but we can solve this in a better way than breaking consistency in your data models. We can provide tools and data transformation tools that help them get their data in a better state. There is probably a wealth of support and suggestions we can provide to fix each mistake.

A simple example is when you create a user account on a website. If the username you choose is already registered, the system should error and prohibit you from creating an account with that name, since usernames must be unique. But so as to not hinder the user, you can provide a suggestion for a similar username that is available, perhaps by appended a short numeric string on the end of their chosen username.

You can also automagically fix data where appropriate, if you can.

About the author

Daniel Irvine is a software craftsman at 8th Light, based in London. These days he prefers to code in Clojure and Ruby, despite having been a C++ and C# developer for the majority of his career.

For a longer bio please see To contact Daniel, send a tweet to @d_ir or use the comments section below.

Twitter GitHub Facebook Instagram