Photo of Jamie & Lion

The personal site of Jamie Knight, an autistic web developer, speaker and mountain biker who is never seen far from his plush sidekick Lion. View the Archive

Topics: Autism Development

Concepts and DOM bashing.

Recently I have come to realise there are two fundemental ways to build Javascript applications. DOM Bashing and concepting.

DOM bashing is the simplest method to build a JS application. Effectively, you just keep bashing at the DOM to get the page to look how you want. You show stuff, hide stuff, copy stuff, get data over AJAX and you store all the state in the DOM.

Immagine a simple app which is a list of items. If your DOM bashing you push stuff around the page to get the look you want. You don’t model the data, you just worry about the pixels on the screen. You click add, a box appears, you close it goes away again. Simple.

Concepting is another approach, rather than starting with the DOM, you start by modeling your concepts into objects. So you may have the concept of an item, and an item may include the concept of a tag etc. You write code which manipulates concepts and at some point updates the DOM to reflect the state of your current object graph. The state is in the JS, the DOM is just a view. You may have a render method which draws the current data structure to the users screen.

I’m sure both of these approachs have thier proper names. As i have learnt more about Javascript i have found myself dealing with concepts more often. Especially as applications get bigger and more complex.

Published: 10 April 2013 Permalink

Comment

Your Comment