This page has moved to

Sunday, February 12, 2006

Ruby duck typing

Old habits die hard. I am writing a set of Ruby classes for handling a variety of document types and my first inclination was to start to design a class hierarchy to factor out common behavior for processing different document types. Specifically, I am handling Word, and AbiWord documents. After a little thought I realized that the only common behavior is uncompressing and reading XML files for and AbiWord. Also, I only need one public method for my application: given a file path to a document return the plain text from the document.

Anyway, I will start with writing 3 unrelated classes - one for each document type. They will all implement one method signature for retrieving plain text for a document file. I am likely to eventually factor out some common code for processing and AbiWord documents, but I can put off that decision (it is better to refactor after you understand a problem better).