Is the MVC pattern a dead end for application development?

In this article, I would like to talk about why using the MVC design pattern is not enough to create flexible and scalable applications. And also offer solutions to identified problems.

There is nothing wrong with the Model View Controller template itself. It solves the problem for which it was invented - this is the separation of the logic of processing the user's request and the logic of the presentation of information.

mvc


Prior to the invention of this pattern, user request processing logic and display logic were closely intertwined in a single file. This greatly complicated the support and led to many errors in the system.

Spaghetti code

Using the MVC pattern is good where the modules are relatively independent of each other. For example, they are called from the main menu. The user works with module A, then opens module B and so on.

Weak connection

In this case, he must know in what order to work with the system modules in order to make the necessary changes.

Also, if the process of working with the system has changed (the business or domain model has changed), the user can learn the new process without making changes to the user interface of the system.

Everything is fine as long as the system is used by a small number of people who can be trained to work with it.

But what if the system comes to many users?

To simplify the use of the system, you can make it so that it itself knows in what order to work with it and offers the user further steps.

But here lies the insidiousness of using the MVC template. As shown in the image below, it is tempting to refer directly from the View of the 'A' module to the controller of the 'B' module, from the B module to the C module, from the C module to the D module .

Strong connectedness
(Or from the controller module 'A' to the controller module 'B'. Or, even worse, from the controller module 'A' to the presentation of module 'B'.) The

business process will be hard-coded in 3 views. Agree that not very clearly. Changing the business process will also be difficult due to the distribution of links across multiple files. And support for several business logic options, where, for example, modules A, C and D will be connected, will have to be implemented through if / else in the Views.

Unfortunately, this approach is very often used to build applications.

How to return the former weak coherence of the system modules, while maintaining a description of the business processes inside it?



To do this, you need to make the configuration of business processes from the modules and place it separately.
Make sure that users and all modules communicate through one primary controller.
In this case, the controller will be guided by the configuration, which modules, in what sequence to provide the user for work.

To configure the module states and transitions between them are very convenient to use the implementation based on finite automata ( the Finite State Machine ).

Examples of such implementations in the Java world are:

Spring Web Flow - add-on for Spring MVC .

the ADF the Task Flows from the Oracle - implementation is very similar to the Spring Web Flow.

Lexaden Web Flow - implementation for the Vaadin component model .

What other implementations of this approach do you know in Java?
Maybe there are similar frameworks for other programming languages?

PPS Implementation details of the described solution for Lexaden Web Flow and Vaadin are described in detail in the article: Navigation: implementation option for a corporate application

Also popular now: