software design question
Pierre Rouleau
prouleau at impathnetworks.com
Sat Feb 7 15:43:31 EST 2004
>
> Ok, the following is the case:
> I got a GUI. This is the base class (automatically generated) from which i
> derive a class that does the implementation. However, since that may become
> rather big I devided the functionality into different modules, i.e. one for
> presentation, one for file-IO, one for help-topic related stuff, etc.
> So this main file imports the modules that implement the functionality.
> Obviously these modules need to access things like "enable action"s, install
> hooks, etc. from the "main part".
> And thats why the circular dependency.
>
> I know that circular dependencies are rather bad than helpful, but the only
> way to circumvent this is to build everything into one big block - which I
> find is rather worse: the source file grows much too large to maintain a
> good overview.
>
> So the question is rather: how to make a better design?
>
Why not look at the GUI as a "presentation layer" that provides access
to the program functionality, like file I/O, help access, etc. Then the
file I/O, help, (etc...) can be written without any knowledge to the GUI
(and therefore testable from a python shell or a testing script) and the
Gui code just call the File I/O, help functions or members. If you need
callbacks, then provide callbacks. This way you would decouple the
GUI from the system functionality. Only GUI code would import the other
modules. The File I/O, help (etc...) would not know anything about the
GUI implementation requirements.
Hope that helps,
Pierre
More information about the Python-list
mailing list