Do I want multidispatch or object plug-ins or something else?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Cioffi

    #1

    Do I want multidispatch or object plug-ins or something else?

    Hello all,

    I've got an EDI parsing application written in Python that is becoming
    unwieldy to maintain. At a high level here's what it does:

    1. Loops through the EDI message 1 segment at a time (think SAX XML...)
    2. Once it identifies what type of transaction is being processed it
    creates a "sub-parser" specifically for that transaction type
    3. The sub-parser marks up the EDI into HTML and extracts a fair
    number of statistics about the transactions.

    Now, my sub-parser classes are polymorphic and I've used the hierarchy
    to make sure I don't have repeated code in each class. HOWEVER, I'm
    finding it difficult to add new statistic gathering methods because
    the code is already rather complex. That leads me to think I've got
    bad design.

    What I _think_ I want is a way to register plug-ins that say "I work
    with transactions of type X,Y,Z" and then have the sub parser string
    together calls to the various plug-ins.

    The "master" sub-parser would handle the basic EDI -HTML formatting
    and the plug-ins would handle gathering any statistics. I currently
    use introspection to figure out what segments sub-parsers are
    interested in and I figure I would keep doing that in the future.

    Can anyone point me to either an on-line or off-line resource I could
    use for this type of thing? Are there established "plug-in patterns"
    already?

    Part of why I'm asking is because I don't think I even have the right
    vocabulary to describe what I'm trying to do. Any pointers would be
    appreciated!

    Chris
    --
    "A little government and a little luck are necessary in life, but only
    a fool trusts either of them." -- P. J. O'Rourke
Working...