1 / 39

SharePoint 2010 Patterns & Practices

SharePoint 2010 Patterns & Practices. Serge Luca http://redwood.be Karine Bosch http://karinebosch.wordpress.com. Audience. Audience : SharePoint developers & architects Level : 300. Topics. Introduction to SharePoint Patterns and Practices Guidance (SPG)

kert
Download Presentation

SharePoint 2010 Patterns & Practices

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SharePoint 2010 Patterns & Practices Serge Luca http://redwood.be Karine Bosch http://karinebosch.wordpress.com

  2. Audience • Audience : SharePoint developers & architects • Level : 300

  3. Topics • Introduction to SharePoint Patterns and Practices Guidance (SPG) • Main Patterns covered by the SPG • Reusable libraries • Application Lifecycle Management for SharePoint 2010 • Unit testing with Pex & Moles • Conclusions

  4. Topics • Introduction to SharePoint Patterns and Practices Guidance (SPG) • Patterns covered by the SPG • Reusable libraries • Application Lifecycle Management for SharePoint 2010 • Unit testing with Pex & Moles • Conclusions

  5. Introduction to SharePoint 2010 Patterns and Practices Guidance (SPG) • Team for Microsoft and others (MDSN & CodePlex) • Provides: • Guidance & documentation • Patterns & reference implementations • Reusable Libraries • Discussions lists • Hands –on Labs

  6. (Coding)Challenges when creating enterprise applications • Testability • Can you isolate your classes • Flexibility • Can you update or replace code without recompiling • Configuration • How do you manage configuration settings ? Scalability ? • Logging and Exception handling • How do you log ? Consistent across the team • Maintainability • How can you maintain code that is always evolving • Can your code run in the Cloud? (Office 365 & the Sandbox) • Without Full trust proxy

  7. Topics • Introduction to SharePoint Patterns and Practices Guidance (SPG) • Patterns covered by the SPG • Reusable libraries • Application Lifecycle Management for SharePoint 2010 • Unit testing with Pex & Moles • Conclusions

  8. Patterns covered by the SPG • Mains patterns illustrated (with reference applications in the SPG) • Service Locator pattern • MVP pattern (Model View Presenter) • Repository pattern • MVVM pattern (Model View View Model)

  9. The Service Locator Pattern Uses Service A Class A Uses Service B Locates Service A Uses Locator Class A Service B Locates

  10. The Service Locator Pattern

  11. MVP (Model View Presenter) pattern View Presenter Model

  12. The MVP Pattern

  13. The Repository pattern Business Entity Client Business Logic Your SharePoint Lists + other storages… ? ? Your list repository Business Entity

  14. Choosing a SharePoint Data Access Technology REST APIs Strongly-typed ClientOM Weakly-typed Client-side Data Platform Farm Site List Data External Lists ServerOM Server-side Weakly-typed LINQ New in 2010 Improved Strongly-typed

  15. The Repository Pattern

  16. Linq To SharePoint DSL extension • To automatically generate a Repository, you can try Linq To SharePoint DSL Extension from Olivier Carpentier (MCS France)

  17. MVVM (Model View ViewModel) pattern • Model : entities • View Model : bind model • Well adapted to RIA : • Optimize benefits of Silverlight & WPF (statefull, 2 ways databinding) • Data changed->one or several views should be updated • Data stays in memory for longer in RIA->interesting to notify that data changes Model change Events UI Events View Model Property changedI Events Model View Update Read ViewModel data

  18. MVVM

  19. Topics • Introduction to SharePoint Patterns and Practices Guidance (SPG) • Patterns covered by the SPG • Reusable libraries • Application Lifecycle Management for SharePoint 2010 • Unit testing with Pex & Moles • Conclusions

  20. SPG Reusable libraries • Service Locator • Settings Manager • SharePoint Logger

  21. Topics • Introduction to SharePoint Patterns and Practices Guidance (SPG) • Patterns covered by the SPG • Reusable libraries • Application Lifecycle Management for SharePoint 2010 • Unit testing with Pex & Moles • Conclusions

  22. Application Lifecycle Management • Collect and analyze business requirements • Establish the technical design • Develop the application in iterations • Deploy to test environment • Perform integration tests and performance test • Deploy to user acceptance test environment • Perform functional tests • Deploy to production • Manage bug fixes and change requests

  23. Manage Application Lifecycle Management with Team Foundation Server 2010 • Analyze business requirements • Enter use cases and split into work items • Enter test scenarios and link to work items • Develop the application in iterations • Develop iteration and link to work items • Branching/merging • Test the application • Nightly builds • Innovation: Lab Management • Unit Tests • Write complete test suite or use parameterized tests • mock SharePoint objects • Integration tests • Performance tests • Tools for Code Coverage and Code metrics

  24. Application Lifecycle Management for SharePoint 2010 • Develop Features and Solutions • Feature dependencies • Solution dependencies • Feature versioning • Feature.xml changes • <VersionRange> • <AddContentTypeField> • <ApplyElementManifest> • <CustomAction> • FeatureUpgrading event

  25. Unit Testing SharePoint 2010 • What? • Isolate testable pieces of code • Determine whether it behaves exactly as you expect • Tedious to write • Large percentage of defects are identified during its use • Rerun after bug fixes can detect newly introduced bugs • Problem with SharePoint: • Unit test should run isolated • SharePoint objects like SPSite need connection to SharePoint • A lot of SharePoint object classes are sealed types with non-public constructors

  26. Unit Testing with Visual Studio 2010 • Visual Studio 2010 • Provide test project template for .NET Framework 4 applications • SP1 • Unit test projects that target the .NET Framework 3.5 • Support for 64 bits Intellitrace for SharePoint 2010 • Unit Test Host for SharePoint 2010

  27. Topics • Introduction to SharePoint Patterns and Practices Guidance (SPG) • Patterns covered by the SPG • Reusable libraries • Application Lifecycle Management for SharePoint 2010 • Unit testing with Pex & Moles • Conclusions

  28. Unit testing SharePoint 2010 using Pex and Moles • Microsoft Pex: • Visual Studio 2010 add-in Visual Studio add-in for testing .NET applications • Parameterized test suites • High code coverage • Can be included in nightly builds because of command line utility • Microsoft Moles: • Allows you to mock objects • Behaviors

  29. Getting started with Pex and Moles… • Download • Using your MSDN Subscription • Microsoft Research site: • http://research.microsoft.com/en-us/projects/pex/downloads.aspx • MSDN forum: • http://social.msdn.microsoft.com/Forums/en/pex/threads • Peli de Halleux rocks !!! • Install • Documentation, source code and binaries can be found • C:\Program Files\Microsoft Pex • C:\Program Files\Microsoft Moles

  30. Create Parameterized Unit Tests with Microsoft Pex • What is a parameterized unit test? • A unit test allowing parameters • A parameterized unit test is organized in 3 sections: • Arrange • Set up the unit under test • Act • Exercise the unit under test, capturing any resulting state • Assert • Verify the behavior through assertions

  31. Unit testing SharePoint 2010 with Microsoft Pex

  32. Unit testing SharePoint 2010 using Microsoft Moles • Visual Studio 2010 add-in • Provides isolation using stubs • Can be used together with Microsoft Pex • Creates a mole for each SharePoint class

  33. Unit testing SharePoint 2010 with Microsoft Pex and Moles

  34. Behaved Types for SharePoint • Moles ask for a lot of coding • Behaved types provide an in-memory model of SharePoint that can be used in the context of unit testing • Provides a set of behaviors that mimic the behavior of that instance • Provides a way to instantiate an instance of a type • Part of the Moles project: • behaviors.samples.zip • Microsoft.SharePoint.Behaviors.dll • Extend behaved types using Moles

  35. Unit testing SharePoint 2010 with Behaved Types

  36. Conclusion • More layered approach in SharePoint development needed • Accustom yourself with the SPG • Focus on the main patterns • Include FeatureUpgrading event in your deployment procedure • Use Microsoft Pex to reduce the number of unit tests • Use Microsoft Moles to typeMock (your SharePoint OM…) • Integrate the Cloud in your governance plan

  37. Stay up to date with MSDN Belux • Register for our newsletters and stay up to date:http://www.msdn-newsletters.be • Technical updates • Event announcements and registration • Top downloads • Follow our bloghttp://blogs.msdn.com/belux • Join us on Facebookhttp://www.facebook.com/msdnbehttp://www.facebook.com/msdnbelux • LinkedIn: http://linkd.in/msdnbelux/ • Twitter: @msdnbelux DownloadMSDN/TechNet Desktop Gadgethttp://bit.ly/msdntngadget

  38. TechDays 2011 On-Demand • Watchthis session on-demand via Channel9http://channel9.msdn.com/belux • Download to your favorite MP3 or video player • Get access to slides and recommended resources by the speakers

  39. THANK YOU

More Related