Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Coordinate User Interface Development with VB.NET and the MVC Pattern : Page 2

Use VB.NET and the MVC pattern to create a user interface framework for collaborative development. By cleanly isolating display elements from data, the MVC pattern lets multiple programmers develop and modify UI functionality at the same time without problems.


advertisement
The Model-View-Controller Pattern
The Model-View-Controller pattern was created out of a need to cleanly separate the display logic, business logic, and data in an application and to properly coordinate their interactions. Take for example a financial application where the same information can be displayed in two separate documents, one as numeric values and one as a chart. If the data changes, both documents must be automatically updated to reflect the changes. The MVC pattern has three classes:

The Model represents the underlying data for the application. It can be a series of business objects, or even the database itself. The View represents the user interface element. It can be a form, a control, or a web page.

The Controller coordinates interaction between the View and the Model. It can validate user-entered data and raise exceptions where necessary. It passes data changes to the Model. The Model, the View, and the Controller interact with each other using direct method calls and by raising events. The sequence generally follows the following sequence



  1. The user inputs data into a View
  2. The View notifies the Controller of a change by using the HandleEvent function
  3. The Controller modifies the Model directly using its properties
  4. The Model sends out events to all its observers to inform them of the change
Implementing the MVC pattern implies also implementing the Observer pattern to allow the objects to sending and receive events. The Observer pattern has two classes:
  1. A Subject—the source of events.
  2. an Observer—which registers with a subject and is notified of changes through events
Figure 1: The Model-View-Controller implies the implementation of the Observer pattern to coordinate events between classes.
There are multiple ways to implement the MVC pattern. Patterns are, by their nature, abstract and open to interpretation. This implementation behaves as follows:

  • The Model sends events to the View informing it of new or modified data
  • The View communicates directly with the Controller to inform it of changes made in the user interface
  • The Controller modifies the Model directly to make changes to the data.


Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date