The MVC pattern is a dead end for application development?

In this article I would like to tell you why to use the MVC design pattern is not enough to create flexible and scalable applications. And to propose solutions to identified problems.

In the Model View Controller pattern, there is nothing wrong. It solves the problem for which it was invented — is the separation of logic processing of the user request and the logic of the presentation of information.

mvc


Before the invention of this template, the logic to process the user request and the logic display were closely intertwined in the same file. This is a very complicated support and led to many errors in the system.

Spaghetti code

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

loose coupling

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

Also if you have changed the process of working with the system (changed the business or domain model), the user can learn a new process without making any changes to the UI system.

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

What if the system comes to multiple users?

To simplify use of the system, you can make sure that she knew in what order to work with it and suggested to the user next steps.

But here lies the cunning use of MVC pattern. As shown in the image below, it is tempting to refer directly to representation (View) of the module 'A' on the controller (Controller) module 'B' with module 'B' and module 'C', module 'C' on module 'D'.

Strong connectivity
(Or from controller of module 'A' module controller 'B'. Or, even worse, from controller of module 'A' representation module 'B'. )

The business process is rigidly fixed in 3 views (Views). Agree that not very clearly. The change in business process will also be hampered because of the distribution of links in several files. And support for multiple types of business logic, which will involve, for example, modules A, C and D will have to implement using if/else in the view (Views).

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

How to regain the loose coupling of system modules, retaining the description of business processes in it?



For this you need to make the configuration of the business processes of the modules and place it separately.
To make users and all modules communicate via a single master controller.
The controller will follow the configuration of which modules, in what sequence to provide the user to work.

For configuration of modules and transitions between them are very convenient to use implementation based on ultimate slot machines (Finite State Machine).

Examples of such implementations in the Java world can be:

Spring Web Flow add-on Spring MVC.

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

Lexaden Web Flow — the implementation for the component model Vaadin.
What you have to know the implementation of this approach in Java?
There may be similar frameworks for other programming languages?

P. P. S. details of the implementation of the described solution for Lexaden Web Flow and Vaadin, described in detail in the article: Navigation: variant of implementation for the enterprise application
Article based on information from habrahabr.ru

Комментарии

Популярные сообщения из этого блога

Car navigation in detail

Google has launched an online training course advanced search

PostgreSQL: Analytics for DBA