Wednesday, January 26, 2005

UI and Scripting

One thing that Scott Collins mentioned in his talk tonight on "Mozilla Lessons Learned" at the SDForum Software Architecture and Modeling SIG touched a nerve. He suggested that User Interfaces should be scriptable. This is something that I have believed for a long time.

In my early days I built several interactive user interfaces only to find that their principal use was with scripts. This was before GUIs so you could just feed a script into any UI. The problem was that as I had assumed that the interface was being used interactively it did not handle errors in the script gracefully, and the program would often get wedged.

Recently I have only been tangentially involved in UI design, however there are two things that I have noticed. Firstly, GUIs are notoriously difficult to test, and secondly, as always, any worthwhile application that has a GUI also needs an API for automated access. Consider that a scripting interface can be used to expose programmable access to the application and we get to a thought about how we should be building applications with GUIs.

Instead of designing an application with a GUI, we should be designing the application with a language interface. This makes the application accessible from a scripting interface, and it also allows comprehensive automatic testing of the application through scripts. At the same time the application needs a GUI, which should be generated automatically from the language definition. Because the application is thoroughly tested through its scripting interface and because the GUI is generated automatically, the GUI does not need a lot of testing. Provided that the GUI generator works properly, the application GUI should work properly.