Saturday, July 10, 2010

MVC framework development in Swing

Not sure whether there is any like JSF/Struts kinds are there for fat client development. I thought something similar should work well with the desktop apps. Here is what I think -

Develop a framework XML schema design that will map each of the users' screen into the event source, the listener, target business component, target business method and its parameters in terms of the source screens' saved properties. The XML will look something like this -


com.pkg.gui.Source
com.pkg.gui.listener.Listener
com.pkg.model.Model
methodName
sourceProperty

outcome
com.pkg.gui.TargetScreen
fileName

.....
Several other mappings
....

The main idea is to reduce the application code and not unnecessary handling the screen flow. The developer can concentrate on - Designing the front screen, modelling the business data and the objects containing the business logic.

Once a event is detected, the registered listener's corresponding method is invoked. Inside the method, developer can simply call - Controller.invoke(this, sourceScreen); This call will get Controller to read the XML file to find out the source screen mapping. It will take the action source by the help of the event (From the listener) and based on the mapping load the corresponding business object and invoke the designated method with the designated parameter "reflectively".

There are several gray area in this - such as - how the target screen will populate the screen's property? Essentially, what I try to do here is eliminate the developer's codes like -
if (event.source is button)
then
 if button id is search
  then
    take text from this field
    make the object of this class
    invoke this method
    if (result is x)
         initialize this screen
   else
       initialize screen x
 else
  ........
Instead of all these code under ONE listener's action method, one will write - Controller.invoke(params);

However, this seems to be a much convoluted XML design game. WIP.

Welcome to my blogs

The contents here are my independent point of view. They reflect my thoughts, experience in my professional and social life.

Search This Blog