[Tutor] Problem with file()

Kent Johnson kent_johnson at skillsoft.com
Sat Aug 21 16:43:06 CEST 2004


 From your description, I think I would try a procedural design to start. 
You can use different modules to hold different kinds of functions on a 
client list. The main program would create a client list and pass it to 
various functions to get some work done.

It's possible that the client list itself should be a class that either 
extends list or wraps a list. This would be appropriate if you have several 
functions that operate on the list, such as getextlist(). These functions 
could become methods of ClientList. You could take this one step further 
and add higher level functions to ClientList such as copying and deleting 
files. These methods could use helper functions from your functional 
modules. Alternatively you could have a way to execute a function on each 
member of the ClientList.

But this is likely overkill, from what you have said so far. Start with the 
functional organization. Keep an eye out for common operations on the 
client list or functions that take similar parameter lists. These will show 
you where you might want to create some classes. The code will tell you 
when it is time to use classes.

Kent

At 03:52 PM 8/21/2004 +0100, Bernard Lebel wrote:
> > BTW from what you have shown here, using a class to hold the getextlist()
> > function may be overkill. Classes are great when you have several
>functions
> > that have to work together, for example sharing common data in fields. If
> > you have independent functions that you want to group together for
> > convenience/modularity/testing/reuse, you can make them global functions
>in
> > a separate module without creating a class.
>
>Well you might be right. The classes are there mostly to encapsulate few
>functions instead of having them all under the same level. But the module
>has versatile functions: one is to work on a "client list", wich is the
>cmClient class, while the other classes use the list. For instance, the
>cmFile class is to copy, move and delete files over a large number of
>computers, and the cmServices class is to handle remote processes of this
>list.
>
>Like I said right now everything sits in the __init__.py file. I will
>definitely give a try to your separte module setup suggestion.



More information about the Tutor mailing list