Title: Practical Implementation of Composite Smart Clients with CAB and SCSF
1Practical Implementation of Composite Smart
Clients with CAB and SCSF
- Kurt Claeys.NET Architect ORDINA Belgium
- www.n-technologies.be
2Abstract
- This session demonstrates the concept of the
composite UI pattern and the implementation of it
by using the Composite UI Application Block and
Smart Client Software Factory and is focused on
the task of the developer/architect to separate
the responsibilities of the UI from business
logic handling behavior. By integrating code
generation into Visual Studio 2005 through the
Guidance Automation Toolkit and delivering
guidelines in design patterns CAB/SCSF allows to
build Smart Clients where UI and logic are
loosely coupled. CAB and SCSF, as part of the
Microsoft Patterns Practices development tools
and architecture guidance, are the foundation for
building Enterprise Application enabled User
Interfaces.
3Session not about ...
- ClickOnce deployment
- Mobile/PDA
- Atlas/Ajax
- Offline caching
- WPF, WPF/E
- Cabinet files
4Agenda
- Composite Smart Clients ?
- Composite UI Application Block (CAB)
- Demo Hello World of CAB
- CodeReview
- BankTeller demo (working with modules)
- Smart Client Software Factory (SCSF)
- Demo SCSF
- QA
5Real World Example
6Typical about Smart Clients ?
- Rich user interface (maybe WPF)
- Use local resources
- Exchanging information with services
- Have Complex infrastructure Logic
- Tailor Made
- Intelligent deployment (maybe ClickOnce)
- Windows (forms) based
7Composite ?
- Modular
- Integrated Desktops
- Hosting different types of applications
- Integration between applicationsparts
- Common way of working
Modules (plug-ins) integrated within a common
host environment
8Composite UI Application Block
- Microsoft Patterns Practices
- Dynamically loading modules into a common shell
- Supports the composition pattern
- Event-Broker, loosely coupled communication
- Base classes for MVC/MVP implementation
- Framework for pluggable infrastructure services
9Patterns Practices
http//msdn.microsoft.com/practices
10Goals
- Allow parts of the UI to communicate with one
another but dont introduce too much
dependencies. - Separation of Concerns each developer
concentrates on a specific task. - Architectural Framework for a consistent, high
quality desktop, development. - Increase productivity, reduce overall development
time. - Separate shell logic, infrastructure components
and business logic.
11Modules
Smart Client Module A
Service X
Smart Client Module B
Service Y
Users
Application
Smart Client Module C
Service Z
12Example
13Framework
Business Logic
Plug In
Your Infrastructure Services
Composite UI Application Block
14Composite UI Patterns Overview
Shell Services
Workspaces
Strategy presenters for UI
UI Extension Sites
Command
View
View
Commands
MVC
Activation
SPInfo
Controller
Presenter
MVP
Core Services
Event Broker
Pub/Sub
WorkItem
State
State Persistence
Model
Model
Blackboard
CAB Application
Workflow
Use Case Controller
Crypto
Extension
Instrum
Lifetime Container
Service Locator
ObjectBuilder
Module Loading
Enumerator
Loader
AuthN
Builder
Factory
Injection
Plugins
15Model View Controller
Calls
Manipulates
16Model View Presenter
Passes Calls to
Updates
Presenter
Fires Events
Manipulates
17CAB Terms
- ShellForm (hosts the plug-ins)
- Workspace
- UIExtensionSite
- Module (plug in)
- Workitem (a use case)
- ModuleControler ( root WorkItem)
- SmartPart (UserControl)
- Controller
- Service
- Commands
- Events
18Workitem
- Run-time container for components
- Component can be visual (smartparts)
- Component be services (supporting class that
provides funcionality to other components) - A Workitems own the components and has
properties to access them. - Workitem must be run.
- Can be actived/deactivated as required.
- Can be seen as a Use Case.
19Workitem Hierarchy
20Events
Subscribers
Publishers
- Components can use events to publish or receive
notifications. - Publishers and Subscribers agree on
- Topic (identified by a URI)
- Message (in case a special EventArgs is required)
- Publishers set scope of event
- Subscribers have control over the thread in which
they process the call - Background (For long-running work)
- UI Thread (to update UI controls on appropriate
thread) - Publisher (on same thread as publisher)
21Loading Modules
- Load modules when the application starts
- Uses an XML catalog file to determine the modules
to load
lt?xml version"1.0" encoding"utf-8"
?gt ltSolutionProfile xmlns"http//schemas.microsof
t.com/pag/cab-profile" gt ltModulesgt
ltModuleInfo AssemblyFile"GlobalBank.AppraiserWork
bench.AppraiserWorkbenchModule.dll" /gt
lt/Modulesgt lt/SolutionProfilegt
22How Does this all work ?
Shell
UI Extension Site
View
UI Extension Site
View
Work Item Shared State Shared Events
Element
Element
Module
Module Catalog
23Hello World Of CAB
24Developer issues
- Based on EntLib and CAB
- Patterns !
- New statement not used (factory)
- Type or Interface based references
- No project references (loosely coupled)
- Declarative way of working with attributes
- Code generation with SCSF
- Use of generics
- Modulebased architecture
- Configuration by ProfileCatalog.xml
25SmartPart
Form
Has a DeckWorkspace called placeholder
WorkItem
MyUserControl mUC SmartParts.AddNewltMyUserContro
lgt() Workspaces"placeholder".Show(m
UC)
SmartPart
SmartPart public partial class MyUserControl
UserControl
26UIExtensionSite
FormShellApplication
protected override void AfterShellCreated()
base.AfterShellCreated() RootWorkItem.UIExten
sionSites.RegisterSite("MainMenu",
Shell.MainMenuStrip)
WorkItem
ToolStripMenuItem menuItem new
ToolStripMenuItem("WorkItem") UIExtensionSites"M
ainMenu".Add(menuItem)
27Commands
FormShellApplication
ToolStripMenuItem menuItem new
ToolStripMenuItem("WorkItem") UIExtensionSites"M
ainMenu".Add(menuItem)Commands"DoSomething".A
ddInvoker(menuItem, "Click")
Controller
CommandHandler("DoSomething") public void
OnAction(object sender, EventArgs args)
//Implementation
28Services
Service
Service public class MyService public
string GiveMeData() //Implementation
Controller
ServiceDependency public MyService MyService
set myService value
myService.GiveMeData()
29Events
Controller
EventSubscription("topic//WindowsApplication/Eve
nt" public void OnEvent(object sender,
DataEventArgsltstringgt e)
Shell
EventSubscription("topic//WindowsApplication/Eve
nt" public void OnEvent(object sender,
DataEventArgsltstringgt e)
UserControl
EventPublication("topic//WindowsApplication/Even
t") public event EventHandlerltDataEventArgsltstrin
ggtgt MyEvent
MyEvent(this, new DataEventArgsltstringgt("TEST"))
30Controllers
UserControl
CreateNew public MyController Controller
get return controller set
controller value
Controller
public class MyController Controller //Implem
entation...
31Modules
ModuleInit
public class MyModuleInit ModuleInit public
override void Load()
base.Load() MyWorkItem mWV
rootWorkItem.WorkItems.AddNewltMyWorkItemgt()
mWV.Run()
ProfileCatalog.xml
lt?xml version"1.0" encoding"utf-8"
?gt ltSolutionProfile xmlns"http//schemas.microsof
t.com/pag/cab-profile" gt ltModulesgt
ltModuleInfo AssemblyFile"Module.dll"/gt
lt/Modulesgt lt/SolutionProfilegt
32BankTeller Application
33Smart Client Software Factory
- Proven and integrated practices
- Exposed trough patterns
- Reusable code components
- Reference Implementation
- Wizards
- Code generations
- Visual Designers
34SCSF - VS2005 Integration
35SCSF
36(No Transcript)
37Resources
- http//msdn2.microsoft.com/en-us/library/bb266334.
aspx - http//www.microsoft.com/downloads/details.aspx?Fa
milyID5f9a8435-1651-4be2-956d-0446a89a7358displa
ylangenModel View Controller/Presenter Pattern - http//msdn2.microsoft.com/en-us/library/aa480450.
aspx - http//msdn2.microsoft.com/en-us/library/aa546409.
aspx - http//msdn2.microsoft.com/en-us/library/aa480482.
aspx
38(No Transcript)