Live data from Hacker News

MVC is dead, it's time to MOVE on

cirw.in

131–140 of 233 posts

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

#131
post #96
post #83

Earlier quoted context omitted.

my rails apps pass this test with flying colors. Nearly all of my end points have at least 3 views. 1 for html, 1 for json (often used for ajax calls), and 1 for rss/atom.

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.

Not saying I disagree with you but then where exactly would the JSON and RSS output methods go in an MVC framework, if not in a view i.e. how would a different system or user consume/access their output? Directly from a controller? Would love to know your thoughts as I've always found MVC a difficult conceptual approach to grok when applying it to web apps (lots of code never seems to have an obvious M, V or C home).

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

#132

Earlier quoted context omitted.

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?

No, but it doesn't seem to be a common practice. Actually on my personal projects the first thing I do is to create a service layer, but sadly the real world projects that I jumped into never had it.

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

#133
post #113
post #59

Earlier quoted context omitted.

I suspect this is because most people do not actually understand what MVC is and how it applies to server-client relationships; in fact, the wikipedia article on MVC is slightly off on the subject, assuming one accepts the original Xerox description as a source. Try not to wrap the entire complicated application into one big MVC umbrella because that will just confuse. There are actually multiple processes involved,…

"The big epiphany for me was when I realized that the server has its own MVC, and the browser has its own MVC." While I'd still advocate DRY over this POV (unless of course DRY leads you here naturally), I will agree this is a generally valid viewpoint, because you've got the server-client model built in there instead of glossed over. And you are now the first person who has gotten me to be generally agreeable about…

I'm currently building a single page app using this MVC-MVC approach.

I use Angularjs in the browser, now.js for the interface, and, at the moment, custom code on the server that follows the MVC pattern.

The server is lightweight: its role is to

    * manage authentication and authorizations,
    * ensure data integrity and
    * push data on update according to user permissions.
That's it.

http://angularjs.org/

http://nowjs.com/

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

#134
post #120

Earlier quoted context omitted.

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.

You keep using an appeal to authority, and I still see no value in the distinction.

I am most certainly a human user.

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

#135
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.

HTML is also one of those different methods. It just so happens that the browser renders it instead of spitting out the raw text. 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.

rails is moving towards a "view" based approach. Here is one of the up and coming libraries.

https://github.com/rails/jbuilder/

It looks a lot like a view file :)

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

#136

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…

My thoughts exactly.

Having used MVC for many years, and in the environment where it was invented (Smalltalk-80), I couldn't help but wonder why he was reinventing MVC while thinking he was criticizing it.

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

#137
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.

I believe this gem does something like that, https://github.com/karmajunkie/imperator

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

#138
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.

> JSON and RSS are just different methods for representing data to be communicated to other systems. We call those, "views".

In an MVC, the views are used both for output of the model and to map input back to the controllers. Without the input, its not part of the MVC pattern.

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

#139

Earlier quoted context omitted.

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....

no, those output types dont map back to the controller, they are not views.

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

#140
post #23

This sure looks like MVC, but they call the Controller "operations". The MVC abstraction has an issue with web applications, since the request-response cycle doesn't provide feedback as directly as the hardware-monitor-software cycle that the pattern was originally designed around. However, if the problem is that you are putting too much "logic" into your controllers, you should probably find a better place for it. I…

This looks like MVC to me as well, except what MOVE is calling operations I would call commands. There are quite a few MVC frameworks that work like this, including PureMVC which has been implemented in almost every OOP language http://puremvc.org/.
Post reply on HN