Modern javascript design approaches to manage complexity? [closed]
I have a web app with a javascript code base that's growing enough in size to where I've had to start re-evaluating how to best design this to manage the complexity. This has led me to a few questions on JavaScript design patterns:
- Are HTML5 data- or otherwise custom attributes a good idea? Might they create a problem by coupling controller/viewmodel logic to the presentation layer? Does this create potential conflicts with a test-driven development methodology?
- Do data- attributes serve the same purpose as expando properties?
From experience, anecdotal evidence, or otherwise - how useful has the MVVM pattern proven to be in practice? Do you see any limitations with it? One I have found is that there isn't always a straightforward data binding from a javascript object to a UI control. For example, binding a collection to a jQuery plugin/widget. As with WPF/Silverlight, if the control author didn't design the control to support the MVVM pattern, then you may be forced to create workarounds.
How much of a problem is it to do polling in javascript (e.g. window.setInterval)? How bad is the performance penalty if I want to poll 10, 100, or 10,000 javascript objects (no network requests) in typical app. or how would you measure this? Sometimes I've found it useful to poll some condition to trigger a change in the UI, like CanExecute.
精彩评论