Advice from senior Members

Nick Craig-Wood nick at craig-wood.com
Fri May 23 16:30:09 EDT 2008


flit <superflit at gmail.com> wrote:
>  I am looking for some experience from the senior members.
>  Now I am doing a simple desktop application, this application will
>  have 3 main functions:
> 
>  1- Read information about the desktop system;
>  2- Interact with the user;
>  3- Send information to a server.
> 
>  The first part, reading information about the desktop system, is
>  already done.  And now I am starting to make the gui for the user,
>  that is when the question appear: "What is the best way to make it?
>  divide in files? by classes or functions?"  I have now one big file
>  with all functions to get the desktop information.  Should I make
>  one file for the visual functions (wxpython)? another for the
>  server?  Is productive to divide in files? what is the best way?

I would divide it into 3 files, one for the desktop info, one for the
server interaction and one for the GUI.  Subdivide the files if they
start getting unmanageably long

My wx programs tend to be full of lots of little classes.  I make
every object (pane, window, widget etc) its own class and glue them
all together in other classes.

I'd make your read the information file into probably a single class,
with each function a method.  You can then either read all the
information on __init__ or as methods whichever seems best to you.
Your gui classes will then query this as appropriate (this is the MVC
as discussed by another poster).

You can write another text mode interface for the desktop info module
which prints things out in text format for testing.

Once you've divided your program up, you can start thinking about unit
tests.  You can certainly unit test your desktop info gathering, and
your server interaction.  It is hard to write tests for wx GUIs though
(but not impossible).

When you've finished you'll have 3 files full of classes.  You may
have a few utility functions too.

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list