Friday, September 21, 2007

Trying to Extract Features from AutoFormatter

I took a look at the AutoFormatter code last night, and tried to make a start on extracting the code that does the conversion into a class library.

I can't say it was an easy task though, and at the end of it all I found I'd done it wrong anyway. What I really need is a class that just converts RTF to HTML, but I had extracted the method that creates the div blocks around the code as well. Surrounding the code in this way does make the end result nice and pretty, but for the purposes of a generic conversion library it's not needed.

It was about 11 o'clock last night when I figured this out. It's always a little disheartening when you find you've just spent the last 3 hours doing something that you now need to discard.

Guess that's what happens when you try to modify code without truely understanding it. I can't see any unit tests in the code to give an indication of the intention of some of the code, or to provide a safety net to the quite severe refactoring that I am attempting.

But I think extracting the RTF to HTML code should be easier than what I did last night. There were a number of options I needed to extract into a class and pass into the method last night, but I'm sure I don't need all of this for the straight conversion.

I'll see how it goes.

No comments: