Sunday, September 24, 2006

Refactoring Pong

I just finished refactoring what I wrote for the 2006 STIC contest. In a way, the solution for Pong had two parts. One was the framework on which I relied to write the players, and another one was the actual application of the framework to Pong.

As it turns out, I could separate about 20kb of source code and generalize the framework I found. Now it has a name --- the perception pattern.

Something that I found interesting was that as I was pushing up methods into more abstract classes, Pong classes became quite empty. In particular, the class that models the pong player ended up with 3 private methods that answer instances of Pong eyes, hands and interfaces, as opposed to the more general answers the messages in the superclass provide.

I think the perception pattern is a powerful tool that can help being touchingly expressive. I used it at the office to implement an autonomous agent that mimicks people's actions. It is seriously good stuff. It is so easy to change and improve. It is beautiful.

Now that I have a refactored perception pattern implementation, it will be easier to create other things.

No comments: