The design for LMX 2.0

2007-03-12 23:14:06 -08:00

LMX 1.0 didn’t really have much design to it. I set out to clone NSXMLParser‘s API, which I did, but didn’t give a whole lot of thought to how I would actually implement the parser.

As a result, the parser itself is one humongous method that takes a lot of effort to read. It is only navigable at all because I had the foresight to put in lots of #pragma marks.

LMX 2.0 will not make that mistake. This time, there’s a design, and the parser will not all be in one function. Here’s the design, which I drew on a quadrille pad:

All states have prefix “lmx_state_”. All states are functions; struct LMXParser's “state” member has type LMXParserStateFunc, which is a function pointer. There is also a “saved_state” member, used when entering entity_ref state. parser->state is called for every character in the XML data.

To be explicit, these are all implementation details which will not be exposed to clients of the API.

And the scanner I used to import this from dead tree format is the CanoScan LiDE 600F I mentioned in passing in my post about my HP M425 camera.

3 Responses to “The design for LMX 2.0”

  1. Chris Forsythe Says:

    Want me to graffle this up for you?

  2. Peter Hosey Says:

    Please do. :)

  3. Jamie Says:

    One huge method…what were you thinking man?

    /me points Boredzo @ Refactoring by Martin Fowler.

    I’ve never again written a huge method since I read that book. Thinking about it its probably time for another read again…

Leave a Reply

Do not delete the second sentence.