sharepoint 2010 patterns & practices
DESCRIPTION
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) - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/1.jpg)
SharePoint 2010 Patterns & Practices
Serge Lucahttp://redwood.beKarine Boschhttp://karinebosch.wordpress.com
![Page 2: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/2.jpg)
Audience
• Audience : SharePoint developers & architects• Level : 300
![Page 3: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/3.jpg)
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
3
![Page 4: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/4.jpg)
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
4
![Page 5: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/5.jpg)
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
![Page 6: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/6.jpg)
(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
![Page 7: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/7.jpg)
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
7
![Page 8: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/8.jpg)
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)
![Page 9: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/9.jpg)
The Service Locator Pattern
9
Class A
Service A
Service B
Class A
Service A
Service B
Locator
Uses
Uses
Uses
Locates
Locates
![Page 10: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/10.jpg)
DEMOThe Service Locator Pattern
![Page 11: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/11.jpg)
MVP (Model View Presenter) pattern
11
View Presenter
Model
![Page 12: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/12.jpg)
DEMOThe MVP Pattern
![Page 13: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/13.jpg)
The Repository pattern
13
Client Business Logic
Your list repository
YourSharePointLists + other storages…
Business Entity
Business Entity? ?
![Page 14: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/14.jpg)
Choosing a SharePoint Data Access Technology
LINQ
Farm Site List Data External Lists
Data Platform
Client-side
Server-side
Strongly-typed
Weakly-typed
Strongly-typed
Weakly-typedServer OM
Client OM
REST APIs
New in 2010
Improved
![Page 15: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/15.jpg)
DEMOThe Repository Pattern
![Page 16: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/16.jpg)
Linq To SharePoint DSL extension
• To automatically generate a Repository, you can tryLinq To SharePoint DSL Extension from Olivier Carpentier (MCS France)
![Page 17: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/17.jpg)
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
17
ViewView Model
Model
UI EventsModel change Events
Property changedI Events
Update
ReadViewModel data
![Page 18: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/18.jpg)
DEMOMVVM
![Page 19: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/19.jpg)
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
19
![Page 20: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/20.jpg)
SPG Reusable libraries
• Service Locator• Settings Manager• SharePoint Logger
20
![Page 21: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/21.jpg)
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
21
![Page 22: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/22.jpg)
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
22
![Page 23: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/23.jpg)
Manage Application Lifecycle Management with Team Foundation Server 2010
• Analyze business requirementsEnter use cases and split into work itemsEnter test scenarios and link to work items
• Develop the application in iterationsDevelop iteration and link to work itemsBranching/merging
• Test the applicationNightly buildsInnovation: Lab ManagementUnit Tests
• Write complete test suite or use parameterized tests• mock SharePoint objects
Integration testsPerformance tests
• Tools for Code Coverage and Code metrics 23
![Page 24: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/24.jpg)
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
![Page 25: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/25.jpg)
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 constructors25
![Page 26: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/26.jpg)
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
26
![Page 27: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/27.jpg)
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
27
![Page 28: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/28.jpg)
Unit testing SharePoint 2010 using Pex and Moles
28
• 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
![Page 29: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/29.jpg)
Getting started with Pex and Moles…
29
• 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
![Page 30: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/30.jpg)
Create Parameterized Unit Tests with Microsoft Pex
30
• 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
![Page 31: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/31.jpg)
DEMOUnit testing SharePoint 2010 with Microsoft Pex
![Page 32: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/32.jpg)
Unit testing SharePoint 2010 using Microsoft Moles
32
• Visual Studio 2010 add-in• Provides isolation using stubs • Can be used together with Microsoft Pex• Creates a mole for each SharePoint class
![Page 33: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/33.jpg)
DEMOUnit testing SharePoint 2010 with Microsoft Pex and Moles
![Page 34: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/34.jpg)
Behaved Types for SharePoint
34
• 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
![Page 35: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/35.jpg)
DEMOUnit testing SharePoint 2010 with Behaved Types
![Page 36: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/36.jpg)
Conclusion
36
• 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
![Page 37: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/37.jpg)
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
Download MSDN/TechNet Desktop Gadget
http://bit.ly/msdntngadget
![Page 38: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/38.jpg)
TechDays 2011 On-Demand
• Watch this 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
![Page 39: SharePoint 2010 Patterns & Practices](https://reader035.vdocuments.mx/reader035/viewer/2022081503/568161ce550346895dd1bfdc/html5/thumbnails/39.jpg)
THANK YOU