Model–view–adapter
   HOME

TheInfoList



OR:

Model–view–adapter (MVA) or mediating-controller MVC is a software
architectural pattern An architectural pattern is a general, reusable solution to a commonly occurring problem in software architecture within a given context. The architectural patterns address various issues in software engineering, such as computer hardware perform ...
and
multitier architecture In software engineering, multitier architecture (often referred to as ''n''-tier architecture) is a client–server architecture in which presentation, application processing and data management functions are physically separated. The most wide ...
. In complex computer applications that present large amounts of data to users, developers often wish to separate data (model) and
user interface In the industrial design field of human–computer interaction, a user interface (UI) is the space where interactions between humans and machines occur. The goal of this interaction is to allow effective operation and control of the machine f ...
(view) concerns so that changes to the user interface will not affect data handling and that the data can be reorganized without changing the user interface. MVA and traditional
MVC MVC may refer to: Science and technology * Maximum-value composite procedure, an imaging procedure * Multivariable calculus, a concept in mathematics * Multivariable control, a concept in process engineering * Mechanical vapor compression, a desal ...
both attempt to solve this same problem, but with two different styles of solution. Traditional MVC arranges model (e.g., data structures and storage), view (e.g., user interface), and controller (e.g., business logic) in a triangle, with model, view, and controller as vertices, so that some information flows between the model and views outside of the controller's direct control. The model–view–adapter solves this rather differently from the
model–view–controller Model–view–controller (MVC) is a software architectural pattern commonly used for developing user interfaces that divide the related program logic into three interconnected elements. This is done to separate internal representations of infor ...
by arranging model, adapter or mediating controller and view linearly without any connections whatsoever directly between model and view.


Principles


View and model do not communicate directly

The view is completely decoupled from the model such that view and the model can interact only via the mediating controller or adapter between the view and the model. Via this arrangement, only the adapter or mediating controller has knowledge of both the model and the view, because it is the responsibility of solely the adapter or mediating controller to adapt or mediate between the model and the view—hence the names adapter and mediator. The model and view are kept intentionally oblivious of each other. In traditional MVC, the model and view are made aware of each other, which might permit disadvantageous coupling of view (e.g., user interface) concerns into the model (e.g., database) and vice versa, when the architecture might have been better served by the schema of the database and the presentation of information in the user-interface being divorced entirely from each other and allowed to diverge from each other radically. For example, in a
text editor A text editor is a type of computer program that edits plain text. Such programs are sometimes known as "notepad" software (e.g. Windows Notepad). Text editors are provided with operating systems and software development packages, and can be us ...
, the model might best be a
piece table In computing, a piece table is a data structure typically used to represent a text document while it is edited in a text editor. Initially a reference (or 'span') to the whole of the original file is created, which represents the as yet unchanged ...
(instead of, say, a
gap buffer A gap buffer in computer science is a dynamic array that allows efficient insertion and deletion operations clustered near the same location. Gap buffers are especially common in text editors, where most changes to the text occur at or near the cur ...
or a
linked list In computer science, a linked list is a linear collection of data elements whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collection of nodes whic ...
of
line Line most often refers to: * Line (geometry), object with zero thickness and curvature that stretches to infinity * Telephone line, a single-user circuit on a telephone communication system Line, lines, The Line, or LINE may also refer to: Arts ...
s). But, the user interface should present the final resting state of the edits on the file, not some direct information-overload presentation of the piece-table's meticulous raw undo-redo deltas and incremental operations on that file since the current editing session began.


Model is intentionally oblivious of views

