[Tutor] Here's something to talk about

Alan Gauld alan.gauld at btinternet.com
Thu Apr 16 01:05:41 CEST 2009


"Weidner, Ronald" <RWeidner at ea.com> wrote

># This code is posted for the purpose of conversation.  If it is of some
> # value to someone that would be great.  But what I hope is that the code
> # sparks conversations about what I did in this code and why I did it. 
> Since
> # the list seems thick with OOP questions at the moment, I thought this 
> might
> # be relevant.  Digest and enjoy.

Some fairly quick comments based on an initial scan:

>
> class Item ( object ):

Its good to put some documentation strings describing the purpose
of the class, same for the methods.

>    def __init__( self ):
>    self._FullName = ''
>    self._Recovery = 0
>    self._Exporter = SimpleItemExporter ();

Why not make these default values of parameters? That then gives the
clients the chance to initialise the values at instantiation time.

> class SimpleItemExporter ( object ):
>
> def __init__( self ):
> pass

This does nothing, you do not need an __init__ if its not used.

> class XMLExporter ( object ):
> def __init__ ( self, tag='XML' ):
> self.SetRootTag( tag )

Nothing wrong with doing direct assignment inside a method.

> class SQLExporter ( object ):
>
> def __init__ ( self, tableName):
> self._TableName = tableName

Which you do here!

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 




More information about the Tutor mailing list