Monday, December 20, 2010

SharePoint 2010 Developer Notes

I recently went to SharePoint 2010 Developer training. The following are some notes I took which were really interesting for me to learn about when comparing to my past experiences in SharePoint 2007. There are tons of published articles out there that capture much of the big things; this should capture some subtle changes as a developer you should know about.

My instructor was Scott Hillier with Critical Path Training. The course was really good.

  • Sandbox Solutions – We can talk about the challenges of working within the SharePoint Sandbox from a developer perspective because you are working with a restricted API. However the best practice moving forward is that all solutions should be initially developed for the Sandbox. My personal experience so far is that trying to force yourself into running in the Sandbox is a good thing and will force you to write good performing and secure solutions. If you cannot create a solution that reasonably fits in the Sandbox, then we should move out of it. Still there are ways to get around running in the SharePoint Sandbox. Enterprise data can be pulled in using External Content Types, Silverlight and ECMA JavaScript have no constraints, and it is possible to call a custom DLL from a Sandbox Solution writing a Full Trust Proxy. This right here is the best discussion I have read on the SharePoint Sandbox to date -
  • Upgrade Actions and Event Handler – Can I say Hallelujah? This is a new ability to add on custom actions to deployed features without having to completely remove old versions and redeploy. There is a new tag called <UpgradeActions> which can be added to the Feature.xml. There is also a new FeatureUgrading event handler. One note is that PowerShell must be used to actually initiate the upgrade. This will be very helpful to managing deployed Features. When Features are activated across a large number of sites it can be challenging to push out changes and make sure that all new activations of that Feature are the same from that point on.
  • Declarative Features – Little tip is that in Visual Studio 2010, if you are building a purely declarative Feature, like content types, turn off the DLL generation because there really is no DLL that needs to be deployed.
  • SharePoint Explorer – Do not take this for granted. This is a great way to dig around SharePoint and get things you may need for development, like those pesky instance GUIDs.
  • Common Master Page – Application and Site pages no longer have different master pages and CSS. Default.master is available for backwards compatibility to SharePoint 2007 (i.e. an upgrade). v4.master is used for new pages that are created in SharePoint 2010. Application pages use the same v4.master page. The v4.master links to corev4.css, has a reference to the ECMA javascript library, and heavily utilizes the ribbon.
  • Asynchronous Web Parts – For long running processes in your web parts. You can use System.Web.UI.PageAsyncTask class to facilitate handling the callback when the processing is complete.
  • Upgrading Content Types – Along the lines previously mentioned, <UpgradeActions> has a tag called <AddContentTyepField> which can be used to help with content type Features deployments. Sometimes pushing out changes in SharePoint 2007 would not well and this should resolve those problems.
  • Relational Lists – This will be very interesting to work with in SharePoint 2010. We all know that SharePoint lists do not replace a real database like SQL Server however we do Joins between lists and referential integrity is now supported. Another interesting feature is that columns can now be marked as unique, forcing a unique value for that the list.
  • List Throttling – Has been introduced to ensure that developers do not continue bad behavior by querying too many items and taking down your SharePoint site.
  • List Item and List Item Field Validation – We can now create formulas for validations reducing the amount of custom event handlers we would have to write.
  • Post Synchronous Events – THANK YOU. We can now add a property to the receiver definition (SPEventReceiverDefinition.Synchronization) which allows for post-processing after the commit but before the user is shown the result.
  • Cancel Event Error Page – We now have the ability when we want to cancel an event handler, maybe because a business rule failed, we can route the user to a screen with custom error explaining why the event failed.
  • LINQ to SharePoint – This is news everyone should know about but man is working with data in SharePoint lists so much easier without CAML code. NOTE – if you want to extend the code that is generated code by SPMetal are partial classes. So you can write your own partial class that combines custom logic which will not be lost when you regenerate your classes.
  • WCF Data Services – REST based services make it very easy for external applications to have direct access to data in SharePoint. Generating a Proxy for simple Windows or command line application is easy.
  • Content Organizer – You should really look into the new features here instead of custom coding like we have had to do the past.

No comments: