FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

MVC for DWT

 
Post new topic   Reply to topic     Forum Index -> Potential Projects
View previous topic :: View next topic  
Author Message
un_guru



Joined: 14 Sep 2005
Posts: 32

PostPosted: Wed Oct 25, 2006 2:23 pm    Post subject: MVC for DWT Reply with quote

the title is not the name of the project, it's just the description.
What it is, and what it is not:
- it's not jface
- it doesn't hide dwt, it attaches to dwt controls offering more power
- it's a data awarenes (component/tool/library) for dwt

How it works:
I have two methods to implement this (in my mind) and I don't know which one to choose
1. The View and the Controler are merged in one class:
Code:

class ViewControl
{
   this(parent , style, model)
{
...
}
/** Control part **/
   onValidate() { ... }
   onKeyDown() { ... }

   handleDataChanged( event) { ... }
}

class Model
{
registerListener(event, delgate)
/* delegate is a member of ViewControl and it will be called on event */
   notifyListeners(event)
// -- and functions to manage it's data
}


The ViewControl knows exactly the model it uses all it's public members to interogate and instruct, while the Model is not aware of it's listeners, it just notifys 'em about data changes using a well defined mechanism.
Code:
ExtendedCombo c = new ExtendedCombo(parent, style, model);
ComboModel m = new ComboModel();
m.registerListener(DataChanged, &c.handleDataChange);
m.registerListener(NewData, &c.handleNewData);
// ...
// If the user imput doesn't exist in combo's list, the combo will notify the model via NotInListEvent;
...
handleNotInList() // member of ExtendedCombo
{
   model.addData(this.getText()); // this might be this.combo instead
}

The Model has means to verify data and accept it sending a NewData event to the ViewControl, or invalidate the request sending a NotValidData to the VC. The VC will decide if necesary to update it's display or notify the user or ...

2. The second method uses 3 classes The View is a basic DWT Widget, the Model is similar to the 1st methods Model, and the Controler is a gateway between the View and the Model, it also controls the behaviour of both
One would use standard DWT Widgets and standard defined models(or exdending standards), and create a control to manipulate both. The Controler receives notifications from both the View and the Model.
Code:

ComboControler
{
   this(Widget, Model) { ... }
   onNewData() { // if needed update display}
   onNotInList() { //if needed update model}
   
}

I think the second option would help produce cleaner code, and it's true separation of MVC components.

It's also easyer to port the second option to other D GUIs (like DFL). The model doesn't know about GUI and the Controler can be quite easily changed to use other Widgets. Anyway, this is not a GUI abstraction layer Smile
Any ideas are welcome.
thank you

read more: http://en.wikipedia.org/wiki/Model-view-controller
Back to top
View user's profile Send private message
un_guru



Joined: 14 Sep 2005
Posts: 32

PostPosted: Sun Nov 05, 2006 5:41 pm    Post subject: Reply with quote

maybe this will bring more interest:
http://dworks.marte.ro/napuca.htm
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Potential Projects All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group