Brad Clements wrote:
> The code that creates the above query (or those like it) is 
> getting pretty long. I'm 
> interested in more expressive mechanisms that still retain 
> the ability to understand...

You have a lot of logic in there that I don't think is reducible; the
structure, however, is made more manageable by refactoring. I'd *start*
by passing an object instead of a string as the dataSet parameter, and
building attributes and methods into each object rather than using the
large if/else statements. That is, rather than

    if dataSet == 'ShipmentCharges':
        shipcols = self.shipmentChargesColumns
        packageColumns = ()
        queryShipmentCharges = True

you could write:

    q = Query()
    dataSet.populate(q, opts)

...and stuff the dataset-specific logic into the ShipmentCharges class.
Find the common code to all classes and stuff that into a superclass
from which the other classes inherit.

And so on ;)


Robert Brewer
MIS
Amor Ministries
[EMAIL PROTECTED]
_______________________________________________
DB-SIG maillist  -  DB-SIG@python.org
http://mail.python.org/mailman/listinfo/db-sig

Reply via email to