#SPSTCDC Just Freakin Work! Development Best Practices in SharePoint


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Things to take away from this session…
  • #SPSTCDC Just Freakin Work! Development Best Practices in SharePoint

    1. 1. Just Freakin’ Work!Avoiding Common Hurdles in SharePoint Development<br />Geoff Varosky (GraceHunt)<br />Mark Rackley (Juniper Strategy)<br />Welcome to SharePoint Saturday—The Conference<br />
    2. 2. Welcome to SharePoint Saturday—The Conference<br />Thank you for being a part of the first SharePoint Saturday conference<br />Please turn off all electronic devices or set them to vibrate.<br />If you must take a phone call, please do so in the hall so as not to disturb others.<br />Open wireless access is available at SSID: SPSTC2011<br />Feel free to “tweet and blog” during the session<br />Thanks to our Diamond and Platinum Sponsors:<br />
    3. 3. About the speakers…<br />The Hillbilly<br />Mr. Ackley<br />Catcher of all things that flow downhill<br />Solutions Architect for Juniper Strategy, LLC.<br />www.juniper-strategy.com<br />Speaker, Blogger, (soon to be) Author<br />Blog: www.sharepointhillbilly.com<br />Twitter: @mrackley<br />E-mail: mrackley@gmail.com<br />
    4. 4. About the speakers…<br />The Yankee<br />Geoff Varosky<br />Director, Development and Evangelism<br />GraceHunt<br />www.gracehunt.com<br />Speaker, Blogger, (soon to be) Author<br />Blog: www.sharepointyankee.com<br />Twitter: @gvaro<br />E-mail: gvarosky@gracehunt.com<br />
    5. 5. You might be a SharePoint Developer if… <br />
    6. 6. Agenda<br />Introduction<br />Development<br />Deployment<br />Resources<br />Q&A<br />
    7. 7. Introduction<br />Types of Development<br />Development Tools<br />Development Environment<br />Developing to Deploy<br />
    8. 8. Introduction<br />Types of Development<br />Unmanaged Code<br />Managed Code<br />Customization<br />
    9. 9. Introduction<br />Development Tools<br />STSDEV (2007)<br />stsdev.codeplex.com<br />WSPBuilder (2007 & 2010)<br />wspbuilder.codeplex.com<br />CKS:DEV (2010)<br />cksdev.codeplex.com<br />SharePoint Designer<br />Developer Dashboard (2010)<br />
    10. 10. Introduction<br />Development Environment<br />Physical?<br />Virtual?<br />Desktop?<br />Dusty old PC under the desk?<br />
    11. 11. Introduction<br />2007 or 2010<br />64-bit (leaves room for upgrade)<br />>= 4G of RAM<br />Choice of Virtual Host<br />HyperV, VMWare, VirtualBox<br />Not much in the way of VirtualPC support<br />Create a base virtual image<br />SQL, Base SP install, Service Packs, Dev Tools<br />Visual Studio, SPD, etc.<br />
    12. 12. Introduction<br />Development Environment<br />Follow the SDK (2010)<br />64 bit<br />Desktop<br />Windows 7<br />Vista (SP1+)<br />Http://msdn.microsoft.com/en-us/library/ee554869.aspx<br />Server 2008<br />
    13. 13. Introduction<br />Development Environment<br />Make sure your environment matches deployment targets!<br />In Visual Studio<br />CPU<br />x86? x64? AnyCPU?<br />.NET Framework<br />Service Packs<br />Same architecture<br />
    14. 14. Introduction<br />Development Environment<br />Don’t do everything as local admin!<br />Follow proper account configuration from the SDK<br />Developing to Deploy<br />Use the least amount of privileges<br />This will make admins happy<br />Web application deployment (/bin)<br />CAS policies<br />
    15. 15. Development<br />General Development Practices<br />Lists<br />Event Receivers<br />Web Parts<br />Unmanaged Code<br />Web Services<br />
    16. 16. Development<br />General Development Practices<br />Dispose of Objects!<br />SPDisposeCheck<br />Test with multiple accounts/privileges<br />Strongly named assemblies<br />Separate high and low privileged DLLs<br />Do not mix .NET Framework versions<br />64 bit code compatibility<br />
    17. 17. Development<br />General Development Practices<br />Stay away from the database<br />USE THE API!<br />Use resource & language files<br />Do not hard code strings and labels<br />Caching when and where possible<br />msdn.microsoft.com/library/bb687949.aspx<br />CAS Policies<br />Safe Controls<br />
    18. 18. Development<br />General Development Practices<br />Use try{} catch{} finally{} blocks<br />Check for nulls in finally{} blocks with disposable objects before disposing<br />Change defaults<br />Assembly Info<br />Name it properly<br />GraceHunt.SharePoint.WebParts.Stuff<br />
    19. 19. Development<br />General Development Practices<br />Sign Controls<br />Do not password protect the SNK<br />Elevating Privileges<br />SPSecurity.RunWithElevatedPrivileges()<br />Clean, Validated, Secure data<br />Runs as System account<br />Write operations?<br />Preceeded by SPUtility|SPWeb.ValidateFormDigest<br />Must use new SPSite or SPWeb – not SPContext.Current<br />
    20. 20. You might be a SharePoint Developer if… <br />
    21. 21. Development<br />Lists<br />Test queries before deployment!<br />U2U CAML Query Builder<br />Remove the <Query></Query> tags!<br />http://www.spsprofessional.com/sqlcaml.aspx<br />LINQ<br />Batch queries when possible<br />
    22. 22. Development<br />Lists<br />Do not use SPList.Items<br />Use SPList.GetItems(query)<br />Paginate (2000 items) – RowLimit<br />GetItemByID<br />Use SPList.GetitemByID<br />Not SPList.Items.GetItemByID<br />
    23. 23. Development<br />Event Handlers<br />Do not instantiate SPWeb, SPSite, SPList, or SPListItem<br />Use what the properties give you<br />properties.OpenWeb()<br />properties.ListItem<br />Bulk operations will not run event handlers<br />Ex: New list created – FieldAdding will not run<br />
    24. 24. Development<br />Event Handlers<br />Connections<br />Make sure you code for external systems not being available<br />LOG ERRORS<br />Make it known why something went wrong<br />
    25. 25. Development<br />Web Parts<br />Deploy to the Web Part Gallery<br />Easy to add to a page from there<br />AllowClose = false<br />Closing web parts = bad<br />X DOES NOT EQUAL DELETE<br />Use Properties – avoid hard coded values<br />HTMLEncode input values<br />
    26. 26. Development<br />Web Parts – In Code<br />EnsureChildControls<br />Ensure that the controls have been loaded before using them.<br />
    27. 27. Development<br />Unmanaged Code<br />JavaScript<br />Will this be used in more than one place?<br />Central Script repository (easy access)<br />Deployment to _layouts folder<br />More of a “managed” approach, more secure<br />Less flexible<br />
    28. 28. Development<br />Unmanaged Code<br />Content Editor Web Parts<br />Awesome, flexible web parts!<br />Use a library with versioning to link the WP to<br />Easier to manage<br />Versioning of “code”<br />Publishing Sites<br />Use content controls, not CEWPs!<br />
    29. 29. Development<br />Unmanaged Code<br />Ghosted v. UnGhosted pages<br />Uncustomized v. customized<br />Unghosted pages can have issues with upgrades<br />i.e. site definitions change with upgrades<br />Branding<br />
    30. 30. Development<br />SharePoint Web Services<br />Provide remote access to a range of object model functionality<br />Run on all front-end web servers<br />Heavily dependent on XML and CAML<br />Reside in physical file system in the 12... Directory and in a virtual file system in /_vti_bin<br />
    31. 31. Development<br />SharePoint Web Services – What They Do<br />Provide programmatic access via .NET and SharePoint Designer<br />Deliver relatively robust remote API functionality<br />Expose SharePoint data repository to disconnected clients<br />
    32. 32. Development<br />SharePoint Web Services – What They Do<br />Permit inter-farm communication (geographic distribution)<br />Integrate well with WinForms, WPF, and SilverLight<br />Client Object Model (SP 2010)<br />
    33. 33. Development<br />SharePoint Web Services – What they DON’T do<br />Do not provide access to entire object model<br />Do not permit manipulation of BLOB objects (documents)<br />NTLM and Basic Authentication Only<br />No SSO integration<br />No extensibility (sealed classes)<br />Limited data aggregation (no joins)<br />
    34. 34. Development<br />SharePoint Web Services – When to use them<br />Remote accessibility<br />Integration with backend or legacy systems<br />Retrieval of items and content as XML<br />Perform large batch updates to lists<br />
    35. 35. Development<br />SPServices – jQuery library utilized SharePoint Web Services<br />http://spservices.codeplex.com/<br />
    36. 36. Development<br />SharePoint Web Services Basics<br />Add a Web Reference to any project type<br />Must specify existing SharePoint site in URL + “/_vti_bin/” + ServiceName + “.asmx”<br />Set URL to dynamic<br />
    37. 37. Development<br />SharePoint Web Services Basics<br />All column names are XML encoded and prefixed with “ows_”<br /><rs:dataItemCount="1" xmlns:rs="urn:schemas-microsoft-com:rowset"><br /> <z:rowows_Title="Elmer@Fudd.com" <br />ows_MetaInfo="4764;#" <br />ows__ModerationStatus="0" <br />ows__Level="1" <br />ows_ID="4764" <br />ows_owshiddenversion="5" <br />ows_UniqueId="4764;#{2272A40C-0DA5-4C0D-938D-BFF3AF9C8ACF}" <br />ows_FSObjType="4764;#0" <br />ows_Created="2009-12-12 12:55:10" <br />ows_FileRef="4764;#sps/Contact/test/Lists/Issues/4764_.000" <br />xmlns:z="#RowsetSchema" /><br /></rs:data><br />
    38. 38. You might be a SharePoint Developer if… <br />
    40. 40. Development<br />User Code Solutions (2010 & Office 365)<br />When possible<br />Forces better programming practices<br />Keeps the farm safe<br />Makes admins & managers happy<br />Admins can control<br />Makes them feel special<br />
    41. 41. Resources<br />Development Tools<br />Codeplex.com<br />Search SharePoint & Development<br />SharePointDevWiki.com<br />www.sharepointdevwiki.com/display/public/SharePoint+Development+Tools<br />SPDisposeCheck<br />code.msdn.microsoft.com/SPDisposeCheck<br />
    42. 42. Resources<br />SDKs<br />2010<br />Server and Foundation<br />http://msdn.microsoft.com/en-us/library/ee557253.aspx<br />2007<br />WSS<br />http://msdn.microsoft.com/en-us/library/ms441339(office.12).aspx<br />MOSS 2007<br />http://msdn.microsoft.com/en-us/library/ms550992(office.12).aspx<br />
    43. 43. Resources<br />General Development<br />Roger Lamb’s Blog<br />blogs.msdn.com/rogerla/<br />Patterns & Practices SharePoint Guidance<br />msdn.microsoft.com/en-us/library/dd203468.aspx<br />Using Disposable Objects<br />msdn.microsoft.com/en-us/library/aa973248(v=office.12).aspx<br />
    44. 44. Resources<br />General Development<br />Working with Large Lists<br />go.microsoft.com/fwlink?LinkId=95450<br />SharePoint 2007 Best Practices Resource Center<br />technet.microsoft.com/en-us/office/sharepointserver/bb736746.aspx<br />
    45. 45. You… BEFORE session… <br />
    46. 46. You… AFTER our session… <br />
    47. 47. Resources<br />Q&A<br />
    48. 48. Thanks to Our Other Sponsors!<br />Thanks to our Sponsors<br />
    49. 49. Session Evaluation<br />Please complete and turn in your Session Evaluation Form so we can improve future events. Survey can be filled out at:<br />http://app.fluidsurveys.com/surveys/spstc2011-<br />and add the Session number to the URL<br />Presenter: Geoff Varosky & Mark Rackley<br />Session Name: Just Freakin’ Work!<br />Session No.: FRI-S5A-110<br />