Posts Tagged ‘CAB SCSF’

Composite UI Application Block (CAB)

The Composite UI Application Block is a ready-to-use building block provided by the Microsoft patterns & practices group for creating complex, modularized smart client applications. This building block basically provides the following functionality:
1 Dynamically loading independent yet cooperating modules into a common shell
2 Event broker for loosely coupled communication between modules and parts of modules
3 Ready-to-use Command pattern implementation
4 Base classes for Model-View-Control (MVC) pattern implementations
5 Framework for pluggable infrastructure services ranging, such as authentication services, authorization services, module location, and module loading services

CAB is built for designing applications based on a use case¡Vdriven approach by clearly separating use case controller classes from views with their controller classes or presenter classes. Central client-side services can be added through the services infrastructure provided by CAB.

Major terms related to CAB that are important for architectural decisions.

A WorkItem is a class encapsulating logic for one dedicated use case. It can be seen as a use case controller that knows all the different aspects of a use case. As such, a WorkItem holds state for all parts involved in a use case, such as views necessary to display, or sub-use cases. Furthermore, it acts as an entry point into the use case (or one of its sub-use cases) it is responsible for.

Services encapsulate functionality that is common for the whole client application, for a specific module, or just for WorkItems within a certain hierarchy of WorkItems (for example, for sub-WorkItems of a specific parent WorkItem). Typical services are security services responsible for authentication or authorization or Web service agents encapsulating service communication and offline capability.

Multiple, logically related WorkItems can be summarized into a single unit of deployment. A module is an example of a unit of deployment. Configuration of CAB-based smart clients basically works on a module-level. Therefore, finding the right granularity for encapsulating WorkItems into modules is crucial.

The profile catalog is just a configuration that specifies which modules and services need to be loaded into the application. By default, the catalog is just an XML file that resides in the application directory. This XML file specifies which modules need to be loaded. By writing and registering a custom IModuleEnumerator class, you can override this behavior to get the catalog from another location, such as a Web service.

This is a general service provided by CAB, which is responsible for loading all the modules specified in a profile catalog. It just walks through the configuration of the profile catalog, tries to dynamically load the assembly specified in a catalog entry, and then tries to find a ModuleInit class within that assembly.

Each module consists of a ModuleInit class, which is responsible for loading all the services and WorkItems of a module.

Shell application
The Shell application is the primary application that is responsible for initializing the application. It is responsible for dynamically loading modules based on the configuration and launching the base services for the smart client application, in addition to starting the main form (Shell).

This is the main form of the application; it provides the user interface that is common to all dynamically loaded modules. The Shell always hosts the root WorkItem, which is the entry point into any other parts of the application, such as services, modules, and WorkItems that are created and registered by these modules.

A workspace is a control that is primarily responsible for holding and displaying user interface elements created by WorkItems. Usually workspaces are added to the Shell (or to other extensible views within your WorkItem hierarchy) and act as containers for parts of the UI that are going to be dynamically filled with UI items that are provided by WorkItems or sub-WorkItems. Any user control can be a workspace by implementing the IWorkspace interface. Out-of-the-box, CAB includes classic container controls as workspaces, such as a tabbed workspace.

UIExtensionSites are special placeholders for extending fixed parts of the Shell such as menus, tool strips or status strips. Unlike workspaces, they are intended to be used for parts of the UI, which should not be completely overridden by WorkItems; instead, they should just be extended (such as adding a new menu entry).

Command is a base class of CAB for implementing the Command pattern. CAB supports classic commands created manually or declarative commands by applying the [CommandHandler] attributes to the method; these attributes act as command handlers. You can register multiple invokers for one command

EventPublications are used by event publishers for loosely coupled events. An event publisher implements the event through .NET Framework events that are marked with the [EventPublication] attribute. Events are uniquely identified by event URIs (unique strings). Only subscribers using subscriptions with the same event URI will be notified by CAB. A subscriber needs to have a method with the same signature as the event used [EventPublication] and needs to be marked with the [EventSubscription] attribute.

EventSubscription is the opposite of EventPublication. Any class that wants to subscribe to an event with a specific event URI needs to implement an event handler that matches the method signature of the EventPublication. You must mark this event handler with the [EventSubscription] attribute and the publisher’s event URI (in the attribute’s constructor) and CAB makes sure that a subscriber will be notified each time a publisher raises an event with a matching event URI and method signature.

Model is the (client-side) business entity a WorkItem processes; for example, Customer, BankAccount, or Loan.

View is an ordinary .NET Framework user control that is responsible for presenting a part of or the whole model to the user and allowing the user to modify its contents through user interface controls. Typically, the view implements only UI logic; whereas the related client-business logic is implemented in the presenter/controller.

A SmartPart is a .NET Framework user control with the [SmartPart] attribute applied. Optionally, a SmartPart can implement the ISmartPartInfoProvider interface. As such, it provides additional information about itself, such as a caption or a description.

Controller is a class that implements the logic for modifying a model. One controller can modify a model presented by many views. Origin: Model-View-Controller

ObjectBuilder is a foundation component of CAB that acts as the factory for creating objects that require specific builder strategies to be created or that need features, such as automatic instantiation and initialization of dependant objects when creating instances. As such, the ObjectBuilder has a combined role as a factory, a dependency injection framework, and a builder strategy framework.

Dependency Injection
Dependency Injection is a pattern that allows a factory to automatically create or initialize properties or members of objects with dependant objects. ObjectBuilder provides this functionality.

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.

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.

ModuleController classes are introduced by the Smart Client Software Factory and are used for encapsulating a special WorkItem within a module taking on the role of a root WorkItem within a module. The default ModuleInit implementation of a module created with the Smart Client Software Factory automatically creates a WorkItem for a module named ModuleController. Therefore, the ModuleController is the primary entry point for all WorkItems provided by a module.

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.

Happy Coding…:)


Read Full Post »