What is Architectural Patterns?
The modern Web is founded on an architecture where a Web browser makes a request of a Web server and gets a response that it renders and shows to the user.
For interactive, data-driven Web applications, you can expand the Web server box to reveal an architecture that has become the norm for modern Web applications.
Example of one of the Data-driven Web Applications architecture:
When application is large scale, spilling over with screens and features, it may become increasingly complex. Over time, the complexity may become unmanageable unless you have a good architecture in place.
Good development architecture is all about reusing concepts and ideas from previously successful implementations of your current project. These are known as patterns.
Among the several good patterns that you can use are as follows:
1. MVC (Model-View-Controller)
2. MVVM (Model-View-ViewModel)
3. MVP (Model-View-Presenter)
Alhough each has its strengths and weaknesses, from a development standpoint, they can be treated similarly. There isn’t a single definition for any of these patterns. If you search the Web, you can find several slightly different descriptions of each.
What is goal of Architectural Patterns?
These architectural patterns have goal to help keep the application structured in such a way that it is easy to maintain and has low coupling. Re-usability is one of the key Principles of Architecture.
What are the major elements involved in Architectural Patterns?
Architectural Patterns separate our application into three major sections.
This is the data model and is typically represented by the database and any direct interaction with the database. This includes the queries used to extract the data from the database, classes that represent a row in each table (entity classes), and entity class validation logic to ensure that the data in the database is consistent with the business rules. The validation logic ensures that the data is consistent with business rules before it is stored in the database.
This is the code that displays the data on the screen for use by the user. It includes the code to create the window and add the controls necessary to display data. A significant piece that is not in the view is data manipulation and business logic. Changing data is the responsibility of the third piece, the controller, presenter, or view model.
Controller / presenter / view model:
The place where the three patterns differ is in this third piece. Depending on which pattern you choose, you have only a controller, only a presenter, or only a view model. The general goal of these pieces is the same in all three patterns, but the specifics and implementation details differ.
In general, each view has either a controller, presenter, or view model associated with it. This is the section that glues the model and view together and orchestrates the interaction between the two. This is where we put the business logic necessary to decide which rows in the database need to be retrieved and the code to query those rows (using the model) and deliver that data to the view to display to the user. This piece uses the services we described earlier to implement some of the generic business logic, and the logic specific to the requested operation is included here.