I'm working on a feature-rich single page app with lots of Ajax. We've partially implemented MVVM with Knockout, but I want to clean things up and draw clear lines as to what belongs where. Searching the web has left me with lots of vague answers and conflicting opinions. To that end, I have two questions:
First, what exactly belongs in the Model? In almost all the Knockout example apps I've seen, the ViewModel holds data in observables and the Model is often completely missing. If the model doesn't hold data, then what is it for?
Second, where does business logic (such as our client performs) that doesn't touch UI belong in the MVVM pattern? It seems like it doesn't has a home.
With the amount of work our application does with data, it feels like the Models should hold the weight and the ViewModels should stick to a lightweight translation role. I'm struggling with the fact that our ViewModels are massive while our Models are tiny. Currently our Models consist of data validation, Ajax calls, and virtually nothing else.
From what I've seen two things are allowed in the Model: raw data, and validation. Is it reasonable for me to want to place observables and functions that manipulate them in the Model, or does that totally violate the pattern? And while I'm at it: the View is generally accepted to be markup and data-bindings. Can functions be part of the View? I'd like to place pure UI operations there. Essentially I'm finding the View=Markup, ViewModel=Code, Model=Data paradigm to be too restrictive in my current project. I'd rather base the separation on assocation/role than asset type.
The ViewModel's responsibility would shift from the current "pretty much everything" to screen flow and data translation.
Any thoughts are appreciated. Thanks!