SlideShare uma empresa Scribd logo
1 de 30
Composite Application Guidance
      An Introduction..
Introduction to Composite
Application Guidance aka “Prism”
  Building Silverlight and WPF applications with
      Composite Applications Guidance and
          Composite Application Library

                         Don Burnett

                         http://blog.donburnett.com
Prism is compliant with your development process

• design patterns like Model-   • Code-Behind minimalist
  View-View Model and           • Modular, Composite
  Model-View-Presenter            Application
• Test-Driven Development       • Distributed Agile Team
  (TDD)                         • Fluent Interfaces
• Loosely Coupled               • Multi-Targeting Silverlight
• Separation of Concerns          and WPF
  (SoC)                         • Routed Commands &
• Interface-based                 Routed Events
  Programming                   • High Performance Dev
• Dependency Injection (DI)     • Data Binding
• Inversion of Control (IoC)
  Containers
Topics
• Targeting Silverlight or WPF
  – Managing complexity
  – Best practices for testing and design
    patterns
• Focus around UI concerns
  – XAML, Code-behinds, Data Binding
• Using Prism
  – Runtime Library + Guidance + Project Linker
Related Technologies
• Windows Presentation Foundation
  (WPF), Silverlight, XAML
• Unit Testing (nUnit), TDD
• Dependency Injection (DI), Inversion
  of Control (IoC), Loose coupling
• UI Design Patterns (MVC, MVP)
Goals
• Appreciate value of C-A-G for Silverlight and
  WPF
• Demonstrate a few key Prism concepts
• A little WPF, Silverlight; discuss a couple of
  Design Patterns / Anti-Patterns
Terminology
• Composite Application Guidance for
  WPF and Silverlight Version 2
• Composite Application Library for WPF
  and Silverlight  runtime support
  included – sometimes called “CAL”
Composite Applications
    Guidance v2
 Patterns & Practices Group
  microsoft.com/patterns
• Long development
                                 cycles
    Product Groups             • Strategic
                               • Big Teams
                               • Costs
                               • Support

   Patterns & Practice Group
                               • Rapid cycle times
                               • Small, focused agile teams
                               • Ship tactical solutions now
• EntLib, Unity, Arch Guide       – Code and Guidance
• CAB, Prism v1, Prism v2      • Open Source
                               • Legacy free
Composite Applications Key
        Concepts
Shell, Regions, Views
•   Shell is main window for applications
•   Shell defines (visual) Regions
•   Regions control where UI will appear -dynamic
•   Views are displayed within a region

• WPF/Silverlight design, code, tooling is
  complimentary – Composite Application
  Guidance brings it together
Views and Modules
• Modules are DLLs (Projects)
• You can decide which modules to load
• Modules can be configured to load code, XML,
  or XAML
• Modules can be downloaded
  – Can write your own rules for loading
• Modules have Views (usually)
Events
• .NET events are tightly coupled (references in
  both directions)
• WPF events
  – Loosely coupled and limited to same visual tree
• Composite events
  – Loose coupling; not limited to same visual tree
• More: Force to UI thread; event filtering
• Events are triggered through commanding.
CAG/Prism Conventions
•   Bootstrapper
•   Shell
•   One module per DLL
•   M-V-VM pattern
Why Separate UI from Code?
• Improves Developer / Designer interaction
• Develop in Visual Studio and Design in Expression
  Blend
• Easier Testing- now possible to Unit Test (vs.
  Integration Test)
   – Simpler issue of isolation
• Reuse opportunity goes way up
   – Same ViewModel can be reused with UI variations
• Better organized code is easier to understand and
  maintain. SE Principles: SoC, coupling, cohesion, SRP
  (rendering, mouse & keyboard, disabled, hover)
How to Separate Concerns in UI?
• Use Code-Behinds reluctantly + M-V-VM
• M-V-VM Model-View-ViewModel Pattern
• Abbreviated as M-V-VM, MVVM
• Referred to as ViewModel
• Presentation Model pattern where View knows
  about ViewModel
• Documentation refers to it as Presentation
  Model
• ViewModel pattern is the more common term.
Advantages
Commanding also spans View & ViewModel
No UI in VM

MVP is a delegation model – MVVM handles
this with data binding – way less code in the
code-behind

