Wednesday, December 13, 2006

On clean reusable interfaces and the pleasure to see things happen

As Dom wrote it already, if you are having your documents mainly in MS Works format (yes, it is normally what comes often pre-installed on a new purchased computer along with some version of Windows) you are not excluded from the free desktop any more.

Focus on libwps, a Microsoft Works file word processor format import filter library

There is a nice neat tiny library, libwps, that allows you to read those documents and convert them to other formats. A plug-in for HEAD version of AbiWord exists and its integration into should not take a lot of (coding, the QA and paperwork is other beast) time.

The library (not yet released, but ready to be soon) deserves to have some spot-lights on it. Not only it fills a gap in file-format coverage by FOSS word processing applications, it's author Andrew Ziem is an example of a hacker that your servant likes and gets encouraged by. Being one of the great applicants for Google Summer of Code with, his proposal was finally refused. It was a close call and the refusal was only due to the ridiculous number of 6 slots allocated for 69 eligible applications and 20 mentors standing on starting blocks. Many other would get discouraged and abandon the idea of contribution to the FOSS. Not Andrew! This great hacker started to code for his pleasure and libwps is the wonderful result of his work. Your servant has had the privilege to be assisting to the birth of the project and feels lucky.

The number of reinvented wheels should be (almost) zero

For a FOSS project, the beginning is often important. The hacking has to be fun and the results have to come in a tangible manner quite quickly. Otherwise, one is more likely to reallocate one's free time for other activities and the nascent FOSS project experiences a cot-death. On the other hand, to get a library design right can be quite difficult especially if one does it for the first time.

The design choice of libwps was the right one: take and reuse the interface and design of a tried and true library used by ALL free and open-source word processing applications, the libwpd. This allowed to avoid several possible iterations of bad designed interface and focus on the MS Works files conversion itself. A nice side effect of this choice is also that was super-simple to integrate a filter based on libwps into AbiWord and it will not be much more difficult to integrate it into or kWord as well. Well, from the design point of view, that is.

Clean and reusable interface design

That this was possible is a deliberate choice of libwpd maintainers. The thanks go especially to Marc “uwog” Maurer and William Lachance for the original design. The idea would be to extract the reusable interfaces from libwpd itself and provide it as a framework for developing import (and possibly export) filters from (to) binary file-formats at least. The libwps experience shows that it is possible. The advantage of the interface is that is does NOT expose STL types to user, so it is usable for applications that use different STL implementations with different signatures from the STL implementation used by the underlying system. As it is the case of that uses STLport internally. A library developed using this interface would be usable both as internal or system library for the given application. So, filter developers of all countries, unite!