Dojo javascript framework is probably the most missunderstood javascript framework ever, and there is good reason. Dojo has been around kicking around the dom way before[1] x and y js framework started off as a hack/scratch/itch in a dev's intelectual loins
I find myself yapping about Dojo to every other developer, startup guy, and in any other javascript/html5 related conversation. In order to save breath Im writing out a blog. In answer to questions like implementing object oriented paradigms/patterns in js, ajax rpc, themeing js wdgets, modular architecture, dependancy loading etc. My answer/recommendation is DOJO.
Comming from an object oriented programming background it was easy to see lthe logic behind dojo, for me JQuery was and is an over hyped hack. If you are serious about making a well designed maintainable, scalable, consistent, localized, accessible, dynamic web application dojo is what you should be using. I mean you could (theorecticaly) build an application using shell scripting, but that'd be stupid, get the idea.
Dojo Mojo Blockers
Firstly I'm going to shoot some of the common dojo mojo blockers.
-
Dojo is too big, its too slow. Yes Dojo is big its big in features. Slow: well I have to admit it was slower before 1.6 but now with dojos new dependancy loading in 1.8 dojo is faster or fast as most of the js frameworks out there, comparing feature by feature. With the new architecture you can load just the bits that you'll need to use without pulling in the whole kitchen sink. Yes, it gives you dependency loading for free, no 3rd party hack to fix that js gripe.
-
Dojo is complex: Yes its more complex than most commonly used js frameworks. Comming back to my shell script analogy, so if you are making the equivalent of a shell script dont use Dojo. 'But I can do this in one line using ****' yeah , and I can balance my accounts using cat, sed, awk and bc in one line too.
-
Dojo is not popular not many use it. Dojo is not as popular as x and y, but popularity is not a relavent criteria for kickass, if software development was a democracy (LOL), if science was populist driven .... That said there is the real world issue of not getting good developers, but if you are paying to get good developers why would you want to make them use a hacky scratchy framework. Un-true Dojo is used by many large organizations.
-
Dojo is not well documented. Probably related to the previous point but IMHO dojo has pretty good set of quality examples. Documentation is more terse compared to the slew of material availiable in jQuery etc. I neve had a problem finding good material on dojo. But that said one potential hicup that i have encountered is the many version of Dojo documentation hanging around in the forums. So if you are planning to do some hacky scratchy copy paste chutney coding, make sure us are getting the code for the freshest[2] version of dojo.
What's the Mojo in Dojo ?
So what makes dojo so awesome ? First thing for me is the consistency. There are many aspects, but these were the highlights for me.
-
Design Consistency: dojo follows an object oriented design and every component is designed on that principle, so if you are comming from C#, or Java or C++ or any other respectable high-level programming language you'll be right at home. On the other hand if you are comming from a scripting background you might be cribbing about all the apparent complexity.
-
Api consistency: the api interfaces are consistent and predictable, so theres this awesome new feature introduced, you pull up the doco and no surprises, yay.
-
Familiar design patterns: once you've worked with dojo for a while and you start 'getting it' you'll notice familiar patterns repeating , a lot of GOF (Gang Of Four) patterns are involved. Dojo's api interfaces are pure joy, will get to that soon.
-
UI Consistency: The most obvious is the consistency in the usage of themes and widget styling. Dojo's widget system in addition to having all the above consistency factors are thematically consistent also. So you app with the very least designing from your part won't end up looking like Dr Frankenstiens's creation. And the consistent css selector naming makes rolling your own theme a joy.
-
'A11y oop'*[basketball pun]: if you don't know what A11y is [heres] http://pragprog.com/book/jsaccess/design-accessible-web-sites a good reference. Dojo gives you A11y for free so your apps are instantly accessible to a larger user base.
Dojo Store API [3][4]:
This IMHO, is one of the most useful api provided by Dojo. It provides an uniform access interface to any kind of data. It has saved me a lot of trouble working with complex ajax ping-pong, transactions and tracking state etc. How it works briefly is you build you data access on these api on the client side js, most of the dojo widgets readly support the store api. For example you plan to do json rpc style ajax so what you wuld do in general is make a bunch of calls to send/receive data and and check state, update ui controls widgets forms etc based on the response. This gets really messy really fast before you know it you have a bunch of ajax handlers bunch of state variables, handling cases etc, which makes it a maintenance nightmare with a lot of network sniffing and debugging. Dojo simiplifies this by taking care of the whole transport, so you just drop in a JsonRestStore (provided you implement the store api) and read and write to the datastore asif it were a local clienside object, on the server end just setup the relavent handlers for the requests issued by the datastore. So now you have that in place you can manage all your io through the datastore elegantly and it gives you event handling also. Using dynamic forms? no problem just link up the dojo widgets to the data store and they will automagically update on changes in the datastore. I have used the data grid widget with the store api and it saved me a hell lot of trouble with data access and synchronizaton.
Dijit Widgets:
Dijit wdgets are awesome, they provide a consistent, cross browser, stable user interface out of the box. It builds on the plain html controls adding themeing validation, api integration. Its extremely easy to extend, customize and theme. There are some powerful widgets in the toolkit and they all use the same consistent apis.
Dojo AMDs:
AMDs are dojo's answer to require.js and the likes. Asynchronous Module Definition alows for asynchronous loading of component modules and dependancy management. Since 1.7 Dojo has been extremely modularized and you can easily pick an chose precicely what you need to load without pulling in the kitchensink. This is done asynchronously so other parts of the page can load while dojo modules are loaded.
In Conclusion
This blog does not do justice to the awesomeness of the Dojo Toolkit. Im an currently not working on a Dojo project but I see a whole bunch of hacks cobbled together in most frameworks, I reminisce working on dojo, not that it was particularly easy but it was elegant. Order where chaos usually ensues, layers, intelligent design.
Post a comment
Comments