Archive for June, 2007

Don’t debug like Google!

Friday, June 8th, 2007

Everybody loves Google because they do a great job at everything, but there are two things I noticed on YouTube.com that my fellow flash developers should avoid in their Flash applications.

While watching a video I noticed debug statements appearing in my FlashTracer window. Although it is pretty common to see similar debug statements on websites that have flash content, it should not be common and it is very easy to remove these statements for production content.

99% of these statements were typical, but there were a couple that, although funny, could be embarrassing. Look at the two lines of text I highlighted in the left column of this screenshot:

YouTube.com screen capture

Although it is hilarious to see these statements in code from a reputable company, there are a couple reasons why they should not be there.

I avoid writing this kind of stuff in my code because most developers know another developer who has been burned by writing these type of statements and they never learn. Google can get away with this because nobody is really going to be offended and they’re their own client. But, when I’m working for a client I follow these two rules:

  1. Never put anything in your code that you don’t want your client or boss to see.
  2. When you do comment your code, be professional enough to omit them when you compile for production!

When you compile/publish in Flash, remember to select “Omit Trace Actions” in the publish settings to prevent your trace statements from appearing in the compiled swf. Sometimes, I might leave in a few traces so I know the version of the app that the client uploaded or other info that might be helpful for debugging problems.

Here are some other funny examples of code I have seen in other applications that should be omitted for production…

  • The connection just got tea bagged – reset and reload
  • Fuck bandwidth detection script its taking too long or not working so fuck it hard
  • This feature does not work and crashes the player fix laterz
  • HACK HACK HACK HACK HACK this scuks

The best part about the google debug statements, is that you can see them for yourself by installing the FlashTracer add-on for Firefox and the Debug Flash Player, then browse over to YouTube.com and watch a video. And, although I named this post after Google, you could also look at another example of what not to do in this article. It’s about a bunch of unprofessional comments from some Microsoft Win2K source code.

UPDATE: Google promptly removed these statements after about 130 hits to this page from google.com (not referrers, but actual native traffic from the company domain).