Friday, October 3, 2014

Just an idea

So I have been watching some JSConf and I listened to a talk about adding tooling to your JavaScript. The tooling used "console.group" which I was unfamiliar with. But I was thinking about Proxies and Aspect Oriented JavaScript. I was also thinking about how I hated reading code with tons of debug log statements. I also thought about a piece of code I wrote recently that searches through a namespace to find all the objects the fit a certain criteria and run an operation on those objects.

Here is the idea. What if you had a JavaScript program that went through your system and replaced every function with a Proxy. The Proxy would be something simple. It would record the function name and all the functions on entry to the function. It would then record when you left that function. You could simply insert this code during debug runs and get verbose output about exactly what was happening. Of course, you would probably want to target specific things. You could do this via targeting a namespace. By namespace I really mean a global object that you put your code under. You wouldn't need to add a whole bunch of lines. Instead you would have an additional script include and a few lines about what namespaces you were going to search over.

I will probably start working on this when I have some more spare time and mental energy. Just wanted to note it down so I don't forget.

No comments:

Post a Comment