building high quality solutions with design patterns & application foundations for sharepoint...

Post on 29-Nov-2014

384 Views

Category:

Technology

7 Downloads

Preview:

Click to see full reader

DESCRIPTION

One of SharePoint’s greatest strengths is its flexibility and the possibility to quickly build powerful solutions with the web UI and SharePoint Designer. However, when building business critical enterprise applications, it’s important to make your solution maintainable by using the same standard design patterns and best practices that applies to ordinary .NET development. In this session, we will talk about several different design patterns such as repository, service location and model-view-presenter that will help you build SharePoint solutions that are flexible, testable and maintainable. We will discuss the different considerations you have to make when deciding to use these patterns. We will also go through the Application Foundations library for SharePoint 2010 from Microsoft, which provides support for managing configuration, service location and logging.

TRANSCRIPT

Th26 - Building High Quality Solutions with Design Patterns & Application Foundations

for SharePoint 2010

Christoffer von Sabsay christoffer.von.sabsay@sogeti.se

Agenda • Design Patterns – what, why and when? • Repository Pattern • Service Locator Pattern • Model-View-Presenter Pattern • Application Foundations for SharePoint 2010

SharePoint vs .NET development • SharePoint is just a .NET application, right? • So are there really any differences between

SharePoint and plain .NET development?

Design Patterns • What is it? • Why should we use it? • When should we use it?

Repository Pattern

Client Business

Logic

Data Source

Repository

Entity – Data Mapping

Business Entity

Business Entity

Persist

Retrieve

Model-View-Presenter Pattern

IView Presenter

Model

View

Service Locator Pattern

Class Service A

Service B

Service Locator

Application Foundations for SP2010

• SharePoint Service Locator • Logger • Configuration Settings Manager

SharePoint Service Locator using Microsoft.Practices.ServiceLocation; using Microsoft.Practices.SharePoint.Common.ServiceLocation;

IServiceLocator serviceLocator = SharePointServiceLocator.GetCurrent();

IServiceLocatorConfig typeMappings = serviceLocator.GetInstance<IServiceLocatorConfig>();

typeMappings.RegisterTypeMapping<IService1, Service1>();

IService1 service1 = serviceLocator.GetInstance<IService1>();

Other options for Service Location • Custom implementation • Unity • Spring.NET • StructureMap • Other frameworks

Logger using Microsoft.Practices.ServiceLocation;

using Microsoft.Practices.SharePoint.Common.ServiceLocation;

using Microsoft.Practices.SharePoint.Common.Logging;

using Microsoft.SharePoint.Administration;

IServiceLocator serviceLocator = SharePointServiceLocator.GetCurrent();

ILogger logger = serviceLocator.GetInstance<ILogger>();

logger.TraceToDeveloper("My message.");

logger.TraceToDeveloper("My message.", TraceSeverity.High);

logger.LogToOperations(msg, EventSeverity.Error);

Configuration Settings using Microsoft.Practices.ServiceLocation; using Microsoft.Practices.SharePoint.Common.Configuration; using Microsoft.Practices.SharePoint.Common.ServiceLocation; IServiceLocator serviceLocator = SharePointServiceLocator.GetCurrent(); IConfigManager configManager = serviceLocator.GetInstance<IConfigManager>(); IPropertyBag bag = configManager.GetPropertyBag(ConfigLevel.CurrentSPWebApplication); configManager.SetInPropertyBag("MySetting", DateTime.Now, bag); IHierarchicalConfig config = serviceLocator.GetInstance<IHierarchicalConfig>(); if(config.ContainsKey("MySetting")) lastUpdate = config.GetByKey<DateTime>("MySetting"); configManager.RemoveKeyFromPropertyBag("MySetting", bag);

Summary • Learn about the different design patterns and

when to use them • Use Application Foundations for common

tasks such as configuration and logging

Questions?

Resources Developing Applications for SharePoint 2010 http://msdn.microsoft.com/en-us/library/ff770300.aspx Developing Applications for SharePoint 2007 http://msdn.microsoft.com/en-us/library/ff800762.aspx Application Foundations for SharePoint 2010 http://msdn.microsoft.com/en-us/library/ff798371.aspx

Keep in touch! E-mail: christoffer.von.sabsay@sogeti.se Blog: http://christoffervonsabsay.wordpress.com Twitter: sabsay

top related