[Tutor] design question

Albert-Jan Roskam fomcl at yahoo.com
Fri Sep 10 11:23:07 CEST 2010


Hi,

I've made a small data entry program where a picture of a hand-written, scanned 
form is shown next to several text entries. The design has been largely 'bottom 
up', although of course I started with a rough sketch. I started with the 
following classes: Menu (responsible for the widget creation), Autocomplete (a 
subclass of the tkinter text entry widget which I've found on the internet, I 
wanted to keep this intact), Convert (responsible for the conversion/cropping of 
the images, which is somewhat tedious) and Events (here's the pain spot: this 
has become a mixed bag). Originally, the Events class was supposed to contain 
all the commands behind the widgets, but it has slowly gotten more 
responsibilities. Notably, all methods that deal with reading/writing the data 
also live here. The program is about 500 lines of code now, including blanks.

I'd like to rewrite to entire program so that (1) all classes have just one 
responsibility (2) classes connect to as little other classes (so it becomes 
easy to e.g. change to another widget set). I'd love to hear some thoughts or 
advice on the new design from you (I hope my description wasn't too short). Is 
there a specific design pattern that could be used?

One specific, additional question: the program has a title bar that shows 
something like "processing file X (1 of 3; 33%)". My colleague suggested to use 
the Iterator pattern (gang of four) for this. Is this (a) overkill (b) a simple 
opportunity to apply this pattern? 


Thank you in advance for your advice!

Cheers!!
Albert-Jan


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public 
order, irrigation, roads, a fresh water system, and public health, what have the 
Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100910/0d6bbd96/attachment.html>


More information about the Tutor mailing list