WorkItemController what is it for?

Topics: CAB & Smart Client Software Factory
Jun 25, 2007 at 1:18 PM
Hi,

I'm currently trying to grok the design ideas behind CAB & SCSF and I'm having a bit of trouble with the WorkItemController & ControlledWorkItem. Basically, I'm happy with splitting code between the View & Presenter, but I'm not how to split between Presenter & WorkItemController.

I get that the separation is so that the "containment" aspect of the WorkItem is separated out from any specific use-case logic, but I'm not sure what sort of logic should go in the WorkItemController, and how it should be accessed. Is the WorkItemController supposed to be used just for controlling WorkItem state, and not to provide other functions?

I'm presuming that the idea is that Presenter classes shouldn't be trying to get a reference to the WorkItemController, because the design forces you to do some pretty tightly coupled casting to ControlledWorkItem<T> to do this, which seems odd.

Maybe the WorkItemController should implement some interface and register itself as a service?

I'm confused :-(
Jun 26, 2007 at 1:26 PM
Edited Jun 26, 2007 at 1:26 PM
Hi swythan,

I found really useful when beginning SCSF the whitepaper available in SCSF’s homepage (http://msdn2.microsoft.com/en-us/library/aa480482.aspx). Here’s a quote from it that may be useful for getting the differences from WorkItemController and ControlledWorkItem:

WorkItemController:
A WorkItemController is a class introduced by the Smart Client Software Factory that encapsulates common initialization logic for a WorkItem. When creating WorkItems with SCSF, instead of directly inheriting from the WorkItem base class, you inherit from this class to get the added initialization logic.

ControlledWorkItem:
Again, this is a class introduced by the Smart Client Software Factory; it is a generic class for instantiating new WorkItems based on a WorkItemController. It launches the added initialization entry points provided by the WorkItemController for you.

Presenter:
Presenter is a class that implements the logic for one single SmartPart (view). The presenter is based on the Model-View-Presenter (MVP) pattern, which is basically a simplified variant of the Model-View-Controller (MVC) pattern. The big difference between MVP and MVC is that with MVP, the View is completely controlled by the presenter, whereas in the MVC, the controller and the model can update the view.


Hope it helps!

Luciano G. Panaro
http://staff.southworks.net/lpanaro
Jun 26, 2007 at 3:15 PM
Thanks for the reply.


I found really useful when beginning SCSF the whitepaper available in SCSF’s homepage (http://msdn2.microsoft.com/en-us/library/aa480482.aspx).


Yes, it's a very good paper. I've got it printed out & comb-bound on my desk. It's the first ime I've used the comb-binder in the 7 years I've worked here!


WorkItemController:
A WorkItemController is a class introduced by the Smart Client Software Factory that encapsulates common initialization logic for a WorkItem. When creating WorkItems with SCSF, instead of directly inheriting from the WorkItem base class, you inherit from this class to get the added initialization logic.


Ah! That's interesting, I'd missed that.

The important bit to me is "encapsulates common initialization logic for a WorkItem". Similar statements elsewhere seem not to include that critical word "initialization". If the WorkItemController is only intended for setting up the WorkItem state when it is first created (and perhaps in response to events), then I'm happy.

I've looked a bit more through the Bank Branch RI, as well, and the WorkItemControllers in there are all pretty empty, too.

Last week I was thinking that maybe the WI controllers were supposed to be somewhere that you put a lot more code. Now I'm getting that it's all supposed to go in Presenters and Services.

Thanks again,

James