By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,097 Members | 1,529 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,097 IT Pros & Developers. It's quick & easy.

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

P: n/a
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"

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

"A little government and a little luck are necessary in life, but only
a fool trusts either of them." -- P. J. O'Rourke
Nov 9 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.