[Python-talk] [Fwd: OOP, when and when not to use it...]

Lloyd Kvam python at venix.com
Mon Aug 10 11:21:24 EDT 2009


On Mon, 2009-08-10 at 10:05 -0400, Ben Scott wrote:
> > My own introduction to OOP came from perl ...
> 
>   While I pretty much agree with Paul's take, I still can't help but
> think that this is like having a guy who's only red-green color blind
> describe color to a guy who's monochromatic.  ;-)
> 
>   (Not that my own attempts {were, would be} any better, really.  I
> got *my* OOP intro from C++.  Ick.)
> 
> -- Ben

Alan Gauld is one of the contributors to the Python-Tutor list
(moderated by Kent) and posted this tutorial:
http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm

If you search out Alan's advice on the tutor list, you'll see that he is
quite adamant about behavior (methods) being the driver in your OOP
design.  Having learned OOP from the C++ viewpoint where a struct (data
grouping) is the starting point, I focused on the data first.  

Eventually I realized that Alan is right.  Issues with data and function
signatures, may signal a need for OOP.  However your OOP design will be
much smoother if you focus first on the methods and let them drive the
data.  For me, test driven design will generally get me on a sensible
course without too much wasted effort.

-- 
Lloyd Kvam
Venix Corp
DLSLUG/GNHLUG library
http://dlslug.org/library.html
http://www.librarything.com/catalog/dlslug
http://www.librarything.com/rsshtml/recent/dlslug
http://www.librarything.com/rss/recent/dlslug



More information about the Python-talk mailing list