Cleaning up code is a lot like cleaning your house 1


The past week, I’ve spent some time cleaning up the nooks and crannies of the house. Informing my grandchildren about the chimney sweeps in Victorian England, I had them crawl under the bed and push out everything that had collected there. The result was this.

room floor covered in books and other crap

Also, Eva, would like it pointed out that she did “Like, all of it” and that her younger sister, “Maybe pushed out one book.”

This is Eva

This is Eva

In between reviewing grants, testing aspects of the game and writing code, I would go up and put away or throw away a few items. It took me 4 days because I had a lot of other stuff to do.

The result was this:

cleaned up floor

Lately, I’ve been doing the same thing with a lot of code. I have little mini-games I wrote years ago and both browser capabilities and my own capabilities have changed a lot since then. I also had one of our game consultants, Ronda, provide some feedback on game improvements. She had several that I am working in bit by bit.

So … what does this code clean up look like? A lot like cleaning up your house.

First, you toss out the stuff that is obviously garbage, like in the last post, where I mentioned fixing things that don’t work any more because browser support has been eliminated.

Second, you organize things, like putting all of the books in the bookshelves. Or, in my case, we had several different versions of jQuery referenced in different places. I’m moving those all to one js folder. People who say I should just reference the Google hosted jQuery, you’re wrong and here is why – I often work in places where there is no or very sporadic internet connection so I try to have everything possible locally hosted.

Third, you get rid of things you don’t need any more. There were images in the folder or scripts linked that at one point did something but we had long since deleted their usage but the files were hanging around.

Fourth, you make stuff look better. This could be making the bed, vacuuming and dusting or it could be adding features like music when they are playing the game, improving the fonts, adding images, making better borders and theme colors in a style sheet. Adding all of that now.

Hopefully, my code will soon be as clean as my bedroom.

 

 


Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

One thought on “Cleaning up code is a lot like cleaning your house

  • Sylvain Galibert

    About the point #2, there is a trick to get the best of both worlds:

    Link to jquery on Google. Second, test if jquery is working using “window.jQuery” (returns true if jquery is active) and use document.write(script tag with local link) to load the local copy of jquery if it failed to load it from Google. This way, if Google’s jquery is already cached by the local browser, it will use it, and download jquery from your site only if it is not already available.

    (I’d post the code, but I don’t think this comment area would display the tags properly.)