Anyway long story short. I don't think the pattern is abused anywhere near as much as the term as been.
We call those, "views".
If you're claiming that regular HTML views are compliant with MVC because they have HTML links, one can argue that some RSS readers convert the reference links from the RSS feed to actual HTML links that you can use to navigate to the individual RSS item. How is that different than a regular HTML view with links?
[1] Although were talking about Model 2 here, so thats irrelevant. Come to think of it, this whole discussion is pointless: we're arguing about whether views in a Model 2 architecture are proper MVC views...
I see no purpose for this distinction. A view is an output representation of the model data.
Given the challenge, "How much of my code survives if I drastically change the view?", I think json and rss make perfect sense. They are drastically different output representations of the data.
Quote from the inventor of MVC, Trygve Reenskaug:
"The essential purpose of MVC is to bridge the gap between the human user's mental model and the digital model that exists in the computer."
Source: http://heim.ifi.uio.no/~trygver/1979/mvc-2/1979-12-MVC.pdf
And you are not a human user, you are an engineer.
I am most certainly a human user.
Maybe there is some significant difference, but you haven't outlined one other than "it's not what person X says MVC means".
as JSON encoded output, as XML....
You have just provided a new definition of a view:
"A view is just an interface layer. Whether it's interfacing to a human or not is irrelevant"
If this definition suits your application, good for you. But you are no longer talking about MVC.
The problem here is that Reenskaug explicitly abrogated the authority you're appealing to. He recognised that MVC as originally posed was problematic and incomplete, and invited others to refine it via a pattern language, making MVC a metadefinition. At this point in history, you simply can't point at "MVC" and say that the original definition is canonical.
If you're still going to appeal to the original definition, the View still isn't a visual representation. That's the Editor. Everyone seems to forget about that bit. If you exclude the Editor, we're no longer in Reenskaug-MVC, so even if they weren't in the first place, machine representations would be ok. If you include it, your objection to JSON and RSS representations per se falls apart, because they can be perfectly valid technical details of the Editor layer under control of the View.
If this definition suits your application, good for you. But you are no longer talking about MVC.
Yes, I am. I'm just not talking about your definition of MVC, which is needlessly proscriptive.Unfortunately, the wrong choice comprises nearly half of comments made. You were obviously right the first time - let it lie :)
That said, non-HTML output bypasses the view entirely in Rails (it makes sense to), so it can equally be the case that the distinction is correct.
https://github.com/rails/jbuilder/
It looks a lot like a view file :)
The Formatter inspects the Request to determine what format it should be (html, json, xml, etc.), and returns the correct View to the Controller, which then passes the Model to that View.
The way we chose to do things in LedgerSMB (starting with the new code in 1.3) is to adopt a sort of untraditional MVC. The view has to represent the model and vice versa (information present in the model thats not in the view is never used, information present in the view but not in the model is always discarded).
However, the controller scripts are agnostic of this structure. They just glue these together and process operations. Therefore depending on the changes to the view, you may or may not have to change the model, but you should not have to change the controller unless you want to change what a button does. Similarly for reports, you can change these to your heart's content and no underlying changes are needed at all.
We've run into a lot of resistance from folks more used to traditional MVC stuff because the controller only needs to know what it minimally needs to know (and usually this is virtually nothing). Since everything is hash refs passed around....
But in the end the approach works, and specifically because we try hard to keep things fairly abstracted and loosely coupled within the application.
That is, a model encompasses extracting the knowledge and turning into something that the controller passes to a view or another model, but is not processed much (if any) during the transfer. At most, it might be combined with data from other models into an uber-record that is passed to the view.
How much of my code survives if I drastically change the view?
For example, if I want to switch to a new desktop, web or text console interface, can I reuse much of the application? Of course, architecture changes this significantly (particularly web architecture), but still, if I cannot swap out the view, then I'm losing out on one of the significant advantages of an MVC architecture. One way to make sure this works is to start with 2 views from the beginning - the view you're actually going to ship, and a headless view for tests.