[Chicago] pedantic guessing game demo
verisimilidude at gmail.com
Mon Mar 7 23:16:00 CET 2011
On Mon, Mar 7, 2011 at 2:23 PM, Tim Ottinger <tottinge at gmail.com> wrote:
> For children, I think this is a good start. Without introducing
> looping, and barely introducing subroutines, it's not bad for kids.
> I took a copy and started by running autonose in the directory and
> writing unit tests. That drove me to make a lot
> of changes. I ended up breaking out a game object, introducing member
> functions, isolating the input and output from the core game, etc.
This mirrors my thoughts when I looked at the code. It is all written
in one large function, with no distinction between user interaction,
processing or data manipulation. There are no tests, and no easy way
to inject testing.
I started to think about a data object that would initialize itself
and compare itself against a guess. I considered proposing a user
interface object that would read its strings externally so it could
easily be moved to different languages. And a process controller that
would isolate the looping constructs could be added.
But then again it's a one page function that has no plans to grow.
All the above is premature optimization and should be done as part of
refactoring processes as the code is prepped for the addition of the
Actually, If I was trying to get my kids interested, I would modify
this into a web app where they could see the HTML and start to
understand how the web is technology not magic. Being able to put in a
background image and change the look of the page is fun. And when you
show them that if they view the page source they can find the 'secret'
number in the text of a hidden field they feel a thrill like they are
cracking a secret of the universe.
More information about the Chicago