ControlledWorkItem and WorkItemExtension

Topics: CAB & Smart Client Software Factory
Mar 1, 2006 at 11:02 AM
originally posted by: jdressel

I'd like to make a couple comments and ask a couple questions regarding the thoughts on the direction the ControlledWorkItem<TController>.

I see the value in separating the use case/business logic behavior (re: WorkItemController) from the containment behavior of the WorkItem. I think this is a positive step. I would like to share a couple thoughts on a similar decoupling approach I took before I had a detailed look at the SC-BAT. The decoupled implementation follows a pattern similar to the IWorkItemExension (and loosely the IWorkspace / IWorkspaceComposer) concept. I created a IControllableWorkItem<W> where T: Workitem. IControllableWorkItem is basically an IWorkItemController without the Run(). The base IControllableWorkItem<W> implementation is essentially the same as WorkItemExtension, except that the Type of WorkItem is generic, and hooks to all events are provided. We still need the case for inheritance because we would like to override InitializeServices() or OnBuiltUp(), this is the rationale for the generic type. The desire is to then extend IControllableWorkItem<W> via an IUserCaseInterface (eg. MyUseCase : ControllableWorkItem<WorkItem> , IMyUseCase). This way, we can test the use case behavior and allows us to mock it out when we have workitem dependencies. We can also continue to use our a common base TestableWorkItem in our tests.

To my questions...
Is there a preference to extend only when you need to extend? I've gone with the make all extensions present by default in my base ControlledWorkItem<W> class.

Having said that, I see similarities between the CAB's WorkItemExtension and the WorkItemController. In an abstract way, they appear to be able to serve the same purpose when it comes to separation of business and containment logic. If I assume for a moment that the practice is to follow a WorkItemController approach in coding of business logic, would SC-BAT guidance not advocate extending WorkItems, but rather advocate extending Controllers (your usecase), because you've left the containment, injection behavior to the WorkItem and the business logic is in a Controller so you extend Controllers, not WorkItems?