[Tutor] The Game of Life

Kent Johnson kent37 at tds.net
Thu Jan 6 12:06:50 CET 2005


Danny Yoo wrote:
> There seems to be a fashionable push to introduce patterns early on in
> computer science education, perhaps because they are easy to put in as
> test questions.
> 
> But despite this, I do think that there are some patterns that are worth
> seeing, even if they are in unrealistic toy situations.  I got a kick out
> of seeing how 'Command' was applied in the Life example, because it shows
> that we can store active actions as data.

I agree that it is helpful to understand design patterns. It's also helpful to understand that 
applying design patterns doesn't always yield the simplest solution to a problem :-)

>>Why not just build a new world with the values of the next generation in
>>it, and return that from apply_next_generation?
> 
> 
> That also works, but it doesn't fit the function's description.  The
> example that I adapted originally wanted a function that mutated the
> previous generation, so that's what I stuck with.

OK. I didn't have the spec available. But you can still do it with just one copy, then generate the 
world back into the original world.

For a class problem you might have a firm requirement of a mutating method but in the real world you 
can often adjust your design to accomodate a more efficient algorithm.

> If the Life example sucked, don't blame me too badly: I'm just the
> translator.  *grin*

<soapbox>
I hope this is not representative of CS education today.

My subjective impression is that a lot of Java software suffers from overengineering of this sort. 
The Python world is refreshingly free of this. I think a lot of the difference may be due to the 
better tools available in Python, especially first-class functions. But there may also be a cultural 
bias toward heavier solutions in the Java world.
</soapbox>

Kent

> 
> 
> Talk to you later!
> 
> 


More information about the Tutor mailing list