[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] I have a quick question... again...



On Sat, Jun 16, 2007 at 01:27:37PM -0400, Charles Joseph Christie II wrote:
> > I don't know about canonical, but PySpaceWar uses pure MVC.  I think; I
> > never fully understood the "controller" part of it; my views are often
> > also controllers.
> >
> > http://mg.pov.lt/pyspacewar/http://mg.pov.lt/pyspacewar/

Gaah, obviously it should have been just http://mg.pov.lt/pyspacewar/
Copying and pasting URLs from Firefox to GNOME Terminal sometimes has
this strange delay that makes me thing I didn't press the middle mouse
button, so I do it again.

> > There were two reasons for making the model independent of views:
> >
> >   * I wanted beautiful and understandable code
> >   * I want to add network play at some undetermined point in the future
> 
> I'll take a look at that. But when you say making the model independant of 
> views, what exactly do you mean?

Model objects have no references to view objects.

You can take the Python modules that implement the game model of
PySpaceWar (world.py, game.py, ai.py) and build a different user
interface without changing those modules.  Or build a network server
that doesn't have any drawing code.  In theory.  I haven't attempted
either, so it's possible that some flaw in the design may require
modifications to the model classes to support alternative views.

> What's unit testing? I wouldn't be surprised if I knew what it was, but didn't 
> know what it was called. I also wouldn't be surprised if I never had the 
> slightest idea what it was, either.

It's the programming equivalent of putting your answers into the
original math equation to make sure you haven't made any silly mistakes
while solving the problem.

Dive Into Python has two chapters devoted to unit testing (and
test-first programming, which is a somewhat separate thing):
http://www.diveintopython.org/unit_testing/index.html
http://www.diveintopython.org/unit_testing/stage_1.html

Marius Gedminas
-- 
1 + 1 = 3
                -- from a Microsoft advertisement

Attachment: signature.asc
Description: Digital signature