Topics: CAB & Smart Client Software Factory
May 23, 2007 at 3:42 PM
Hi my question is about mvp in cab application
as i understand the presenter communicates with the view through an appropriate interface
and the view holds an instance of the presenter
so far so good

1)My problem concerns the role of the controller(workItemController) and its interaction with the view
does the controller get the data via ServiceAgent or mybe this job is intended for the presenter (also via service agent)?

2) If the controller gets the data from the serviceAgent what is the right way to pass the data to the View ?
the controller holds and instance of IView so i can Invoke the method that i wont directly from the controller
IView.SetData(data) or mybe store the data in the workitem.Items collection and then the presenter will get the data from the items and assign it to the view.

Please advise me about the best/right way to do this

Thanks Alex

May 23, 2007 at 6:31 PM
Edited May 23, 2007 at 6:44 PM
My experience with the MVP pattern is that the presenter will get and retrieve data from the view and it will contain the logic and call services. This pattern allowed me to take out logic from the view and have a more testable code (more coverage).
On the other hand I’ve used the WorkItemController as the orchestrator of one or more use cases. It will subscribe to events and handle commands, show views, add services to the workitem, etc.

The learning material I found most enlightening was:
- Bank Branch reference implementation
- SCSF's Hands on Labs (

Hope it helps!

Luciano Panaro
May 24, 2007 at 1:51 PM
Hi Luciano

Thanks for your help but i would really like to pin point my problem so i will do things the "Right way"
EventSubscription("ShowMyData" )
public ShowMyDataHandler(Status s)
//This event is fired from a smartpart passing a parameter which tells me how
// to filter the needed data. and my dilema is as follows

IView MyView; // The view instance is taken from the workitem.Smartparts collection

// Or the alternative is and as i understand from you the right way to do this is
IView MyView;
WorkItem.Items.Add("MyData", MyServiceAgent.GetData(s));
// The next step would be to retrive the data from the items collection when the presenter OnViewReady is fired
// or mybe to store the Status parameter is the items collection and then Call the serviceAgent from the
// presenter.


Thanks for your help.
May 24, 2007 at 5:09 PM
Edited May 24, 2007 at 5:10 PM
Hi Alex,

I would put the logic inside the presenter and not in the controller.
You can inject the service to your presenter in order to work with it, resulting in something like this:
public IMyServiceAgent MyServiceAgent
    set { _myservice  = value; }
public override void OnViewReady()
    MyDataType data = MyServiceAgent.GetData();
May 31, 2007 at 7:44 PM
Jun 19, 2007 at 2:29 AM
I had a go at learning CAB last year, with the bankteller example - but put it on the shelf as having a huge learning curve.
Now I am ready to come back to CAB & SCSF.
I was listening to Ron Jacob's program about the "Presenter First" pattern at which sounds very cool.
This program explains how the use cases should go in the presenter class; with the presenter class accessing a model class and a view class via interfaces

For example use case "When the user clicks load, the data loads into the grid " would get expressed by presenter calling both the model and the view via interfaces,

However from my earlier learning - I thought the use cases were meant to go in the work item.. Has there been a change in guidance regarding this?