[Tutor] class initialization with a lot of parameters

C.T. Matsumoto c.t.matsumoto at gmail.com
Wed Nov 11 08:40:12 CET 2009


Thanks for the ideas,

I see I still don't have the hang of this context thing! I still haven't
provided enough
context. So here goes again, to show the entire chain. This might change the
discussion to be about design practice but it will give overview of how I'm
using
the class in question.

First I've got a db class

class DB(object):
    """ This does all the database handling.
    """
    ...

Then I've got a class to filter a list of potential tables to be compared.
These
tables need to be tested.

class CompareTableList(DB):
    """ Make a master list, from a source list of compare tables
         that need to be compared.
         If the tables in the list pass the tests make a CompareItem.
         Store all the CompareItems in a compare_list.
    """
    ...

CompareItem is the class in question.

CompareItem(object):
    def __init__(self, ref_table, ref_dburi, ref_rows, test_table,
test_dburi, test_rows, keys):
        ...
    ...

This would be your suggested TestTable only it already has the pair and is
ready to be
compared. Rather than a method compare is a class.

Compare(CompareTableList):
    """ Foreach CompareItem in the CompareTableList.compare_list. Workout
         the differences and store difference in something that can format
         a report.
    """
    ...

Cheers,

T

On Tue, Nov 10, 2009 at 10:12 PM, Alan Gauld <alan.gauld at btinternet.com>wrote:

>
> "C.T. Matsumoto" <c.t.matsumoto at gmail.com> wrote
>
>> This list provides defines 2 tables that need to be paired and then
>> compared.
>>
>
> So two instances of a TestTable object maybe?
>
>
>  reference_table_name
>> reference_dburi
>> reference_rows
>> test_table_name
>> test_dburi
>> test_rows
>> keys
>>
>
> Looks like two TestTable objects and a set of keys?
> And maybe TestTable has a comparison method that compares one table to
> another? Or maybe can index a row based on a key?
> Maybe the Rows are objects too and they can compare themselves?
>
> Lots of possibilities depending on your problem.
>
>
> Just a thought.
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Todd Matsumoto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091111/b5b7e326/attachment.htm>


More information about the Tutor mailing list