Visions of Aestia

30 Mar 2005

Procedural Java code is ugly

Filed under: Programming — JBowtie @ 11:29 am

I started working on an implementation of VTD-XML in Python, using the examples provided as test cases.

It’s not quite as straightfoward a conversion as I expected for the main parser. After the encoding detection, the core parser is a huge switch statement with lots of embedded conditional logic. This is very procedural and very, very ugly, especially since Java is so verbose.

So, I’m implementing this very slowly so as not to get lost in the deeply nested regions. The two changes I’ve made so far are using Python’s native codecs package for the character iteration and actually implementing the state machine with the State design pattern. Making each state a class allows me to break up the conditional logic further so I know what’s going on.

Once the parser is done the rest should be relatively painless. I might initially go with an array of tuples instead of bitpacking the lookup tables.

One Response to “Procedural Java code is ugly”

  1. Jimmy Zhang Says:

    We are trying to simplify the parsing routine, in hope for a better
    cleaner and comprehensible code.
    Let me know if you have any questions.

    Cheers,
    Jimmy Zhang

Leave a Reply

Powered by WordPress