Silverlight controls don’t automatically
implement Icommand so this is extremely
useful.
ViewModel Pattern
                                           Load external data
                                           from web services,
                                           etc.


View    Data Binding       ViewModel    Your Code   Model



       Supported by WPF / SL


                                   C-A-G provides an
                                   Automapper to smartly
                                   map your data to the view.
Code-Behind Pattern (Old Way)
                                                  Load external data
                                                  from web services,
                                                  etc.


           View                Observable Collections/Code   Model

Code Behind for each Control
 Supported by WPF / SL
Prism Still In the Wild
• You build it
• Microsoft Patterns and Practice does not ship
  a binary at this time.
• No Prism-specific templates for Visual Studio
  (YET!)
• Cannot unload a Module.. Choose what you
  load WISELY..
When to go Composite?
• You are designing “complex” WPF or
  Silverlight applications, helpful in Line of
  Business situations.
• You are building an application that presents
  information from multiple sources through an
  integrated user interface.
• You are developing, testing, and deploying
  modules independently of other modules.
When to go Composite?
• Your application will add more views and more
  functionality over the coming years, or…
• You must be able to change the app quickly and
  safely to meet emergent business requirements,
  or…
• Your application is being developed by multiple
  collaborating teams; or…
• Your application targets both WPF and Silverlight,
  and you want to maximize code sharing between
  platforms.
When to NOT go Composite?
• Your applications do not require any of the
  above scenarios.
• Your application consists of a few simple
  screens.
• You are prototyping.
• Your developers do not have the time to learn
  about Composite Application Guidance.
Advantages
• SoC + SRP + reducing plumbing code + Unit Tests
  is the best way to handle complexity and enable
  ability to respond rapidly to changing
  requirements.
• M-V-VM  best design/development pattern to
  support application development in Silverlight
  and WPF.
Official Site
http://microsoft.com/compositewpf
             -- or --
http://codeplex.com/compositewpf
Watch these spaces
• “Contrib” site @
  http://compositewpfcontrib.codeplex.com/
• Channel 9 for tutorial videos
  – http://channel9.msdn.com/tags/Prism/
• Infragistics control adapters for Prism @
  http://ncal.codeplex.com/
  – Region Adaptors for Prism
Prism v2 References
• http://www.microsoft.com/downloads/details.aspx?FamilyI
  D=fa07e1ce-ca3f-4b9b-a21b-
  e3fa10d013dd&DisplayLang=en
• http://blogs.msdn.com/jmeier/archive/2009/02/18/new-
  release-composite-application-guidance-for-wpf-and-
  silverlight-v2-0-prism.aspx
• http://timheuer.com/blog/archive/2009/02/18/prism-2-
  released-composite-guidance-for-silverlight-lob.aspx
• http://msdnrss.thecoderblogs.com/2009/02/18/composite-
  application-guidance-for-wpf-and-silverlight-v20-prism/
Other Resources
• Josh Smith on MVVM with WPF:
  http://msdn.microsoft.com/en-
  us/magazine/dd419663.aspx
• Brian Noyes on Understanding Routed Events and Routed
  Commands in WPF: http://msdn.microsoft.com/en-
  us/magazine/cc785480.aspx
• WPF Commanding Overview:
  http://msdn.microsoft.com/en-us/library/ms752308.aspx
• Martin Fowler’s description of Presentation Model pattern:
  http://martinfowler.com/eaaDev/PresentationModel.html
• XAML Guidelines for Creating a Composite UI:
  http://msdn.microsoft.com/en-us/library/dd458877.aspx
Thanks for Attending..

Building Silverlight and WPF applications with
    Composite Applications Guidance and
        Composite Application Library

                       Don Burnett

                       http://blog.donburnett.com
Composite Application Guidance
      An Introduction..

Mais conteúdo relacionado

Destaque

Destaque (9)

Research Skills
Research SkillsResearch Skills
Research Skills
 
Kalmanfilter
Kalmanfilter Kalmanfilter
Kalmanfilter
 
Historia
HistoriaHistoria
Historia
 
Knowledge Modeling in Various applications in Traffic Systems
Knowledge Modeling in Various applications in Traffic SystemsKnowledge Modeling in Various applications in Traffic Systems
Knowledge Modeling in Various applications in Traffic Systems
 
