Separating GUI and code

Andrew Cooke andrew at andrewcooke.free-online.co.uk
Tue May 11 07:35:24 EDT 1999


Hi,

I am designing an application which has a very close connection between
the GUI and various objects in the code (there are also some aspects of
the GUI which do not correspond so closely to the underlying objects).

I want to separate the GUI and the underlying functionality so that
different toolkits could be used to provide different (but functionally
similar) interfaces.

I have very little experience of GUI design/implementation (but am very
happy with OOP in general).  My first instinct was to make the objects
that have an obvious GUI representation inherit from the appropriate
GUI object (eg. lists of data extend the GUI list class).  However, this
makes the code strongly dependent on the GUI API (not what I want).
(And, IMHO, inheritance is a double-edged sword - composition is often
better unless the relationship is very tight).

How would others here go about tackling this problem?  Should my objects
include GUI components which the access via a standard API (of my own
invention, but based closely on a particular GUI API) - each GUI
implementation would then involve writing wrapper classes to match the
GUI API to that expected.  Does anyone have any experience of this?  Is
it easy to configure?

With little experience of GUI I am unsre just how complicated the
interface should be - I prefer simplicity wherever possible (especially
after having had to work on a projects= where GUI and functionality were
strongly mixed , leading to a maintenance nightmare).

Sorry my question is rather vague.  No doubt after a first attempt I
will know much better how to tackle this - but I'd like my first
attempt to be as near the mark as possible.  Any advice/pointers to
sample projects/code appreciated.

Thanks,
Andrew

----------------------------+------------------------------------------
work andrew at intertrader.com | play andrew at andrewcooke.free-online.co.uk
 http://www.intertrader.com |  http://www.andrewcooke.free-online.co.uk

--
-----------------------------+--------------------
-----------------------
work: andrew at intertrader.com | play:
andrew at andrewcooke.free-online.co.uk


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---




More information about the Python-list mailing list