Live data from Hacker News

MVC Isn’t MVC

collindonnell.com

111–120 of 165 posts

Re: MVC Isn’t MVC

#112
One question which always preoccupied me is how those MVC components interact with nesting/recursion. For example, a view may include a scrollbar, which has state, and can be interacted with, sometimes independently from the model displayed by that view. So the scrollbar has it’s own model (containing e.g. the scrollbar position) and it’s own view (responsible for how the scrollbar is rendered) and controller (allowing the user to operate the scrollbar). This nested mini-MVC for the scrollbar however is primarily or exclusively part of the larger view. The scrollbar’s model, however, may have to refer to the larger model, for example when the scrollbar size depends on the size of the larger model’s data. Or maybe its the scrollbar’s controller that queries the larger model (or gets notified by it) and then updates the scrollbar’s model. In any case, it’s not obvious how exactly the nesting could or should work.

More complex cases are for example a combo box, which consists of a text input, a dropdown button, a dropdown list, which in turn may have a scrollbar. And this is just one relatively basic control within a potentially much more complex UI.

I’ve never seen a systematic treatment of that topic. Given that UIs use nested controls, one would think that this would be widely addressed by architectural patterns for UIs.

Re: MVC Isn’t MVC

#113
post #23

What MVC refers these days is not of MVC from 1979 but from the Design Patterns by Gags of Four and they did not mean the patterns should be applied strictly as is. So.. what? What is the point of the article? He does not seem to really understand the purpose of design patterns and it in practice

MVC isn't a Pattern in GoF.

Re: MVC Isn’t MVC

#114
post #112

One question which always preoccupied me is how those MVC components interact with nesting/recursion. For example, a view may include a scrollbar, which has state, and can be interacted with, sometimes independently from the model displayed by that view. So the scrollbar has it’s own model (containing e.g. the scrollbar position) and it’s own view (responsible for how the scrollbar is rendered) and controller (allowi…

The approach Elm uses is every event goes through a main "router", no exceptions.

If you want to do sth special on the account page modal scroll, you issue a specific event for that, and deal with it in the same way as any other.

It is a very simple and clean model, but not complicated enough for some people :) of course it helps that with a good type system you can catch missing or incorrect cases.

Re: MVC Isn’t MVC

#115
post #58

for simple web application backends, why does one need more than just "models" (structs, that describe database tables/rows, using something like "an ORM" but more lightweight, so as to provide query building, caching, etc.) and "routes" (procedures, mapped to URL patterns, that execute logic such as accessing models (cached or queried) and then responding with output from a simple HTML template system, or possibly a…

I'm using Sveltekit and doing pretty much what you're doing, and never touched Rails before. I'm equally confused about the MVC pattern I hear so much, and why it was so big back then, and why it isn't very big now. Was this more of a design / architecture "fad" or a design around the constraints of the time?

MVC offered a formalized separation of concerns for data, ui, and business logic at a time when many developers were cramming all of their application code into massive php or C# files. The pattern was delivered via frameworks (RoR, Cake, Asp.net MVC) that handled a lot of the boiler plate for you and made for an easier development experience than what most of the people switching to it were used to at the time. As web applications became more focused on the client code, the template driven server side rendering capabilities of these frameworks was less useful or no longer necessary.

Initially when the mindshare began to move to the client code, front end tool chains actually did do a lot of hemming and hawing of what variant of mv* they were. Eventually tools like react came around and whatever variant of mv* they were wasn’t what was interesting about the building paradigm. More or less that’s where we are now.

Re: MVC Isn’t MVC

#116
post #25

For OpenStep/NeXTSTEP style MVC, which is very similar to the original MVC, is well explained in the book "OpenStep for Enterprises", https://www.amazon.com/OpenStep-Enterprises-Nancy-Knolle-Cra... . I just cannot understand why the author says it's different from ST80 style MVC.

Is the explanation in that book better/different than the one in https://cdn.preterhuman.net/texts/computing/nextstep-openste...? Just curious.

Re: MVC Isn’t MVC

#117
post #33

A bit pedantic. It’s just a design principle not a scientific law.

It’s often unclear (and people have different opinions on) what exactly that principle actually is, though. You can’t just say “MVC” and have everyone be in agreement on what that will mean.

Re: MVC Isn’t MVC

#118
post #112

One question which always preoccupied me is how those MVC components interact with nesting/recursion. For example, a view may include a scrollbar, which has state, and can be interacted with, sometimes independently from the model displayed by that view. So the scrollbar has it’s own model (containing e.g. the scrollbar position) and it’s own view (responsible for how the scrollbar is rendered) and controller (allowi…

This is what MVVM is for. Last two letters mean View Model - a model of the view - data structures for each user control, and code that synchronizes these structures with Model structures.

Re: MVC Isn’t MVC

#119
post #112

One question which always preoccupied me is how those MVC components interact with nesting/recursion. For example, a view may include a scrollbar, which has state, and can be interacted with, sometimes independently from the model displayed by that view. So the scrollbar has it’s own model (containing e.g. the scrollbar position) and it’s own view (responsible for how the scrollbar is rendered) and controller (allowi…

This is what MVVM is for. Last two letters mean View Model - a model of the view - data structures for each user control, and code that synchronizes these structures with Model structures.

But that’s not a recursive pattern. I would disagree that there is only a single level on which MVC, MVVM, or whatever, is relevant. For example, the controller or View Model of a view containing a combo box should not have to manage the internal mechanics of the combo box. So it makes sense for the combo box to have its own internal MVC/MVVM. Similarly, the view may be embedded into a larger dashboard, where the dashboard should not have to manage the internals of the view, but would have its own MVC/MVVM.

Re: MVC Isn’t MVC

#120
post #96

Earlier quoted context omitted.

> You take a table from the database and put it into an html tag table. > Do you want your view to know how to connect to a db? I think this is where there's a misunderstanding: you think of your model as "a database". A database is not a model, a database is just a storage layer. A model is an object that provides an api with high-level business operations and views on data. At that point, your view needs only to re…

In fact the original MVC was done with Smalltalk which has a persistent image. So the Smalltalk system itself _is_ the storage layer in which model objects live.

This!

Also the original MVC (not the req-resp cycle Model2) was not for client-server split apps. It was for desktop apps, so the Model could update the view. Now with WebSockets we're coming full circle.

Post reply on HN