In de weerd presentatie social media
In de weerd presentatie social mediaIn de weerd presentatie social media
In de weerd presentatie social media
 
Hype task 2015 in pics
Hype task 2015 in picsHype task 2015 in pics
Hype task 2015 in pics
 
IIT JEE Maths 1985
IIT JEE Maths   1985IIT JEE Maths   1985
IIT JEE Maths 1985
 
Slides of Cluana Webinar
Slides of Cluana WebinarSlides of Cluana Webinar
Slides of Cluana Webinar
 
Actividad 6
Actividad 6Actividad 6
Actividad 6
 

Mais de Our Community Exchange LLC

Mais de Our Community Exchange LLC (11)

Real Time Connected Vehicle Networking with HDInsight and Apache Storm
Real Time Connected Vehicle Networking with HDInsight and Apache StormReal Time Connected Vehicle Networking with HDInsight and Apache Storm
Real Time Connected Vehicle Networking with HDInsight and Apache Storm
 
2012 Updated Portfolio
2012 Updated Portfolio2012 Updated Portfolio
2012 Updated Portfolio
 
Roi and user experience
Roi and user experienceRoi and user experience
Roi and user experience
 
I phone versus windows phone 7 coding
I phone versus windows phone 7 codingI phone versus windows phone 7 coding
I phone versus windows phone 7 coding
 
U Xmagic Agile Presentation
U Xmagic Agile PresentationU Xmagic Agile Presentation
U Xmagic Agile Presentation
 
Porting the Legacy Application to Composite Application Guidance
Porting the Legacy Application to Composite Application GuidancePorting the Legacy Application to Composite Application Guidance
Porting the Legacy Application to Composite Application Guidance
 
WPF Line of Business Control Templates Styles
WPF Line of Business Control Templates StylesWPF Line of Business Control Templates Styles
WPF Line of Business Control Templates Styles
 
WPF Fundamentals
WPF FundamentalsWPF Fundamentals
WPF Fundamentals
 
WPF Line of Business Application XAML Layouts Presentation
WPF Line of Business Application XAML Layouts PresentationWPF Line of Business Application XAML Layouts Presentation
WPF Line of Business Application XAML Layouts Presentation
 
Wpf Tech Overview2009
Wpf Tech Overview2009Wpf Tech Overview2009
Wpf Tech Overview2009
 
New Introductionfor Flash Designers
New Introductionfor Flash DesignersNew Introductionfor Flash Designers
New Introductionfor Flash Designers
 

Último

Dubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai DouxDubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai Douxkojalkojal131
 
Design Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptxDesign Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptxTusharBahuguna2
 
The Art of Batik, template ppt aesthetic
The Art of Batik, template ppt aestheticThe Art of Batik, template ppt aesthetic
The Art of Batik, template ppt aestheticTiaFebriani
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...Pooja Nehwal
 
Tapestry Clothing Brands: Collapsing the Funnel
Tapestry Clothing Brands: Collapsing the FunnelTapestry Clothing Brands: Collapsing the Funnel
Tapestry Clothing Brands: Collapsing the Funneljen_giacalone
 
The history of music videos a level presentation
The history of music videos a level presentationThe history of music videos a level presentation
The history of music videos a level presentationamedia6
 
CBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call Girls
CBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call GirlsCBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call Girls
CBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call Girlsmodelanjalisharma4
 
Editorial design Magazine design project.pdf
Editorial design Magazine design project.pdfEditorial design Magazine design project.pdf
Editorial design Magazine design project.pdftbatkhuu1
 
Delhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
WAEC Carpentry and Joinery Past Questions
WAEC Carpentry and Joinery Past QuestionsWAEC Carpentry and Joinery Past Questions
WAEC Carpentry and Joinery Past QuestionsCharles Obaleagbon
 
Booking open Available Pune Call Girls Kirkatwadi 6297143586 Call Hot Indian...
Booking open Available Pune Call Girls Kirkatwadi  6297143586 Call Hot Indian...Booking open Available Pune Call Girls Kirkatwadi  6297143586 Call Hot Indian...
Booking open Available Pune Call Girls Kirkatwadi 6297143586 Call Hot Indian...Call Girls in Nagpur High Profile
 
