Thread:«no subject» (503)

The Model-View-Controller (MVC) architecture is a powerful design pattern that recurs in most object-oriented programming languages and applications. MVC essentially decouples the data model from the component that represents it on the screen. If you have to work with graphical interfaces, you will most likely use MVC pattern in your program. Unlike AWT, the Java Swing component set uses the MVC architecture consistently. One of the earliest programming frameworks, MVC is a programming idiom to solve the user interface problem. If you write code that handles the data as well as draw the user interface screen to present it, you end up with a kludge. The code becomes error prone and difficult to maintain. MVC solves the problem by dividing it into three parts:  the data model - the component that handles data in the application  the view - the component that presents the data to the user  the controller - the component that mediates between the model and the view   This way the user interface code is decoupled from the code that handles data, and another component, the controller, is used to provide the interaction between the two. The benefits are two fold:  <font face="Verdana, Arial, Helvetica, sans-serif" size="2">Multiple views are possible from the same data model </li> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">Flexibility and re-use </li> </ul> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">The Java Swing set uses a modified MVC pattern. It combines the view and controller parts into a component. Each components has an associated data model, either a built-in class or a user defined sub-class. Explore a bit with the JTable and the JComco classes in the Swing set and you will see what I mean by multiple views, flexibility and re-use. <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> Related Topics : Observer, Strategy and Composite Design Patterns. See also Erich Gamma et al, Design Patterns <b>Elements of Reusable Object-Oriented Software</b>

[Published on my website at: http://javanook.tripod.com/patterns/java-mvc.html]