Enterprise RIA Javascript MVC Thoughts?

I like Knockout’s binding functionality, it should appeal to both Flex and Silverlight software engineers who decide to move into Javascript land. I haven’t used Underscore yet, but I’m sure I will. Which brings me to ExtJS and building large RIA Javascript applications.

The ExtJS tutorials talk about Big Applications, and provide some direction. Pragmatic Guide to JavaScript suggests Dojo as the first choice for RIA’s. What I am so far missing is the best way to put together a large application using Javascript frameworks.

Flex and Silverlight both have MVC/MVVM pretty much pegged, which leads me back to Ed’s posting on Customer containers with ExtJS. The problem I have with the samples in Ed’s posting is that the view is in Javascript. Yet in Flex/Silverlight the view is in a markup language – MXML/XAML.

It appears to me that most Javascript MVC samples appear to avoid the big RIA question, steering towards leveraging appropriate server side technology, whereas what I want is a Javascript RIA connected to a streaming server – obviously :)

Today, I could possible do something like this at the application view level i.e. appropriate breaking the application into smaller parts:

    var viewport = new Ext.Container({
		renderTo: 'viewport',
		layout: 'absolute',
		width: '100%',
		height: '100%',
		autoScroll: true,
        items:[{
			itemId: 'stage',
            xtype: 'container',
			layout: 'absolute',
			x: 5,
			y: 10,
			width: 1010,
			height: 764,
			items: [{
				itemId: 'viewBar',
				xtype: 'viewBar',
				x: 125,
				y: 5,
				width: 890,
				height: 35
			},{
...

Coupled with sub-views such as:

...view.viewBar = Ext.extend(Ext.Container, {
    layout: 'absolute',
	cls: 'viewBar',

	instrument: '',
	priceType: '',
	price: 0,


    initComponent: function() {

		this.boxTitle = new Ext.form.Label({
			itemId: 'boxTitle',
			cls: 'bigPriceBoxTitle',
			text: this.boxTitle,
			x: 4,
			y: 3,
			width: 174,
			height: 12,
		});

		this.bigFigure = new Ext.form.Label({
			itemId: 'bigFigure',
			cls: 'bigPriceBoxBigFigure',
			x: 9,
			y: 8,
			width: 165,
			height: 16,
		});
...

Which just doesn’t feel right given what I said above. Which leads to the question, what patterns are other people following in the RIA enterprise Javascript space?

Advertisement

~ by mdavey on November 25, 2010.

5 Responses to “Enterprise RIA Javascript MVC Thoughts?”

  1. Some recommendations

    Pro JavaScript Techniques (John Resig)
    Pro JavaScript Design Patterns (Ross Harmes)
    JavaScript: The Good Parts (Doug Crockford)

    Secrets of the JavaScript Ninja by John Resig looks like a good book when it’s finished as well.

    + lots of great video material at http://developer.yahoo.com/yui/theater/

  2. When I moved from Java-land to JS-land I kept wanting to stick to the same demarcations of MVVM, strict immutability, strong typing…
    Its only when you let go of these things that the power of JS RIA architecture comes through.
    I started out with the view in markup and css. Fine, but creating the view in JS and CSS is actually faster than running a parser over markup that contains widgets.
    A model in JS is fine too, but it starts out being strict (see backbone.js) but this always felt like it was missing the point of JS’s dynamic typing – so the model became a validator and decorator of carefully JSON-serialised structures.
    Controller is where you can go to town and have pluggable transport layers – just keep everything pub/sub within the browser (small widgets publish events that are captured by container widgets that are raised up to app widgets).

    I’ll look again at backbone, but it seems like it would ask you to add alot of code to circumvent the benefits of dynamic typing.
    FWIW I use Dojo throughout and its data store widget binding is very good, as too is its event model and promise-based ajax req/response architecture.

  3. Vendors like MS and Adobe do a great job in guiding developers towards widgets, patterns, libraries, frameworks and associated WYSIWYG tools – the complete package. Compared to these, JavaScript application development can feel like a “do it yourself” solution.

    ExtJS is pretty close to being a one-stop-shop for building web applications but, like any vendor solution, it has its strengths and weaknesses. The widgets look fantastic, but I wish ExtJS made more use of templates, like XAML. JavaScript makes it easy to use a mixture of ExtJS and bespoke widgets in your MVC framework – the important thing is to concentrate on developing and testing each widget in isolation.

    My preference is to compose applications from MVC triads (Passive View), but MVVM/Presentation Model is also a viable alternative. All MVC-derivative patterns require some sort of observable pattern, therefore choosing the right middleware (e.g. pub/sub) to give the required degree of component isolation is a key consideration.

    • Hi Andrew,

      Thanks for the comment. Have you tried the jQuery templates?

  4. I haven’t used jQuery templates, but I like the way that they leverage HTML. At Caplin, we also use HTML templates/data binding, with extensions for JavaScript controller logic – not dissimilar in principle from XAML. You can read about our approach here: http://blog.caplin.com/2010/12/01/html5-toolkits-for-complex-web-applications/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 273 other followers