I have been fiddling around with the idea of skipping the server side UI model completely for buildling web apps for a year. With the advance and acceptance of client-side toolkits such as Dojo, Prototype + script.aculo.us, Yahoo Widgets, extJS, jQuery etc, client-side rich widgets are becoming increasingly popular and growing in number.
The original MVC pattern created by the Small Talk community was made for GUI clients, and was re-vamped – in a not so good way if you dare – as MVC Model 2 for web apps. The problem with MVC Model 2 is that it’s not MVC at all! Ok so MVC is about having your view render your model and update itself as the model changes, and have its interactions handled by the controller. In this sense I do have to agreee that MVC Model 2 adopts this concepts.
What people don’t get is that models are NOT about your application data. A model isn’t database data, although it may contain some of it. A model is simply holding the data the view needs to display. Take Swing as an example. Every single widget has a related model which holds the data it’s supposed to present.
Also controllers are NOT about your business logic. They are supposed to be the bridge between the user’s actions, and the execution of business logic, but not orchestrating multiple uncoordinated pieces of business logic spread around various classes. If your business logic is spread out like that, create Façades for it, don’t try to push it all into the UI controller. Did you notice I said UI? Well that’s what MVC is meant for, not application-wide architecture.
So you’d say “ok, but if MVC is for the UI, what should I do with my business logic?” The answer, my friend, ain’t blowin’ in the wind, it’s SOA. Your company may have already invested, or chances are it’s looking into investing on a Service Oriented Architecture. Now if you already have services available, why not use them from inside your RIAs?
Why not go full-on client-side on your UI and use your services for business logic? This way you skip all the risks of building a business logic heavy UI controller, and also enable reuse throughout applications of that very same logic using services.
Anyhow, I made you read all this babble because I finally did find someone who shares my vision. The CTO from AppCelerator, Nolan Wright will be publishing this article on the SOA World magazine next month. Read it and leave your comments.