39
itcampro @ itcamp12 # Premium conference on Microsoft technologies Developing SharePoint 2010 and Silverlight Web Parts – Tips and Tricks Ovidiu Becheș-Puia SharePoint Developer EBS Romania [email protected]

ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

  • Upload
    itcamp

  • View
    360

  • Download
    3

Embed Size (px)

Citation preview

Page 1: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Developing SharePoint 2010 and Silverlight Web Parts –

Tips and Tricks

Ovidiu Becheș-Puia

SharePoint Developer

EBS Romania

[email protected]

Page 2: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices ITCamp 2012 sponsors

Page 3: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices

• SharePoint Developer Tools

• ASP.NET and Silverlight Web Parts

• SPG (SharePoint Pattern&Practices Guidance)

• Unit Testing in SharePoint

• DEMOS

Agenda

Page 4: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices Intro

What means to me developing and working with SharePoint ?

Page 5: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices Intro

Page 6: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

TOOLS

The SharePoint Developer Toolbox

Page 7: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices

• SPM 2010

TOOLS

Page 8: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices

• ULS Viewer

TOOLS

Page 9: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices

• .NET Reflector / JustDecompile

TOOLS

Page 10: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices

• Fiddler2 / Firebug

TOOLS

Page 11: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices

• CKS – Community Kit for SharePoint

TOOLS

Page 12: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices

• SPSF – SharePoint Software Factory

TOOLS

Page 13: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices

• Linq to SharePoint DSL Extension for VS2010

TOOLS

Page 14: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

WEB PARTS

Developing ASP.NET and Silverlight WebParts

Page 15: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices Web Parts

Page 16: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices Web Parts

My GOLDEN RULE (GOAL)

It would be so much easier if we could avoid using

SharePoint server to develop Web Part / anything

The F5 Build/Deploy/Test cycle is slow….

Page 17: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices Web Parts

When not to use SharePoint:

-if your WebPart does not use SharePoint calls

-use a simple ASP.NET Web Application – test harness

-statically declare WebParts in aspx – so no need to

handle personalisation

The F5 Build/Deploy/Test cycle is slowww..

Page 18: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

SPG

SharePoint 2010 Pattern & Practices Guidance

Page 19: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices

(Coding) Challenges when creating enterprise

applications:

• Testability

– can you isolate your classes

• Flexibility

– Can you update or replace code without

recompiling

• Configuration

– How do you manage configuration settings?

SPG

Page 20: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices

(Coding) Challenges when creating enterprise

applications:

• Logging and exception handling

– How do you log ? Consistent across the team

• Maintainability

- How can you maintain code that is always

evolving

• Can your code run in the Cloud (Office 365)

- Without Full trust proxy

SPG

Page 21: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices

• Main patterns illustrated (with reference

applications in the SPG)

-Service Locator pattern

-MVP pattern (Model-View-Presenter)

-MVVM pattern (Model-View-ViewModel)

-Repository pattern

SPG

Page 22: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices SPG: Service Locator pattern

Page 23: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices SPG: Service Locator pattern

Mappings add on Farm level Can be added using only: -farm feature / CA Web App -console app

Mappings add on Site Coll. level

Get Service Locator -Site Collection (if SPContext ) -Farm

Page 24: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices SPG:MVP (Model-View-Presenter)

-MVP originated in early 1990s

-MVP is a derivative of MVC

-Two types of implementation – Passive View

– Supervising Controller

-Presenter assumes the functionality of the

MVC controller

-View is responsible for handling UI events

-Model becomes strictly a Domain Model

Page 25: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices SPG:MVP (Model-View-Presenter)

Page 26: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices SPG:M-V-VM

• Largely based on MVC

• Specialization of the MVP pattern known as

Presentation Model

• Build specifically for the WPF and Silverlight

• ViewModel is a “Model of the View”

-it extends the Model with Behaviours the View

could use

-Data binding between View and Model

-Passes commands between the View and Model

Page 27: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices SPG:M-V-VM

Page 28: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices SPG:M-V-VM

The Model - which provides a view-independent

representation of your business entities

The View - which is the user interface. It displays information

to the user and fires events in response to user interactions

The ViewModel - which is the bridge between the view and the

model.

Page 29: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices SPG:M-V-VM

How about JavaScript / HTML5?

Page 30: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices SPG: Repository Pattern

Page 31: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices SPG: Repository Pattern

Choosing a SharePoint Data Access Technology

Page 32: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

UNIT TESTS

Unit Testing in SharePoint World

Page 33: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices UNIT TEST

Only Integration Tests with MSTest

- Visual Studio 2010 SP1

SPListCollection – internal ctors.

Isolation Frameworks:

-Typemock – not free

-Pex and Moles – free

Page 34: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices UNIT TEST

Mocking the ‘Principle of Isolation’

Page 35: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices UNIT TEST

TDD and SharePoint

-reducing the cost of change -in a typical SharePoint project, the portion where TDD is actually applicable is very small which is the writing code part

TDD + SharePoint ? Not worth it IMHO.

Sahil Malik

Page 36: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices UNIT TEST

TDD and SharePoint a typical SharePoint project: • Customer communication and prototyping • Plenty of attention to the IT Pro side, where you

decide logical and physical layouts of your servers, networks, and your site collections

• A significant effort in branding • Focus on scalability • Writing some code • Establishing roles within your team (overlap with IT

Pro guys) • Training required • large portions of XML

Sahil Malik

Page 37: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices UNIT TEST

Pex and Moles - Peli de Halleux – Microsoft Research

Page 38: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Q & A

Vă mulțumesc

Page 39: ITCamp 2012 - Ovidiu Beches - Developing SharePoint 2010 and Silverlight web parts

itcampro @ itcamp12 # Premium conference on Microsoft technologies

Architecture &

Best Practices Conclusions