Live data from Hacker News

MVC is dead, it's time to MOVE on

cirw.in

121–130 of 233 posts

Re: MVC is dead, it's time to MOVE on

#121
post #56

The best practices I've seen for MVC apps isn't to put all the logic in the controllers. What you do is to create a "services" or "managers" layer that is called on by the controllers. A userService, for example, might have a function user = userService.login(name, password) It's also nice to abstract this service layer with some clean interfaces so that you can replace the underlying implementation, for example to m…

I agree, I really like the "services" layer. I used it for years programming with Java/Spring and missed a lot when learning RoR. I think it is no coincidence that the two RoR real-world projects that I worked had enormous controllers. The service layer is great to orchestrate operations between models and I don´t know a reason for not using it.

Does anything stop you from using a service layer with Rails?

Re: MVC is dead, it's time to MOVE on

#122
"you end up stuffing too much code into your controllers, because you don't know where else to put it"

And that wouldn't happen to have anything to do with the fact that "you" either don't know any other patterns or solutions besides MVC, or are under the impression that using MVC somehow forbids you to use other patterns?

Not to mention the fact that the definition of MVC that the author uses is false (in a way that describes MVC as more simplistic and limited than it truly is), but after so many years I'm not even going to argue with that any more. Just fucking Google it.

tl;dr: Those who cannot learn from history are doomed to repeat it.

Re: MVC is dead, it's time to MOVE on

#123
> In a MOVE application models only wrap knowledge. That means that, in addition to getters and setters, they might contain functions that let you check "is this the user's password?", but they don't contain functions that let you save them to a database or upload them to an external API. That would be the job of an operation.

I cant understand the distinction between a 'setter' (stated here as part of the MOVE 'model') and 'functions that let you save... to a database or upload... to an external API' (stated here as part of the MOVE 'operations').

I would understand the logic a lot more if the 'model' excluded 'setters' entirely and just included 'queries' (which don't change the underlying data set) as opposed to 'commands'/'setters' (which do...). As it is I'm not sure where the line is between 'operations' and 'model' except for the use-cases that have been explicitly stated.

Re: MVC is dead, it's time to MOVE on

#124
post #96

Earlier quoted context omitted.

JSON and RSS views don't make sense - in MVC, views are visual representations of data (the model). Views are how the user percieves the application. JSON and RSS are just different methods for representing data to be communicated to other systems.

So it's only a view when you write all your code to push bits to the monitor yourself. Outputting using libraries that convert formats like html (-> browser -> os/driver -> screen) aren't views. Got it.

Let me give you an example. In your model, you have represented the salary of an employee as an integer. In a web application, the salary can be presented to the user through numerous different views - as a number on the screen (plain HTML), as a slider (jQuery UI slider), as a bar in a bar chart (using some charting library). The tools you use to build the view are not relevant.

Re: MVC is dead, it's time to MOVE on

#125
Does anyone else think that it's weird for the model to be sending events directly to the view and have the view listening for those? That seems like something that should be going to the "operation tree" and having that push changes to the view.

Re: MVC is dead, it's time to MOVE on

#126
Does anyone else think that it's weird for the model to be sending events directly to the view and have the view listening for those? That seems like something that should be going to the "operation tree" and having that push changes to the view.

Re: MVC is dead, it's time to MOVE on

#128
post #120

Earlier quoted context omitted.

In the context of MVC, a user is a human being - describing JSON and RSS services as "views" totally misses the point. 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."

I'm a human user and I have a mental model of the json and rss apis I consume via code I write. I notice that he didn't say visual as you did earlier

"A view is a (visual) representation of its model. It would ordinarily highlight certain attributes of the model and suppress others. It is thus acting as a presentation filter."

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.

Re: MVC is dead, it's time to MOVE on

#129
Are you talking about pure mvc's like sproutcore? faux mvc's like backbone? model2 patterns like rails and most other server side architectures? I think what you mean is 'Model2 is dead...'. MVC is great for any environment where the observer pattern can be implemented (eg web front-end).

The biggest problems I've seen in model 2 architectures is weak models. The side effect of this is everything gets stuffed in the controllers. This is understandable because there is no observer pattern and therefore the models don't have nearly the power they do in real MVC.

Heres a great explanation of the MVC[1]:

In a nutshell the classic MVC architecture work like this. There is a model that is at the heart of the whole thing. If the model changes, it notifies its observers that a change occurred. The view is the stuff you can see and the view observes the model. When the view is notified that the model has changed, the view changes its appearance. The user can interact with the view (e.g. clicking stuff) but the view doesn’t know what to do. So the view tells the controller what the user did and assumes the controller knows what to do. The controller appropriately changes the model. And around and around it goes.

[1] http://michaux.ca/articles/mvc-architecture-for-javascript-a...

Re: MVC is dead, it's time to MOVE on

#130

Earlier quoted context omitted.

So it's only a view when you write all your code to push bits to the monitor yourself. Outputting using libraries that convert formats like html (-> browser -> os/driver -> screen) aren't views. Got it.

Let me give you an example. In your model, you have represented the salary of an employee as an integer. In a web application, the salary can be presented to the user through numerous different views - as a number on the screen (plain HTML), as a slider (jQuery UI slider), as a bar in a bar chart (using some charting library). The tools you use to build the view are not relevant.

> In a web application, the salary can be presented to the user through numerous different views - as a number on the screen (plain HTML), as a slider (jQuery UI slider), as a bar in a bar chart (using some charting library)

as JSON encoded output, as XML....

Post reply on HN