[wxpython-users] code structure - suggestions? (classes for
gui, data, calculations...)
Igor Jese
igor at jeseonline.com
Mon May 19 07:11:57 PDT 2008
> I try to separate my logic code from the GUI as much as possible. The
> MVC model is definitely one of the best ways to go, although I doubt I
> follow it too closely. So far, most of my projects are very small, so I
> just put logic code into what amounts to a logic module or modules. Then
> I just import the functions to whichever GUI file needs access to
> whichever function.
You can do it in similar manner even more robust: your classes that
actually do something (the "model") in one file, GUI in 2nd and flow (the
"controller") in the 3rd (of course you can have more than one for each,
where needed)
- GUI: all it does is triggers actions in controller (and sometimes might
keep it's own state in separate class - if you need it).
- Your model is unaware (by definition) of the world outside. This way you
can (and should) unit-test it
- Controller "keeps the flow", it talks to both GUI and Model and
implements your app behavior.
IMHO you don't need full MVC for small(ish) applications. Also observers
lessen "visibility" when debugging.
You can check several approaches (MVC, MVP and "Humble View") at Martin
Fowler blog:
http://martinfowler.com/eaaDev/uiArchs.html
Regards,
Igor
--
Igor Jese, igor at jeseonline.com
http://MockupScreens.com
http://SimpleProjectToDo.com
More information about the wxpython-users
mailing list