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

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



On Saturday 16 June 2007 01:18:49 pm Marius Gedminas wrote:
> On Sat, Jun 16, 2007 at 09:32:09AM -0700, Casey Duncan wrote:
> > On Jun 16, 2007, at 8:56 AM, Laura Creighton wrote:
> > [..]
> >
> > >If you use Model-View-Controller like separation of your code,
> > >None.  All your changes will be in the drawing.
> >
> > I'm curious how many of you actually employ MVC using pygame, since
> > the library encourages mixing the model and view via sprites. I'd be
> > interested to see a "canonical" example of a pygame that uses MVC.
>
> 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/
>
> 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?

> > MVC has strong advantages when you need to present and interact with
> > the same data in multiple ways, but often in simple games data is
> > only presented a single way. Using MVC has advantages for unit
> > testing as well, but how many pygames actually employ unit tests in a
> > meaningful way?
>
> For some low-level functions (e.g. vector math) unit tests were rather
> useful.  Also, I couldn't have refactored the AI code that Ignas
> Mikalajūnas wrote for me without writing a set of unit tests for it.
> Other than that, my initial resolution to have everything covered by
> unit tests evaporated pretty rapidly when I got caught in the frenzy of
> prototyping the fun stuff.

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.

> > I'm curious how widespread these practices really are in the pygame
> > community, not to make a point for or against them, but to better
> > understand theory vs. practice.

I'm curious about everything.