[FRPythoneers] Help With Object Oriented Design

John Purser jmpurser at yahoo.com
Wed Dec 25 08:44:08 MST 2002


Merry Christmas!

I'm working on a project in Python and it's my first real application
of Objects.  My purpose is to create a useful interface to our
company data which is stored in ISAM files.  I want to be able to
dump the data to files, spreadsheets, or a database.  

I've written a class to read the data file type and I've automated
the creation of the code to subclass that for each file type.  I can
connect, read, and write any data file in the system with no major
problems.

Now I'd like to add the functionality of creating multiple types of
outputs like those listed above plus allowing the addition of any
others that come along.  There is an active community using the same
business software and I plan to release the code when I'm done so I
want it to be pretty flexible.  Currently my structure looks like:

class header:

class DimFile:
    myheader = header()
class IM1(DimFile):
    IM1DataMap = {"Constant Dictionary"}
    def IM1FormatTest():
        "A routine to tell which format to use to read this binary
string ouput"

Now, where do I put a class (DataDog) that can output mulitiple
formats, create database tables, etc.  My test setup will use MySQL
but I'll add Excel and MS SQL as well as delimited text files later. 
I want this code to be able to read the "DataMap" above that tells
how many records types are in the file and the format for each type
and use that information to create the correct number and structure
of tables or spreadsheets as well as delimited file output.

While I can see the class/code that will allow this I'm confused
about where to put it.  Should I add it as a "IsA" or "HasA" to the
DimFile class or keep it seperate.  I'm planning on passing it the
raw file descriptor (DataMap) for the file so I don't think it would
be much good outside of a DimFile class but I could make it more
generic and add the code to convert the DataMap to standard SQL
before it passes it to the DataDawg.

Design suggestions would be appreciated.  Objects look so obvious
when I'm thinking about them but get real muddy when I start to code.

Thanks for the help.

John Purser


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



More information about the FRPythoneers mailing list