Thursday, August 5, 2010

Deleting Code is My Favorite Thing in the World (well maybe my second favorite)

‹prev | My Chain | next›

Tonight, I delete. Oh, do I ever delete.

I remove references to the my precious, homegrown fab.js apps that I lovingly BDD'd with vows.js:



Ah, I was so proud of that code... I delete it without remorse.

I remove resource that the client in my (fab) game used to communicate player movements and to establish communication channels:



I was so proud of that fab.js code that I gave a presentation on it to the Baltimore/DC Javascript User's Group last night. I delete it with a smile on my face.

I remove backend code that will broadcast generic messages to attached clients:



I remove backend code that broadcasts specific messages:



I remove (fab) apps that broadcast the arrival of new players:



...and store players in the local store:



I remove code that broadcasts messages from functions that are still needed:



I remove code that attempts to keep alive comet connections:



All in all, I remove more than 100 lines of code in my main (fab) app, 3 library (fab) apps, and 3 test suites. The cost for that removal? I have to add 20 lines or so of front-end subscription to faye channels:



Best of all, it all still works:

video

What does this tell me? Faye is a huge win. Huge. Anything that allows me to delete code without loss in functionality is big in my book. That I got rid of so much in a single night, makes me nearly ecstatic.

Not all is a panacea, though. I notice in the video that collision broadcasts take a little bit longer to get sent. That could end up being a big deal with lots of players in the room. I would be willing to add some compensatory code though, if it allows me to stay at my current level of simplicity. I will look into that another day. First up, I need to look into player idle timeouts. I have lost that capability, but it ought to be fairly simple to get back.

Tomorrow.

Day #186

No comments:

Post a Comment