词条 | Model–view–adapter |
释义 |
View and model do not communicate directlyThe 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, the model might best be a piece table (instead of, say, a gap buffer or a linked list of lines). 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 viewsThis separation of concerns 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, Microsoft MFC GUI, GTK+ GUI, Microsoft .NET GUI, Java Swing GUI, Silverlight website, and AJAX website—where (unlike traditional MVC) the model is kept completely oblivious of what information flows toward these user interfaces. 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 modelsLikewise, 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 such as PostgreSQL, Sybase SQL Server, or Microsoft SQL Server that has business logic built into the database server via stored procedures and that has transactions that the server may roll back or (B) by an SQL database server such as MySQL 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 pairAdditionally, multiple adapters may be created to change the way one view presents data for a given model. For example, different governments (either among different states of the United States or different nation-states internationally) may impose different codes of law, 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 among these jurisdictions in between the same database model and the same website view. See also
References1. ^{{cite journal |last1=Zamudio Lopez |first1=Sheydi Anel |last2=Santaolaya Salgado |first2=Rene |last3=Fragoso Diaz |first3=Olivia Graciela |title=Restructuring Object-Oriented Frameworks to Model-View-Adapter Architecture |journal=IEEE Latin America Transactions |date=June 2012 |volume=10 |issue=4 |pages=2010–2016 |doi=10.1109/TLA.2012.6272488 |language=Spanish}} {{DEFAULTSORT:Model-view-adapter}}2. ^{{Citation|last=Thiruvathukal|first=George K.|title=Managing Concurrency in Mobile User Interfaces with Examples in Android|date=2018|work=Topics in Parallel and Distributed Computing|pages=243–285|publisher=Springer, Cham|language=en|doi=10.1007/978-3-319-93109-8_9|isbn=9783319931081|last2=Läufer|first2=Konstantin}} 2 : Software design patterns|Architectural pattern (computer science) |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。