Where does the SharePoint Patterns and Practices fit in?

Over the past year or so Microsoft for the very first time has made life easier for lots of us by listening to us and then providing content and examples that show us how the best way of building something. This is a great change to see, as we can now download PowerShell, Code and even End-to-End real world examples that show us the how in a better way than previously.

ITPro Today

September 29, 2016

5 Min Read
Where does the SharePoint Patterns and Practices fit in?

Over the past year or so Microsoft for the very first time has made life easier for lots of us by listening to us and then providing content and examples that show us how the best way of building something. This is a great change to see, as we can now download PowerShell, Code and even End-to-End real world examples that show us the how in a better way than previously.

This repository is called the Office Patterns and Practices, and is backed by a specific team of not just Microsoft Employees but also worldwide community resources to ensure that everything I relevant. The reason for this is explained within the site.

The SharePoint / Office 365 Dev Patterns & Practices (PnP) initiative was originally formed in 2013 by a group of Microsoft consultants who were working on the transformation effort of the Office 365 Dedicated customers to Multi-Tenant. This involved taking the SharePoint full Trust Code Solutions and transforming the customizations to the add-in model, but PnP guidance has started evolving to other areas as well, including Office 365 APIs, Office Add-ins and unified APIs. PnP initiative has now evolved as open source community effort with both internal and external contributors. Notice that SharePoint / Office 365 Dev PnP is not directly linked with the official Patterns and Practices team at Microsoft, which concentrates more on the general development topics.

To access the solutions and samples, you can visit the following site:

http://dev.office.com/patterns-and-practices

This will then link you to the GitHub site that hosts all of the samples.

https://github.com/OfficeDev/PnP

The breakdown of sample code and examples is listed below:

I hear you saying well that’s great we have these samples, examples and solution, what does it all mean though?

For too long we have really been left to come up with the right approach, right code and solution for building things both within an On-Premises and Cloud Solution. Now we have some core components that we can almost use as a framework for the solutions we build. To start with, head over to YouTube and watch the videos that will give you a greater understanding of the samples.

After that you can then start to download solution and review what they do. To get started with the samples there are core packages that need to be installed, they are installed by simply typing Nuget commands into Visual Studio.

SharePoint 2013
Install-Package SharePointPnPCore2013

SharePoint 2016
Install-Package SharePointPnPCore2016

SharePoint Online
Install-Package SharePointPnPCoreOnline

Once these are done, then the components will be available for the any of the samples that you wish to download. The next step is to now look at some of the documentation that has been provided.

If you open one of these such as “Branding and Site Provisioning,” you can see some core guidance.

The guidance provided is basically a large repository of everything SharePoint that would need, if you were to learn SharePoint On-Premises or Online. Within the documentation are links to other samples and code components to help you in building a solution.

Now that you may have chosen your components you can simply bring down the code directly from GitHub, modify and use the code as needed. A standard example project looks very similar to this:

You can see that each component in the sample Documentation project are grouped into folders and contain the “.cs” classes as needed. A project can contain the following:

  • AppModelExtensions: Extension methods are a .Net construct that allow to extend an existing type with additional methods.

  • Entities: Simple classes used to provide and retrieve more complex objects from the extensions methods in Extensions Methods.

  • Enums:  Enumeration classes for various components.

  • Extensions This folder contains extension methods that are not SharePoint related such as extension methods to help with string manipulations.

  • Utilities: Utility classes (helper classes) for specific components within the project.

Loading any of the samples found here: https://github.com/OfficeDev/PnP/tree/master/Samples, lets you see what each project does and what the core code does. A sample one we can use would be the sample for creating a Site Collection from within the CSOM using a Provider Hosted Add-in.

https://github.com/OfficeDev/PnP/tree/master/Samples/Provisioning.SiteCollectionCreation

The main project is broken into the Web and then the SharePoint Add-in project. The Web project contains the following code layout.

Opening the code, we can access the default page code file and see that the code being called for this is:

There is of course lots more code for other pieces of the project but the core code is really this, the correct way and chosen Microsoft way of doing it. I hear you saying, but yes why would we use it still, I can write code like that?

The real reason for the PnP components comes down to these guidance areas.

As you can see the power that comes with the components touches all areas of what we would class is SharePoint or Office Development.

So where does it fit in?

Well as you can see, this where we are supposed to get the best practice or Microsoft supported approach for building applications and developing against SharePoint On-Premises or within Office 365.

To learn more there are a series of videos you can watch here: https://channel9.msdn.com/blogs/OfficeDevPnP

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like