The anomaly (in terms of MVC) that makes this design difficult to create MVC-compliant is that you want to display information that, in your concept, "does not live in the model." In MVC there is no such thing as âinformation that does not live in the modelâ: its conceptual root: âmodels contain all the information, the views simply perform presentation tasks, the controllers mediate user interaction.â
It is possible that the information you display does not "correspond to any business data", but (in the worldview of MVC) this means that it does not mean that the information is "model independent" "because there is no such thing - it simply means what do you need another class of model (besides what you use to store "business data") to store this "non-business data" !-)
So, when the user âcreates a widget instanceâ (creates a catalog view, presumably by some user action on some main / coordinating view, possibly on another existing widget, if âcloningâ is one way to create a widget instance ), the controller responsible for creating both the widget object and the instance of the "catalog display model class", and establishing the relationship between them (usually by setting a link to the corresponding model instance in the widget), as well as a model for the initial loading of information. When a userâs action in widgets implies an action on a model, the controller extracts a link to the model instance from the widget participating in the event and sends this instance to the appropriate requests (this is a model model that allows the view [s] interested in this to know about changes in information - usually , with the help of some observer pattern, this is definitely not a business controller for delivering information with information - this is really a very different approach from MVC!).
Does the cost of architectural investment correspond to MVC, in your case, compared to a tougher approach, when information flows are less pristine, and the model that should be there simply does not exist? I am a pragmatist, and I definitely do not worship the MVC altar, but I think that in this case (relatively small) investments in sound, a clear architecture can really extinguish itself in abundance. Itâs about anticipating the likely directions of change â for example, what functionality that you donât need right now (but may well get into the picture soon after) will be trivial if you go along the proper MVC route and be an ad hoc kludges nightmare otherwise (or require a somewhat painful reorganization of the entire architecture)? All kinds of possible things, from the desire to display the same catalog information in different widgets, to have a smarter model of viewing âcatalog informationâ, which can be automatically updated as necessary (and provide new information directly to interested views using a regular observer template without involvement of the controller), are natural light and trivial with the MVC (hey, that MVC whole point, after all, so it's not surprising -!), kludgy and fragile with ad-hoc architecture corner at Lamy - a small investment, a large potential rewards, go for it!
You can see from the volume in the previous paragraph that I donât worship the altar of âextreme programmingâ - as a pragmatist, Iâll do a bit of âdesign aheadâ (especially from the point of view of inputting a clean, flexible, extensible architecture, from the very beginning, even if itâs not necessary now) - precisely because, in my experience, a little prudent and very modest investment, especially on the architectural facade, pays for itself many times over (in such various currencies as scalability, flexibility, expandability, maintainability awesomeness, security, etc., although not all of them will apply to all projects - for example, in your case, security and scalability are not really a concern ... but other aspects are likely to be! -).
Just for the sake of generality, let me note that this pragmatic attitude of mine does not justify the excessive energy and time spent on collecting architecture (by the definition of the word "excessive" ;-) - acquaintance with several fundamental architectural templates (and MVC is certainly one of them ) often reduce the initial investment in terms of time and effort - as soon as you understand that such a classic architecture will serve you well, because in this case it is very easy to see how to implement it (for example, reject the idea of ââ"MVC without M"!), and in fact, it does not take much more code compared to the most complex and fastest ad-hoccest shortcuts! -)