This
separation of concerns In computer science, separation of concerns is a design principle for separating a computer program into distinct sections. Each section addresses a separate '' concern'', a set of information that affects the code of a computer program. A concern ...
permits a wide variety of different views to indirectly access the same model either via exactly the same adapter or via the same class of adapters. For example, one underlying data-storage model and schema and technology could be accessed via different views—e.g., Qt
GUI The GUI ( "UI" by itself is still usually pronounced . or ), graphical user interface, is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indicator such as primary notation, inste ...
,
Microsoft Microsoft Corporation is an American multinational technology corporation producing computer software, consumer electronics, personal computers, and related services headquartered at the Microsoft Redmond campus located in Redmond, Washing ...
MFC GUI,
GTK+ GTK (formerly GIMP ToolKit and GTK+) is a free and open-source cross-platform widget toolkit for creating graphical user interfaces (GUIs). It is licensed under the terms of the GNU Lesser General Public License, allowing both free and proprie ...
GUI, Microsoft .NET GUI,
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
Swing GUI,
Silverlight Microsoft Silverlight is a discontinued application framework designed for writing and running rich web applications, similar to Adobe Inc., Adobe's Run time environment, runtime, Adobe Flash. A plugin for Silverlight is still available for a v ...
website A website (also written as a web site) is a collection of web pages and related content that is identified by a common domain name and published on at least one web server. Examples of notable websites are Google Search, Google, Facebook, Amaz ...
, and
AJAX Ajax may refer to: Greek mythology and tragedy * Ajax the Great, a Greek mythological hero, son of King Telamon and Periboea * Ajax the Lesser, a Greek mythological hero, son of Oileus, the king of Locris * ''Ajax'' (play), by the ancient Greek ...
website—where (unlike traditional MVC) the model is kept completely oblivious of what information flows toward these
user interfaces In the industrial design field of human–computer interaction, a user interface (UI) is the space where interactions between humans and machines occur. The goal of this interaction is to allow effective operation and control of the machine fr ...
. The adapter or class of adapters keeps the model completely oblivious that it is supporting multiple of the user interfaces and perhaps even supporting this variety concurrently. To the model, these multiple types of user interface would look like multiple instances of a generic user oblivious of type of technology.


View is intentionally oblivious of models

Likewise, any one user interface can be kept intentionally oblivious of a wide variety of different models that may underlie the mediating controller or adapter. For example, the same website can be kept oblivious of the fact that it can be served (A) by an SQL
database server A database server is a server which uses a database application that provides database services to other computer programs or to computers, as defined by the client–server model. Database management systems (DBMSs) frequently provide database- ...
such as
PostgreSQL PostgreSQL (, ), also known as Postgres, is a free and open-source relational database management system (RDBMS) emphasizing extensibility and SQL compliance. It was originally named POSTGRES, referring to its origins as a successor to the In ...
,
Sybase SQL Server SAP ASE (Adaptive Server Enterprise), originally known as Sybase SQL Server, and also commonly known as Sybase DB or Sybase ASE, is a relational model database server developed by Sybase Corporation, which later became part of SAP AG. ASE was ...
, or
Microsoft SQL Server Microsoft SQL Server is a relational database management system developed by Microsoft. As a database server, it is a software product with the primary function of storing and retrieving data as requested by other software applications—which ma ...
that has
business logic In computer software, business logic or domain logic is the part of the program that encodes the real-world business rules that determine how data can be created, stored, and changed. It is contrasted with the remainder of the software that might ...
built into the database
server Server may refer to: Computing *Server (computing), a computer program or a device that provides functionality for other programs or devices, called clients Role * Waiting staff, those who work at a restaurant or a bar attending customers and su ...
via stored procedures and that has transactions that the server may roll back or (B) by an SQL database server such as
MySQL MySQL () is an open-source relational database management system (RDBMS). Its name is a combination of "My", the name of co-founder Michael Widenius's daughter My, and "SQL", the acronym for Structured Query Language. A relational database o ...
that lacks one or more of these capabilities, or (C) by a nonSQL RDF database, because the website interacts only with the mediating controller or adapter and never directly with the model.


Multiple adapters between the same model–view pair

Additionally, multiple adapters may be created to change the way one view presents data for a given model. For example, different adapters may impose different primitive data sets, that in turn impose different business logic for the same underlying database and for the same outwardly presented website. In this scenario, a class of various adapters or mediating controllers can represent the variations in business logic in between the same database model and the same website view.


See also

*
Model–view–controller Model–view–controller (MVC) is a software architectural pattern commonly used for developing user interfaces that divide the related program logic into three interconnected elements. This is done to separate internal representations of infor ...
*
Model–view–presenter Model–view–presenter (MVP) is a derivation of the model–view–controller (MVC) architectural pattern, and is used mostly for building user interfaces. In MVP, the ''presenter'' assumes the functionality of the "middle-man". In MVP, all pr ...


References

{{DEFAULTSORT:Model-view-adapter Software design patterns Architectural pattern (computer science)