VVIP Pune Call Girls Dange Chowk (8250192130) Pune Escorts Nearby with Comple...
VVIP Pune Call Girls Dange Chowk (8250192130) Pune Escorts Nearby with Comple...VVIP Pune Call Girls Dange Chowk (8250192130) Pune Escorts Nearby with Comple...
VVIP Pune Call Girls Dange Chowk (8250192130) Pune Escorts Nearby with Comple...Call Girls in Nagpur High Profile
 
Call Girls in Kalkaji Delhi 8264348440 call girls ❤️
Call Girls in Kalkaji Delhi 8264348440 call girls ❤️Call Girls in Kalkaji Delhi 8264348440 call girls ❤️
Call Girls in Kalkaji Delhi 8264348440 call girls ❤️soniya singh
 
Booking open Available Pune Call Girls Nanded City 6297143586 Call Hot India...
Booking open Available Pune Call Girls Nanded City  6297143586 Call Hot India...Booking open Available Pune Call Girls Nanded City  6297143586 Call Hot India...
Booking open Available Pune Call Girls Nanded City 6297143586 Call Hot India...Call Girls in Nagpur High Profile
 
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service 🧵
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  🧵CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  🧵
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service 🧵anilsa9823
 
Top Rated Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated  Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Top Rated  Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Call Girls in Nagpur High Profile
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...Pooja Nehwal
 
Kurla Call Girls Pooja Nehwal📞 9892124323 ✅ Vashi Call Service Available Nea...
Kurla Call Girls Pooja Nehwal📞 9892124323 ✅  Vashi Call Service Available Nea...Kurla Call Girls Pooja Nehwal📞 9892124323 ✅  Vashi Call Service Available Nea...
Kurla Call Girls Pooja Nehwal📞 9892124323 ✅ Vashi Call Service Available Nea...Pooja Nehwal
 
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...ranjana rawat
 

Último (20)

Dubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai DouxDubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
 
Design Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptxDesign Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptx
 
The Art of Batik, template ppt aesthetic
The Art of Batik, template ppt aestheticThe Art of Batik, template ppt aesthetic
The Art of Batik, template ppt aesthetic
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...
 
Tapestry Clothing Brands: Collapsing the Funnel
Tapestry Clothing Brands: Collapsing the FunnelTapestry Clothing Brands: Collapsing the Funnel
Tapestry Clothing Brands: Collapsing the Funnel
 
The history of music videos a level presentation
The history of music videos a level presentationThe history of music videos a level presentation
The history of music videos a level presentation
 
CBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call Girls
CBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call GirlsCBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call Girls
CBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call Girls
 
Editorial design Magazine design project.pdf
Editorial design Magazine design project.pdfEditorial design Magazine design project.pdf
Editorial design Magazine design project.pdf
 
Delhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
WAEC Carpentry and Joinery Past Questions
WAEC Carpentry and Joinery Past QuestionsWAEC Carpentry and Joinery Past Questions
WAEC Carpentry and Joinery Past Questions
 
Booking open Available Pune Call Girls Kirkatwadi 6297143586 Call Hot Indian...
Booking open Available Pune Call Girls Kirkatwadi  6297143586 Call Hot Indian...Booking open Available Pune Call Girls Kirkatwadi  6297143586 Call Hot Indian...
Booking open Available Pune Call Girls Kirkatwadi 6297143586 Call Hot Indian...
 
Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance VVIP 🍎 SER...
Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance  VVIP 🍎 SER...Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance  VVIP 🍎 SER...
Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance VVIP 🍎 SER...
 
VVIP Pune Call Girls Dange Chowk (8250192130) Pune Escorts Nearby with Comple...
VVIP Pune Call Girls Dange Chowk (8250192130) Pune Escorts Nearby with Comple...VVIP Pune Call Girls Dange Chowk (8250192130) Pune Escorts Nearby with Comple...
VVIP Pune Call Girls Dange Chowk (8250192130) Pune Escorts Nearby with Comple...
 
Call Girls in Kalkaji Delhi 8264348440 call girls ❤️
Call Girls in Kalkaji Delhi 8264348440 call girls ❤️Call Girls in Kalkaji Delhi 8264348440 call girls ❤️
Call Girls in Kalkaji Delhi 8264348440 call girls ❤️
 
