A journal that focuses on Flash Platform development, and a little bit about what I am up to on any given day.

Monday, June 20, 2005

Another Debug/Trace Class

This topic has been discussed many times in the Blog world, but I just wanted to contribute my new approach to debugging complex Flash Applications.

After working on the SNL Merger Model application for 8 months, I realized I needed a more robust method for tracing and debugging. The application was huge, and it was all developed in Flash not Flex. Compile times could often surpass 2 minutes, and that made it really frustrating when debugging small glitches.

More than that, if you are a fan of using trace statements, many of you know that as an application grows, it can become unweildly to manage them unless you keep them in context with the process that creates them.

So at the end of the day, I wanted to force myself to behave as a developer, and do the right thing. I designed a simple little class that we use frequently to debug our work at Teknision.

Suprisingly I called it:

com.teknision.debug.TraceManager;

but in it's simplicity it is very useful. The point of it was just to get our whole team thinking on the same wavelength so that when we hand work to each other, we can easily pick up on certain parts without having to study the whole project.

Here is how we use it in Actionscript:

trace(TraceManager.get().getThread("Application").getThread("init").getThread("loadConfig").trace("config file loaded"));

the output from this in the trace window is the following:


201:Application.init.loadConfig{ config file loaded}


The first part is the timer count in which the line executed, and the rest is a path that puts the trace statement in context to your work. Note that using this alot in an application will add processor overhead, but in most ways it is really worth it.

Note that the whole statement is held within the trace() function. This may be a technique used by many, but it is a way to make sure that you can easily eliminate this logic when you deploy production work. The fact that it is all executed in the trace() statement eliminates it on compile if "Omit Trace Actions" is turned on.

As we started using this, I have found that our team has begun to think more alike, and work is easier than ever to pass around. We even built a desktop app to recieve the traces remotely and allow threads to be filtered. This makes focusing on certain pieces of a system very easy.

[update]: thanks Stace

Truly one of the best things about it, is that it exposes application bootstrapping. At a glance I can see the log of everything my application is doing as it runs. Debugging using it is great, but also, another developer can really get on board much faster when observing this output.

2 Comments:

Anonymous bwc said...

The trace class is so much more than just seeing what the hell your flash movie is doing in the browser. I mean, you can do that without the trace class by using the debug player.

It comes down to structure and organization. I can now look in the Trace app and see the structure and bootstrapping of my application. Anyone can view it and understand what is being called, when it is complete, what happens after that event, what event is called, etc. Not only can I dissect my entire project, but I have explained it to another person in its entirety- if of course, you truly buy into the process. Hopefully the new version of Flash will have the ability to tap into the intrinsic class and overwrite it- or tie into debugging in a more robust way that other development environments support.

8:00 PM

 
Anonymous Anonymous said...

runescape money runescape gold runescape money runescape gold wow power leveling wow powerleveling Warcraft Power Leveling Warcraft PowerLeveling buy runescape gold buy runescape money runescape items runescape gold runescape money runescape accounts runescape gp dofus kamas buy dofus kamas Guild Wars Gold buy Guild Wars Gold lotro gold buy lotro gold lotro gold buy lotro gold lotro gold buy lotro gold runescape money runescape power leveling runescape money runescape gold dofus kamas cheap runescape money cheap runescape gold Hellgate Palladium Hellgate London Palladium Hellgate money Tabula Rasa gold tabula rasa money lotro gold buy lotro gold Tabula Rasa Credit Tabula Rasa Credits Hellgate gold Hellgate London gold dofus kamas buy dofus kamas 血管瘤 肝血管瘤 音乐剧 北京富码电视 富码电视 富码电视台 7天酒店 7天连锁酒店 7天连锁 自清洗过滤器 过滤器 压力开关 压力传感器 流量开关 流量计 液位计 液位开关 温湿度记录仪 风速仪 可燃气体检测仪 wow power leveling wow powerleveling Warcraft PowerLeveling Warcraft Power Leveling World of Warcraft PowerLeveling World of Warcraft Power Leveling runescape power leveling runescape powerleveling

10:44 PM

 

Post a Comment

<< Home