Dale Zak is a (Canadian) Windows Mobile programmer. Over the last few months he has been interested in helping with the Ushahidi platform. We didn’t have anyone with WinMo experience, so he developed an application that would work with our API on all WinMo devices. We’re extremely excited to have a person of Dale’s caliber helping on the project!
Below is an explanation of what he has done, in his own words.
Ushahidi for the Windows Mobile platform, is a Compact Framework 3.5 application targeting both Pocket PC (touch screen) and Smart Phone (non-touch screen) devices.
When developing for the Windows Mobile platform, it’s always a difficult decision whether to develop:
a) light-weight Smart Phone version using Windows Mobile 6 Standard SDK which also runs on Pocket PC devices
b) separate Smart Phone and Pocket PC applications, using the Windows Mobile 6 Standard SDK and Windows Mobile 6 Professional SDK for each
Going the light-weight Smart Phone route allows you to focus your attention on a single application, but loses of the benefit of richer UI controls like buttons on a touch screen. However, the other option of developing two separate applications leads to code duplication and increased maintainance.
To get the best of both worlds, Ushahidi is targeting Smart Phones using the Standard SDK and Pocket PC devices using the Professional SDK. However each project shares the same underlying classes, reducing duplication. The only code that is unique to the specific platform, is the actual UI Designer classes.
In the attached screenshot Shared.jpg, HomeViewController.cs, HomeModel.cs, HomeView.cs and Program.cs files are shared by both Ushahidi.View.PocketPC and Ushahidi.View.SmartPhone projects. Only HomeView_SP.cs, HomeView_SP.Designer.cs and HomeView_SP.resx (created using UI Form Designer) are specific to Smart Phone project. For the Pocket PC, HomeView_PPC.cs, HomeView_PPC.Designer.cs and HomeView_PPC.resx are unqiue to that project. Most importantly, all the real work and event handlers exist in HomeView.cs, made possible using partial classes.
Another unique aspect to Ushahidi project, is the implementation of a light-weight MVC framework. There are a lot of benefit to adopting a MVC technique, unfortunately typical WinForms development is rather weak in this regards. So, to avoid tightly coupled forms, I’ve implemented a NavigationController that is responsible for maintaining a stack of Views, as well as a central place to cache existing Views. In the spirit of MVC, a ViewController is responsible for populating a View with Model data, and upon exit responsible for saving the View data back to the Model. It’s the NavigationController’s job to show the View upon being pushed onto the stack, or hide current View after bring popped from stack.
Using this shared solution and MVC technique, we are able to develop a flexible application with a platform-specific UI, while sharing the same underlying code behind.