Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
When designing an application, clearly separating the different logic components that define it always proves useful, and many different paradigms help developers achieve that goal. One of the most famous and most used is surely Model-View-Controller (MVC), which divides each application (or part of it) into three different fundamental elements and states the rules for linking them together. Swing itself is based on this pattern, and everyone who has worked with Struts, a popular framework for building Web applications, knows the theory behind MVC.
This article shows how to enhance MVC by adding a new component to the game that uses annotations to provide an easier decoupling between models and views. It introduces an open source library, named Stamps, which is based upon the component and removes the burden of writing all the plumbing between models, views, and controllers when developing MVC applications.
As the name indicates, the Model-View-Controller pattern suggests the division of an application into the following elements:
These components are tied together: The user affects the view, which, in turn, notifies the controller, which then updates the model. Finally, the model updates the view to reflect its new state. Figure 1 represents the typical MVC setup.
Figure 1. The typical MVC setup
As one of the new features provided with J2SE 5.0, annotations allow the developer to add metadata to classes, methods, fields,
and other language components. Just like reflection, any application can then retrieve and use that metadata at runtime for
whatever reason. Since J2SE 5.0 defines only how to write and read annotations, but not what to do with them (with the exception
of the predefined ones, like
@Override), the developer has endless possibilities in using them for many different jobs: documentation, object-relational mapping,
code-generation, and so on. Annotations have become quite popular as most frameworks and libraries are being updated to support
them. See Resources for more information on MVC and annotations.
As mentioned previously, some sort of coupling between models and views proves necessary since the latter must reflect the former's state. Common Java programs use direct or indirect coupling to bind the components together. Direct coupling occurs when the view has a direct reference to the model—or vice versa, the model contains a list of the views to be maintained. Indirect coupling is generally achieved with the adoption of an event-based dispatching mechanism. The model fires events whenever its state changes, and an independent number of views register themselves as listeners.
|Forum migration complete By Athen|
|Forum migration update By Athen|
|My problem is tracking the messages. By matthew_ford|
|Design an MVC framework By JavaWorld|