Booking open Available Pune Call Girls Nanded City 6297143586 Call Hot India...
Booking open Available Pune Call Girls Nanded City  6297143586 Call Hot India...Booking open Available Pune Call Girls Nanded City  6297143586 Call Hot India...
Booking open Available Pune Call Girls Nanded City 6297143586 Call Hot India...
 
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service 🧵
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  🧵CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  🧵
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service 🧵
 
Top Rated Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated  Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Top Rated  Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...
 
Kurla Call Girls Pooja Nehwal📞 9892124323 ✅ Vashi Call Service Available Nea...
Kurla Call Girls Pooja Nehwal📞 9892124323 ✅  Vashi Call Service Available Nea...Kurla Call Girls Pooja Nehwal📞 9892124323 ✅  Vashi Call Service Available Nea...
Kurla Call Girls Pooja Nehwal📞 9892124323 ✅ Vashi Call Service Available Nea...
 
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
 

Ca Gv2 Uxmagic Presentation

  • 1. Composite Application Guidance An Introduction..
  • 2. Introduction to Composite Application Guidance aka “Prism” Building Silverlight and WPF applications with Composite Applications Guidance and Composite Application Library Don Burnett http://blog.donburnett.com
  • 3. Prism is compliant with your development process • design patterns like Model- • Code-Behind minimalist View-View Model and • Modular, Composite Model-View-Presenter Application • Test-Driven Development • Distributed Agile Team (TDD) • Fluent Interfaces • Loosely Coupled • Multi-Targeting Silverlight • Separation of Concerns and WPF (SoC) • Routed Commands & • Interface-based Routed Events Programming • High Performance Dev • Dependency Injection (DI) • Data Binding • Inversion of Control (IoC) Containers
  • 4. Topics • Targeting Silverlight or WPF – Managing complexity – Best practices for testing and design patterns • Focus around UI concerns – XAML, Code-behinds, Data Binding • Using Prism – Runtime Library + Guidance + Project Linker
  • 5. Related Technologies • Windows Presentation Foundation (WPF), Silverlight, XAML • Unit Testing (nUnit), TDD • Dependency Injection (DI), Inversion of Control (IoC), Loose coupling • UI Design Patterns (MVC, MVP)
  • 6. Goals • Appreciate value of C-A-G for Silverlight and WPF • Demonstrate a few key Prism concepts • A little WPF, Silverlight; discuss a couple of Design Patterns / Anti-Patterns
  • 7. Terminology • Composite Application Guidance for WPF and Silverlight Version 2 • Composite Application Library for WPF and Silverlight  runtime support included – sometimes called “CAL”
  • 8. Composite Applications Guidance v2 Patterns & Practices Group microsoft.com/patterns
  • 9. • Long development cycles Product Groups • Strategic • Big Teams • Costs • Support Patterns & Practice Group • Rapid cycle times • Small, focused agile teams • Ship tactical solutions now • EntLib, Unity, Arch Guide – Code and Guidance • CAB, Prism v1, Prism v2 • Open Source • Legacy free
  • 11. Shell, Regions, Views • Shell is main window for applications • Shell defines (visual) Regions • Regions control where UI will appear -dynamic • Views are displayed within a region • WPF/Silverlight design, code, tooling is complimentary – Composite Application Guidance brings it together
  • 12. Views and Modules • Modules are DLLs (Projects) • You can decide which modules to load • Modules can be configured to load code, XML, or XAML • Modules can be downloaded – Can write your own rules for loading • Modules have Views (usually)
  • 13. Events • .NET events are tightly coupled (references in both directions) • WPF events – Loosely coupled and limited to same visual tree • Composite events – Loose coupling; not limited to same visual tree • More: Force to UI thread; event filtering • Events are triggered through commanding.
  • 14. CAG/Prism Conventions • Bootstrapper • Shell • One module per DLL • M-V-VM pattern
  • 15. Why Separate UI from Code? • Improves Developer / Designer interaction • Develop in Visual Studio and Design in Expression Blend • Easier Testing- now possible to Unit Test (vs. Integration Test) – Simpler issue of isolation • Reuse opportunity goes way up – Same ViewModel can be reused with UI variations • Better organized code is easier to understand and maintain. SE Principles: SoC, coupling, cohesion, SRP (rendering, mouse & keyboard, disabled, hover)
  • 16. How to Separate Concerns in UI? • Use Code-Behinds reluctantly + M-V-VM • M-V-VM Model-View-ViewModel Pattern • Abbreviated as M-V-VM, MVVM • Referred to as ViewModel • Presentation Model pattern where View knows about ViewModel • Documentation refers to it as Presentation Model • ViewModel pattern is the more common term.
  • 17. Advantages Commanding also spans View & ViewModel No UI in VM MVP is a delegation model – MVVM handles this with data binding – way less code in the code-behind Silverlight controls don’t automatically implement Icommand so this is extremely useful.
  • 18. ViewModel Pattern Load external data from web services, etc. View Data Binding ViewModel Your Code Model Supported by WPF / SL C-A-G provides an Automapper to smartly map your data to the view.
  • 19. Code-Behind Pattern (Old Way) Load external data from web services, etc. View Observable Collections/Code Model Code Behind for each Control Supported by WPF / SL
  • 20. Prism Still In the Wild • You build it • Microsoft Patterns and Practice does not ship a binary at this time. • No Prism-specific templates for Visual Studio (YET!) • Cannot unload a Module.. Choose what you load WISELY..
  • 21. When to go Composite? • You are designing “complex” WPF or Silverlight applications, helpful in Line of Business situations. • You are building an application that presents information from multiple sources through an integrated user interface. • You are developing, testing, and deploying modules independently of other modules.
  • 22. When to go Composite? • Your application will add more views and more functionality over the coming years, or… • You must be able to change the app quickly and safely to meet emergent business requirements, or… • Your application is being developed by multiple collaborating teams; or… • Your application targets both WPF and Silverlight, and you want to maximize code sharing between platforms.
  • 23. When to NOT go Composite? • Your applications do not require any of the above scenarios. • Your application consists of a few simple screens. • You are prototyping. • Your developers do not have the time to learn about Composite Application Guidance.
  • 24. Advantages • SoC + SRP + reducing plumbing code + Unit Tests is the best way to handle complexity and enable ability to respond rapidly to changing requirements. • M-V-VM  best design/development pattern to support application development in Silverlight and WPF.
  • 25. Official Site http://microsoft.com/compositewpf -- or -- http://codeplex.com/compositewpf
  • 26. Watch these spaces • “Contrib” site @ http://compositewpfcontrib.codeplex.com/ • Channel 9 for tutorial videos – http://channel9.msdn.com/tags/Prism/ • Infragistics control adapters for Prism @ http://ncal.codeplex.com/ – Region Adaptors for Prism
  • 27. Prism v2 References • http://www.microsoft.com/downloads/details.aspx?FamilyI D=fa07e1ce-ca3f-4b9b-a21b- e3fa10d013dd&DisplayLang=en • http://blogs.msdn.com/jmeier/archive/2009/02/18/new- release-composite-application-guidance-for-wpf-and- silverlight-v2-0-prism.aspx • http://timheuer.com/blog/archive/2009/02/18/prism-2- released-composite-guidance-for-silverlight-lob.aspx • http://msdnrss.thecoderblogs.com/2009/02/18/composite- application-guidance-for-wpf-and-silverlight-v20-prism/
  • 28. Other Resources • Josh Smith on MVVM with WPF: http://msdn.microsoft.com/en- us/magazine/dd419663.aspx • Brian Noyes on Understanding Routed Events and Routed Commands in WPF: http://msdn.microsoft.com/en- us/magazine/cc785480.aspx • WPF Commanding Overview: http://msdn.microsoft.com/en-us/library/ms752308.aspx • Martin Fowler’s description of Presentation Model pattern: http://martinfowler.com/eaaDev/PresentationModel.html • XAML Guidelines for Creating a Composite UI: http://msdn.microsoft.com/en-us/library/dd458877.aspx
  • 29. Thanks for Attending.. Building Silverlight and WPF applications with Composite Applications Guidance and Composite Application Library Don Burnett http://blog.donburnett.com
  • 30. Composite Application Guidance An Introduction..