Fulvio a écrit : > *********************** > Your mail has been scanned by InterScan MSS. > *********************** > > > On Saturday 21 October 2006 02:01, James Stroud wrote: > > I think the trick is to identify when a class would make more sense than > > a collection of subroutines > > I do believe that's a bit of forecasting, in sense to determine whether a > piece of code may have a future. > Usually in hobbistic term I think we can > bear with copy&pasting pieces of code across programs rather than go for a > class(es) module.
OO and reuse are two orthogonal concerns. You don't need OO to reuse code, and OO is not so much about code reuse - even if it can improve reusability - than about how to best structure your code. To illustrate James' POV, if you end up with half a dozen functions working on a same well-defined data structure, then it might be time to 'integrate' these functions and the data structure into a class. Some other hints are when you have a small set of functions depending on a common set of globals, or when you find yourself adding to your functions signature too much additional params that are only meant to be passed to other functions that themselves will pass them etc... Copy-paste reuse should IMHO be limited to very trivial helper functions that are not worth the pain of dependencies management... My 2 cents -- http://mail.python.org/mailman/listinfo/python-list