At work a couple of weeks ago I was given the task to build a multi document interface text editor for the LISP programming language. It was supposed to provide syntax highlighting and bracket matching, and the usual Open/Load/Save/Close operations.
Being a TDD enthusiast, I wanted to give autotesting that graphical user inteface a try. Previously I’ve tried the Humble Dialog pattern, aswell as some home-brewn MVC mixtures in the past. Both with mixed feelings (too awkward, too hard to easily test).
Anyway, since building a syntax highlighting text editor from ground-up seemed like a bad idea when there are fine Open Source alternatives like the TextEditor component from the SharpDevelop community, I started out learning the API in a spike project first of all.
When I spike-hacked away, I continously thought ”how am I going isolate/test this?”. And when I finally got to the point where I wanted to build ”Open/Close” and those basic commands, I still had no idea how to make it work.
So I started to read up on another pattern I’d heard of, the Model View Presenter (MVP) pattern. It seemed to provide even more loosely coupled types than the previous two, giving air to unit tests. But I took a too big chew; practicing and understanding the new pattern while also working with the new component was a little too stressful at the high pace of work, so I made a pragmatic decision to practice the pattern at home first, before I started using it at work.
Here we are! And I’m going to choose a really simple GUI to practice on; it will be a ”item list pick/reorder” GUI. The user is presented with a list of text items, which can be reordered using up/down arrow buttons. Then, double clicking an item chooses that item, while clicking the cancel button picks no item. Reordering is left unaffected whether the user picks an item or cancels.
This is a schematic of the GUI dialog presented to the user:
This is the first blog post in a series detailing what I find out about the MVP pattern. If all goes well, I might extend the example to more elaborate user interface. On the technology side, I intend to use Visual C# 2008 Express Edition, and the open source NUnit test framework.
Taggar: programmering, programming, mvp, csharp, tdd, gui-testing