3 ms·
I have to say, the more javascript (these days coffeescript) I write, the more I think an mvc structure on the client is usually a big mistake. Mvc means shared
by danenania 14y ago
I have to say, the more javascript (these days coffeescript) I write, the more I think an mvc structure on the client is usually a big mistake. Mvc means shared global state and putting your data behind an inflexible facade, neither of which is necessary or a good idea in ui programming.
What's the alternative? Components. Encapsulation. Modularity. It's nothing fancy. Just build small, composable functions and objects that manage their own data and subcomponents, and don't reach outside themselves. In this way you end up building up lots of mini mvcs, one on top of the other, to manage requirements with the approach and data structures most appropriate to each, rather than constantly trying to bend a monolithic global model and api into doing exactly what's needed.
You don't need a complex hierarchy of model classes for your data. Just use json. When you need to process or manipulate it, write a function. When you need to send or receive data from the server, $.ajax and handle the result on whichever tier needs it. Send and receive just the data you need in just the structure you need. No syncing or rails-like magic required.
- anton-107 14y agoWell, after all when you get your modular components you still need some piece of code to make them work together. It's not like you throw them into your project and they magically become an application.
- deleted 14y ago[deleted]
- est 14y ago> Components. Encapsulation. Modularity. Is it like drag & drop web controls to generate html & javascript?
- rsanchez1 14y agoI say Enyo JS fits this description pretty well. http://www.enyojs.com http://www.enyojs.com