Microsoft Patterns and Practices SharePoint Guidance Robert L. Bogue MS MVP, MCSE, MCSA: Security
Where are we today?
Where are we today (for real)? There are relatively few SharePoint Developers today We have free training that MS provides at – Hands on labs – Presentations – Demos (code) … but we don’t have best practices
Who are the Patterns and Practices Group at Microsoft?
The Scenario – Training Management Corporate Training is a big deal. – It needs tracked for personnel reasons – Budgeted for accounting reasons
How do we Deploy Solutions? SharePoint Solution (WSP) WSPs are to SharePoint like MSIs are to Windows WSPs deploy correctly across the farm WSPs deliver assemblies, pages, and features
When should I create a Site Definition? When you need to distinguish a site for future changes When you start so you can differentiate between your sites and OOB sites See: How to Use Site Definitions in SharePointHow to Use Site Definitions in SharePoint
How should I make a Site Definition? Make it an empty shell Create all of the functionality for the Site Definition as features Use Dependencies to have the features activated when the site is created See: SharePoint 2007 Web Content Management DevelopmentSharePoint 2007 Web Content Management Development
How do I make changes to a Site Definition? Design additional Features Feature staple the feature to the site definition
What is Stapling? Allows you to specify a feature that must be activated when a site is created with a definition – without changing the definition What it doesn’t do … activate a feature on existing sites so… Write a feature receiver to activate on the existing sites.
When to use Site Templates? When you want to allow users to make changes to the predefined content User interface can create them (no development tools required) Can be globally deployed via STSADM command
Lists Definition vs. Content Types List Definition – Specify fields – Specify forms – Specify views Content Types – Specify fields – Specify forms
What do we do about branding? Themes – Use Include Master Pages – For core controls that must be on every page Web Part Page – Layout of controls (web part zones) Page Layouts (MOSS Only) – How the pages lay out content
Where do you store configuration? Web.Config? – How do you manage across servers? SharePoint API – What do you do when the SharePoint Web.Config modification API is flaky? SPPropertyBag is on ALL SPPersistedObjects (SPFarm, SPWeb, etc.)
Creating Content Types Every Content type gets a unique ID The Unique ID has GUIDs in it… Creating Content Types from the UI causes unique GUID Creating from the API creates new GUIDs
Modifying Content Types The product team says… don’t overlay the file, use code to programmatically change I say… update your Content Type XML and use a feature receiver to propagate
Managing Process: Event Receiver vs. Workflow
SPList vs. Database Table SPList – User controllable fields – User controllable views – Export to Excel – Alerts Database – High performance – Large scalability
Custom ASPX pages Need to Inherit from a class (think ASP.NET 1.1) Need to have 5 part name (class + 4 part assembly) for the class to inherit
RenderContents vs. CreateChildControls Render/RenderContents = BAD – ASP approach – No events – No multi-device support CreateChildControls – ASP.NET Approach – PostBack, ViewState, etc. – Multi-device support
How do I manage Dev-Test-Prod? Code moves from DEV to TEST to PROD Content moves from PROD to TEST (and rarely to DEV) See: Managing the Code when Customizing SharePointManaging the Code when Customizing SharePoint
Updating Assemblies The assemblies are often loaded by four part name… – Name – Version – Culture – Public Key Token The four part name is in the content DB (which you can’t modify directly)
Unit Testing It’s hard Objects are sealed and have internal constructors TypeMock can be used… You can isolate your SharePoint calls
Continuous Integration How do you setup a build server? (Build requires SharePoint installed) How do you dynamically create SharePoint Solutions Packages
What if I want more? Go to
ROBERT L. BOGUE Thank You