Thursday, March 08, 2007

So What's a WorkItem?

Probably the largest single piece that you need to understand about CAB is the WorkItem.

As I mentioned before, WorkItems are usually 1:1 with use cases.  For example, say we are buiding a CRM product, we might have a use case called “Edit Customer.”  This would map to an EditCustomerWorkItem.

Think of the WorkItem as a container for anything related to the use case.  It can house various elements such as UI components, state, services, etc.  This gives you a nice boundary for when things get instantiated or destructed.

WorkItems live inside of modules, and are instantiated by the ModuleInit class.

So say, given the example above, we have loaded our CustomerInformationModule, which contains an EditCustomerWorkItem.  The workitem might contain:

  • A reference to a customer object, or customer id
  • A service used to retrieve/save the customer
  • A controller for implementing UI logic and interacting with our customer object
  • A view (control) that displays the various controls necessary to complete the use case.  It might have some textboxes, a Save button and a Delete button.

If you don’t do your use case homework, your work items will “go against the grain” of the application and add unnecessary complexity to the whole framework.  Do your use case work up front, and you’ll be designing better WorkItems.

Comments are closed.
Loans - Credit Card - Personal Loans - Debt Loans