Dojo – from a flash developers perspective
Juten Tach,
Yesterday, i actually came to work with HTML/CSS/Javascript again after not having worked in that field for a loooong time. A colleague of mine showed us the basics of dojo, one of the more popular ajax frameworks out there at the moment. And since i am working in the RIA field, well i guess i should also be familiar with stuff not coming from Adobe, right? So, i am giving it a try now.
First thing i have to say: It’s not so much about dojo, it’s more about me having so little knowledge about css compared to some of our smart guys here, it is embarassing. And i have the feeling, dojo is only the glue, that puts CSS and plain content driven HTML together. So yesterday, it was actually more about learning what nice things i can do with css and little about dojo.
This made me thinking on how i work with flash today. I have rarely used the flex framework or mxml yet, i also have not worked with css and flash yet. The user interfaces that we build for our websites and campaigns never look like classical applications, so we usually prefer doing plain actionscript projects, because we have more basic control over everything then. And we need total control, because in the end our designers demand it. But that means, that all the layouting is usually done in code. Of course we separate view logic from the rest, but nevertheless it remains code.
Now doing some dhtml stuff, i realize, things are very different here. Layouting is done almost entirely with CSS, which is declarative, no code. These guys try very hard not to have layouting in their code. And within the HTML/CSS/Javascript field, it makes totally sense, because CSS here is ten times more powerfull than it is in flex and mxml yet.
But back to dojo. In the evening then i eventually managed to do some dojo scripting. Translated to the flash world, it means back to AS1. Not a big deal. I installed Aptana for Eclipse – you MUST check it out, it’s awesome, got my firebug updated and were ready to go. So i type “dojo.” , ….. and get a huge list of stuff, of which i do not know, what to use and what not. I can say, we actionscript 2 and 3 developers are blessed with a language, that benefits auto completion and code hinting. It is a mess in javascript. Although i don’t really know, if it is javascript or if it is dojo. For example, if i type “dojo.query(“, i get nothing. Aptana is not even recognizing, that this is a function. OK, i don’t know, if Aptana or Dojo is to blame, i just see, i don’t see anything (hm, i guess, this could be funny in german, but i’m not sure, if this is correct in english). Another example, if i type “dojo.publish(“, Aptana tells me, that this function wants two arguments, the first one called “_105″ and the second “args”. This is not very readable.
Working with tools like FlashDevelop with AS2 and AS3 or eclipse for java or visual studio for C# for some time now, i recognize, i got so much used to autocompletion and it is so powerfull in so many ways, i don’t want to miss it. Aptana has some very smart autocompletion, but i get the feeling, it works best with prototypes.
Having taken a look into dojo, i reckognize, it makes heavy use of closures and functions returning functions and so on, i don’t see any prototypes. Here i must admit, i have little to no experience about what works good or not good in the javascript world, so i cannot comment on that. When i remember the days, when i was working with AS1, i was totally into prototypes, because i actually wanted to emulate classes and prototypes where quite close. Talking to some of our javascript guys, they tell me, they don’t like prototypes at all. But again, i am sure, there are good reasons for doing things differently there, just have to find them out.
So all this sounds a bit negative, but i also want to mention the nice things about dojo. First of all, the before mentioned query function. It takes css selector statements (even css3 ones) and this is VERY powerfull, it works like a charm, very handy. The connect method is also very usefull for registering for all those ui events. And animating works nice with the animateProperty function, although it is hard to remember, how to write things without autocompletion. I have to have the documentation open all the time.
Well, that’s it so far, i’m only at the beginning here. I will give an update when i’m done with my little project.


Sven,
You should take a serious look at Ext (http://extjs.com). It has an absolutely awesome set of UI controls all designed to work together. It truly is an amazing framework and we have a very supportive community.
Rey
Thanks Rey, i will.