Wed 1 Nov 2006
Annotated code viewer (aka View Source on steroids)
Posted by nj under Flex | development19 Comments
I’m back from MAX, and it was a great time. I’m amazed by how much traction Flex seems to have gotten—granted, the MAX attendees are people who already love Adobe/Macromedia, but it was still great to meet so many people who were enthusiastic about Flex. It was also very cool to see the first public demos of Apollo—I think they really helped people understand why we’re excited about it.
(Oh yeah, and I won a lot of money at no-limit hold ‘em. One of my adversaries turned out to be an analyst; after I put him all-in and won a big hand, he told me he was so totally going to write bad stuff about Adobe in retribution. I’m pretty sure he was joking.)
But now to business.
Here’s something I hacked up during MAX. (If any of my coworkers are reading this: No, I didn’t work on it during your talk. Okay, maybe I did, just a little.)
Click: Anatomy of a simple Flex app. (I recommend maximizing the browser window.)
The sample app in it is one you’ve probably seen before—a simple Flickr browser. The more interesting part is the annotated source view, which you can get to by clicking “FlickrBrowser.mxml” at the top. You can click on annotations, click on links within the annotations, or step through the walkthrough using the arrows on the right.
So, what’s this about?
While looking through some sample Flex apps, it occurred to me that it would be good to have a nicer way to document sample code. Having a bunch of comments in the code explaining conceptual stuff disrupts the readability of the code, while having a completely separate article walking through the app makes it so you have to keep bopping back and forth between the code and the article. So I hacked up this annotated code viewer.
This particular sample is obviously pretty simple if you already know Flex, but I thought it might be a good intro for people who are new to the platform, and you could imagine applying it to more complicated samples like FlexStore. If you know anyone who’s curious about Flex, feel free to forward this to them and see if it helps them understand what it’s about.
The code for the annotated viewer is hacky/ugly and not generalized yet, but I thought I’d put this out there to see if anyone would be interested in seeing more code samples annotated like this (or using it for their own code). If so, please let me know, and I’ll spend more time making a nice reusable version. And, of course, thoughts on how to improve it (either the viewer itself or the content/annotations within it) are welcome.
(By the way, there’s a known bug that if you scroll the code viewer, the annotations don’t scroll with it. I haven’t found a good workaround for this problem yet.)
Let me know what you think. Thanks!
(Update: I obscured my Flickr API key in the app and the source—thanks to my coworker Jono for pointing this out. You can get your own at http://www.flickr.com/services/api/keys/.)
digg this |
del.icio.us | 19 Comments
Awesome!
Awesome NJ, I will for sure try to show this during customer visits to quickly guide them through some code!
Cool idea. It’s ideas like this that will help people understand the power of the flex platform. Source code is nice, but for a newbie these comment fields are a goldmine. In fact, your idea is so great that it should be implemented in FB2 imo.
Very nice!
This is a very interesting idea – I shall look forward to trawling through the source code using your annotated version.
… and thanks for sharing.
Narciso, muy cool, excelente trabajo, gracias por compartirlo. !!!!
Great !!! very cool, thanks
I would like to use. Very nice.
Awesome! I am an instructor and this kid of thing is invaluable. I am new (just leasrning ) Flex but how did you do it if you could share …man…big stuff for the ed field
Thanks for the nice comments! The source code for it isn’t in very good shape, but if you run the app, right-click on it and select “View Source”, you can see how it currently works. My next step would be to clean up how the annotations are stored, and probably add some way to author the annotations in the app itself, rather than typing a bunch of XML and character offsets by hand
Did you have to do all the annotations by hand? It would be cool to have a tool to put that all together for you… you are probably already thinking of that though.
Nice work!
Excellent, an intuitive code exploration learning tool!
We’ve done something simmilar at cairgormdocs.org, the diagram explorer (http://www.cairngormdocs.org/tools/CairngormDiagramExplorer.swf) .. you can see that this would be a valuable addition to this learning tool, not to mention as a stand-alone cairngorm example app.
Well done! We would love to use this tool and/or help with the development of it.
Great Work!!
I would like to use it.
Great idea! I’m involved with CairngormDocs.org and this looks like this would be helpful for our project.
BTW, are you aware that the text on your blog is *really* dark? I have to select it with my mouse in order to read it! Perhaps you’re on a Mac which, if I recall correcly, displays everything much lighter?
Correction. It’s not that the text is dark. It’s that the background is black. I wonder if others are seeing what I’m seeing…
NJ, looks like a very nice we to be able to comment code for demonstration and example purposes. Looking forward to the finalized version.
Evan–very cool! I could definitely imagine incorporating a flow diagram similar to yours to make the “walkthrough” part of my app clearer. I might try that for the next version.
Doug–the background should be light, not dark; maybe your browser isn’t loading the background image for some reason. The server this is on can be sluggish at times (my email account gets a lot of spam), so you might be timing out. Let me know if you continue to have the problem.
NJ, thanks for sharing the CS3 tips and tricks at FlexCamp. I wanted to catch up with you that night but caught up with some other Flex chums of yours. They said to contact you about more CS3 stuff for designers.
I am especially interested in making real-time or rapid prototyping using Flex with minimal backend dev work so apps can be approved in Flex by client and then bid on by developers.
Let me know if you know if this can be done – even partially – I want to help drive this initiative that got some discussions in the “champagne room” that night.
Thanks again, good stuff on the Fireworks/Flex stuff. I may have to dust off my copy
Stumbled across this article, a little belated.
The annotated code viewer is a brilliant idea. I wish it had taken off. This would have been an amazing tool for understanding bits of code.
Claude–good news: our documentation team is actually building a real version of the Code Anatomy app. See my latest post.
[...] In the meantime, one bit of news–the Code Anatomy prototype I published in my last post is turning into a real feature! Our Learning Resources team is getting a real Flex developer to rebuild it from the ground up as a skinned, fully-reusable Flex app, and will be shipping several code samples that use it with Flex 3. Best of all, we’re planning to release the source code, so other folks can post anatomies of their own apps. [...]