By far, the most common class of errors I have are issues with the interface between javascript and server code. This includes having the javascript calling the wrong URL, passing the wrong data (particularly if the needs of what needs to be passed changes, and the javascript doesn’t), and issues in turning data into html the same way that my app does.
Is there an easy way to deal with this? I’m developing currently using Zend Framework in PHP. I think the first couple of issues could be avoided a bit by using Selenium, but I’m not sure how to deal with the data -> html issue. I’d love to have some kind of javascript equivalent to my ZF view helpers, but I’m not sure how possible that is.
On a well designed site, (public) URLs won’t change. You are, of course, free to use whatever internal structure you wish.
If necessary, you should be able to generate JS just like you generate HTML. However, if you apply proper REST principles:
When it comes to making document manipulation proof against future restructuring, use libraries that support a robust element selection language, such as XPath or jQuery’s selectors, rather than walking the DOM structure and use good IDs and class names that won’t change.