[FRPythoneers] Help With Object Oriented Design

Jim Vickroy Jim.Vickroy at noaa.gov
Thu Dec 26 08:24:00 MST 2002


Hello John,

... just a brief answer to some of your questions ...

It seems that the DataDog (DataDawg?) class is not an **extension** of the DimFile
class (i.e., the same attributes/behaviors/methods of the DimFile class plus some
additional attributes/behaviors) so it probably should not extend DimFile.  It
seems that DataDog employs a DimFile to accomplish its tasks.

It also seems that DataDog could become very complex by trying to perform too many
tasks.  You may wish to define some classes that extend a basic DataDog to perform
specific tasks (output a specific format) or are standalone classes (interface
with relational stores).

John Purser wrote:

> 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
> _______________________________________________
> This message sent by the FRPythoneers mailing list.
> Unsubscribe: echo unsubscribe | FRPythoneers-request at lists.community.tummy.com
> URL: http://lists.community.tummy.com/mailman/listinfo/frpythoneers




More information about the FRPythoneers mailing list