MVC is obsolete

Balint Sera
3 min readApr 21, 2018

--

The MVC architectural pattern ruled the software world in the past twenty or so years. It is simple: you never mix your data with the display of them. But then how can you send your data to your view? With the help of a dedicated component, the so called controller. Decoupling the two most important layer of your application this way makes any changes to them easier.

So why am I telling you that MVC is obsolete?

Because in the past few years, most of us, backend web developers have lost our views.

And we are quiet happy with this situation. We still have our beloved datas, we can persist, aggregate, query and transform them using ten different database technology, but we don’t need to build html pages any more. I love HTML and I especially love client side javascript, but on the backend, thank you, I’m more then OK without them.

We build RESTful API-s as microservices, that have some kind of an input from the network and maybe have some kind of a response that we put into the wire as a response to the request.

We don’t send any kind of html any more, but mostly JSON instead. We lost the view, because all we have now is just some other kind of our data:

JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax. It is commonly used for transmitting data in web applications (e.g., sending some data from the server to the client, so it can be displayed on a web page, or vice versa)

Working with JSON (https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON)

“Well” — you say — “maybe you said good bye to your views, but you still have two layers, Model and Controller. How about MC pattern?”

We still have the models, you’re right, but since we don’t have the view, we don’t need to control their communication, do we? Because the Controller’s only job is to serve as a divider or border between the two other layer, it has lost its purpose, so we can happily let controllers go whereever they want.

Backend developers need new patterns — or better put, need to learn old patterns to replace MVC. What patterns? For example node.js has its Express framework, that extensively applies the middleware pattern to let the developers transform the request in any number of decoupled steps into a JSON formatted data response. Command pattern is almost as good as middleware for this task, because it separates the commands from the main flow controlling module. Mediator is almost as good as any subscriber can subscribe for an event such as a request to a route and send back a response or a new event.

We still have at least two layers, but we can’t call them contoller and model anymore.

This basically means that a good architect can leave the good old MVC frameworks because every languages have packages for almost everything and every one of them enables the implementation of these design patterns.

Because the good ol’ web frameworks are in an identity crisis we can expect some very interesting development in this field, like API Platform or Zend Expressive, or the new, very modular, but still controller centered Symfony 4 in PHP, and the forthcoming Loopback 4 in node (typescript especially). And while Go has some MVC frameworks, I think they never really have their momentum because of go’s extensive standard lib (including http).

--

--