Relationship between GUI and logic?

John Salerno johnjsal at gmailNOSPAM.com
Thu May 22 23:37:45 EDT 2008


I know that it is good programming practice to keep GUI and logic code 
physically separate, by using XRC for example, but I'm wondering if it's 
also good practice (and even possible) to keep them separate from an 
implementation standpoint as well. Basically what I mean is, should it 
be possible to write, for example, the logic for a strategy game without 
even knowing what the graphics will look like or how they will work?

To be more specific, let's say I want to create a simple, 2D strategy 
game. It will have a board layout like chess or checkers and the player 
will move around the board. Let's say this is all I know, and perhaps I 
don't even know *this* for sure either. Is it possible to write the 
logic for such a game at this point?

Let's say I want to write a "move" function (or perhaps it would be a 
method of a "Character" class) for moving the player around. Could you 
really write this function without 1) knowing what the interface will 
look like, and 2) integrating GUI code with the logic?

Another example could be printing messages to the player. If I need to 
say "You killed the monster!", is there a general way to write this, or 
do I need to specifically refer to GUI widgets and methods, etc. in 
order for it to be displayed properly?

Basically, the question is this: can you write the logic behind a 
program (whether it be a game, an email client, a text editor, etc.) 
without having any idea of how you will implement the GUI?

Thanks!



More information about the Python-list mailing list