SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Downloaden Sie, um offline zu lesen
Sharepoint Saturday India Online best practice for developing share point solution
MySelf
         5 year of SharePoint

         Blogger, Speaker, Hobbyist
         photographer

         Technical Lead @ Kalsoft
Karachi, Pakistan
#Best Practice Quotes
“We cannot control the winds, but we can adjust the
sails.”
 Anonymous


“It's not necessarily the amount of time you spend at
practice that counts; it's what you put into the practice.”
 Eric Lindros


“My secret is practice”
 David Beckham
Best Practice for Developing
SharePoint Solutions
Content to Cover
SharePoint Solutions
   General Consideration
     Avoid unnecessary construction
    of Objects
     Disposing objects
     Object Caching
     Optimizing code performance
Avoid unnecessary
construction
ofSPWeb/SPSite Objects
   SPWeb
  SPSite



 SPWebApplication webApplication =
  SPWebApplication.Lookup(new
  Uri(System.String);
 SPFarm farm = webApplication.Farm;
 SPContentDatabase content =
  webApplication.ContentDatabases[S
  System.Int32];
Disposing objects
Disposing objects (Cont..)
   Symptoms
     Application pool recycle frequently,
      especially under heavy loads
     System perform poorly, especially under
      heavy loads
     System crash or do users experience
      unexpected errors such as timeouts or
      page-not-available errors, especially under
      heavy loads
Disposing objects (Cont..)
   Why Dispose?
     SPSite class and SPWeb class objects, are
      created as managed objects
     Each instance of SPSite and SPWeb
      contains a reference to an SPRequest
      object that, in turn, contains a reference to
      an unmanaged COM object
Disposing objects (Cont..)
   Rule of thumb

    Never dispose
    SPContext,
    SPContext.Site, SPContext.Current.
    Site, SPContext.Web, and
    SPContext.Current.Web.
Disposing objects (Cont..)
       using (SPWeb web = new
          SPSite(SPContext.Current.Web.
          Url).OpenWeb()) { //
      }
  using (SPSite siteCollection = new
      SPSite(SPContext.Current.Web.Url)) {
      using (SPWeb web =
      siteCollection.OpenWeb()) {
 //
 }}
Disposing objects (Cont..)
      SPSite siteCollection =
      siteCollections.Add(URL,
      "DOMAINUser", EMAIL);


  using (SPSite siteCollection =
     siteCollections.Add(URL, "DOMAINUser",
     EMAIL)
 {
 }
Disposing objects (Cont..)
      SPWeb web =
      siteCollection.AllWebs.Add(URL);



  using (SPWeb web =
     siteCollection.AllWebs.Add(URL)
 {
 }
Disposing objects (Cont..)
Download the SPDispose Check tool
http://code.msdn.microsoft.com/SPDispos
eCheck
Object Caching
  public void CacheData() { SPListItemCollection
  oListItems; oListItems =
  (SPListItemCollection)Cache["ListItemCacheName"];
  if(oListItems == null) { oListItems =
  DoQueryToReturnItems();
  Cache.Add("ListItemCacheName", oListItems, ..); } }
Object Caching
public void CacheData() {
 DataTable oDataTable; SPListItemCollection oListItems;
 lock(_lock) {
 oDataTable = (DataTable)Cache["ListItemCacheName"];
if(oDataTable == null) {
oListItems = DoQueryToReturnItems();
oDataTable = oListItems.GetDataTable();
Cache.Add("ListItemCacheName", oDataTable, ..); } } }
Optimizing code
performance
   SPWeb myWeb =
   SPContext.Current.Web;
   myWeb.Lists["Tasks"].Title = "List_Title";
   myWeb.Lists["Tasks"].Description =
   "List_Description";
   myWeb.Lists["Tasks"].Update();
  SPWeb myWeb =
  SPContext.Current.Web; SPList myList =
  myWeb.Lists["Tasks"];
  myList.Title="List_Title";
  myList.Description="List_Description";
  myList.Update();
Farm Solutions
 Target farm level solutions to the specific
  web application instead of deploying to
  all web applications.
 Try to deploy all the resource files
  (CSS, JPG) from within the Solution
  (Applicable to Sandboxed solution as
  well)
Sandboxed Solutions
 Plan which servers will run the
  sandboxed solutions service.
 Plan which site collections will be able
  to run sandboxed solutions.
 Design your Sand Boxed solution as per
  the Site collection quota
Working With Large Lists
Working With Large Lists
  SPWeb.Lists[strDisplayName]




  SPWeb.Lists[GUID]
  SPWeb.GetList(strURL)
Working With Large Lists
(Cont..)
  SPList.Items
  SPList.Items.Add
  SPList.Items.GetItemById




  SPList.GetItems(SPQuery query)
  SPList.AddItem
  SPList.GetItemById(int id, string
  field1, params string[] fields)
Working With Large Lists
(Cont..)
  SPList.Items.Count
  SPList.Items[System.Guid]
  SPList.Items[System.Int32]
  SPList.Items.GetItemById(Syste
  m.Int32)

  SPList.ItemCount
  SPList.GetItemByUniqueId(Syste
   m.Guid)
  SPList.GetItemById(System.Int32)
Working With Large Lists
(Cont..)
  SPFolder.Files.Count
  SPFolder.Files[System.String]




  SPFolder.ItemCount
  SPFolder.ParentWeb.GetFile(SPU
  rlUtility.CombineUrl(SPFolder.Url,
  System.String)
Working With Large Lists
(Cont..)
   Deleting Versions
  SPListItemVersion.GetVersionFr
     omID(System.Int32). Delete();




     SPFileVersionCollection.
     DeleteByID(System.Int32);
Event Receivers
Event Receivers
   Always use Event Receivers to execute
    the code immediately. Workflows can
    perform similar function but it will run as
    a timer job which may delay the code
    execution.
Event Receivers (Cont..)
  Instantiate an SPWeb, SPSite,
   SPList, or SPListItem
  Update method




  properties.OpenWeb()
  properties.ListItem
Timer Jobs
 Always run the timer job in off hours
 Always perform take out the timer job
  when deactivating the respective
  feature
 Don’t use
  SPContext,SPContext.Current,SPCo
  ntext.Current.Web
General Considerations
 Use proper feature name and
  description.
 Use the feature as it require by design.
 Make sure solutions have proper
  consistent naming convention.
 Use the correct older version of WSPs
  to retract the solution before deploying
  or upgrading the custom code
Thank You

Más contenido relacionado

Was ist angesagt?

SQL Server 2005 CLR Integration
SQL Server 2005 CLR IntegrationSQL Server 2005 CLR Integration
SQL Server 2005 CLR Integrationwebhostingguy
 
Programming web application
Programming web applicationProgramming web application
Programming web applicationaspnet123
 
Creating REST Webservice With NetBeans
Creating REST Webservice With NetBeansCreating REST Webservice With NetBeans
Creating REST Webservice With NetBeansNeil Ghosh
 
Data Binding and Data Grid View Classes
Data Binding and Data Grid View ClassesData Binding and Data Grid View Classes
Data Binding and Data Grid View ClassesArvind Krishnaa
 
Getting your data in and out of elasticsearch: let me count the ways
Getting your data in and out of elasticsearch: let me count the waysGetting your data in and out of elasticsearch: let me count the ways
Getting your data in and out of elasticsearch: let me count the ways🥑 Jay Miller
 
Data management with ado
Data management with adoData management with ado
Data management with adoDinesh kumar
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state managementpriya Nithya
 
Asp.net server control
Asp.net  server controlAsp.net  server control
Asp.net server controlSireesh K
 
ASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server ControlsASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server ControlsRandy Connolly
 
Cejv659 week09 glassfish-s14
Cejv659 week09 glassfish-s14Cejv659 week09 glassfish-s14
Cejv659 week09 glassfish-s14Ken Fogel
 
Using MongoDB with the .Net Framework
Using MongoDB with the .Net FrameworkUsing MongoDB with the .Net Framework
Using MongoDB with the .Net FrameworkStefano Paluello
 

Was ist angesagt? (20)

ADO.NETObjects
ADO.NETObjectsADO.NETObjects
ADO.NETObjects
 
SQL Server 2005 CLR Integration
SQL Server 2005 CLR IntegrationSQL Server 2005 CLR Integration
SQL Server 2005 CLR Integration
 
Ado object
Ado objectAdo object
Ado object
 
Asp objects
Asp objectsAsp objects
Asp objects
 
Programming web application
Programming web applicationProgramming web application
Programming web application
 
Intro to Parse
Intro to ParseIntro to Parse
Intro to Parse
 
Ajax Tuturial
Ajax TuturialAjax Tuturial
Ajax Tuturial
 
Creating REST Webservice With NetBeans
Creating REST Webservice With NetBeansCreating REST Webservice With NetBeans
Creating REST Webservice With NetBeans
 
Web Api vs MVC
Web Api vs MVCWeb Api vs MVC
Web Api vs MVC
 
Data Binding and Data Grid View Classes
Data Binding and Data Grid View ClassesData Binding and Data Grid View Classes
Data Binding and Data Grid View Classes
 
Getting your data in and out of elasticsearch: let me count the ways
Getting your data in and out of elasticsearch: let me count the waysGetting your data in and out of elasticsearch: let me count the ways
Getting your data in and out of elasticsearch: let me count the ways
 
E script
E scriptE script
E script
 
Data management with ado
Data management with adoData management with ado
Data management with ado
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
 
Asp.net server control
Asp.net  server controlAsp.net  server control
Asp.net server control
 
ASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server ControlsASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server Controls
 
Asp
AspAsp
Asp
 
Cejv659 week09 glassfish-s14
Cejv659 week09 glassfish-s14Cejv659 week09 glassfish-s14
Cejv659 week09 glassfish-s14
 
Using MongoDB with the .Net Framework
Using MongoDB with the .Net FrameworkUsing MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
 
KMI System
KMI SystemKMI System
KMI System
 

Andere mochten auch

Stug -Sir Syed University On Location-Live Event
Stug -Sir Syed University On Location-Live EventStug -Sir Syed University On Location-Live Event
Stug -Sir Syed University On Location-Live EventShakir Majeed Khan
 
GWT 2014: Smart City Conference - 07 Il ruolo delle tecnologie Geospaziali ne...
GWT 2014: Smart City Conference - 07 Il ruolo delle tecnologie Geospaziali ne...GWT 2014: Smart City Conference - 07 Il ruolo delle tecnologie Geospaziali ne...
GWT 2014: Smart City Conference - 07 Il ruolo delle tecnologie Geospaziali ne...Planetek Italia Srl
 
SharePoint 2010 and Changing Business Needs-MAJU 2011
SharePoint 2010 and Changing Business Needs-MAJU 2011SharePoint 2010 and Changing Business Needs-MAJU 2011
SharePoint 2010 and Changing Business Needs-MAJU 2011Shakir Majeed Khan
 
Workshop - Verso il Piano Regolatore di Ascoli Piceno - 02 - V. Barbieri
Workshop - Verso il Piano Regolatore di Ascoli Piceno - 02 - V. BarbieriWorkshop - Verso il Piano Regolatore di Ascoli Piceno - 02 - V. Barbieri
Workshop - Verso il Piano Regolatore di Ascoli Piceno - 02 - V. BarbieriPlanetek Italia Srl
 
Sharepoint developement tools(webparts+worflows) EBizSoft
Sharepoint developement tools(webparts+worflows) EBizSoftSharepoint developement tools(webparts+worflows) EBizSoft
Sharepoint developement tools(webparts+worflows) EBizSoftShakir Majeed Khan
 
UX@Vitra - Experience Continuum
UX@Vitra - Experience ContinuumUX@Vitra - Experience Continuum
UX@Vitra - Experience ContinuumKatrien De Graeve
 

Andere mochten auch (8)

Stug -Sir Syed University On Location-Live Event
Stug -Sir Syed University On Location-Live EventStug -Sir Syed University On Location-Live Event
Stug -Sir Syed University On Location-Live Event
 
GWT 2014: Smart City Conference - 07 Il ruolo delle tecnologie Geospaziali ne...
GWT 2014: Smart City Conference - 07 Il ruolo delle tecnologie Geospaziali ne...GWT 2014: Smart City Conference - 07 Il ruolo delle tecnologie Geospaziali ne...
GWT 2014: Smart City Conference - 07 Il ruolo delle tecnologie Geospaziali ne...
 
Sharepoint Online
Sharepoint OnlineSharepoint Online
Sharepoint Online
 
SharePoint 2010 and Changing Business Needs-MAJU 2011
SharePoint 2010 and Changing Business Needs-MAJU 2011SharePoint 2010 and Changing Business Needs-MAJU 2011
SharePoint 2010 and Changing Business Needs-MAJU 2011
 
Workshop - Verso il Piano Regolatore di Ascoli Piceno - 02 - V. Barbieri
Workshop - Verso il Piano Regolatore di Ascoli Piceno - 02 - V. BarbieriWorkshop - Verso il Piano Regolatore di Ascoli Piceno - 02 - V. Barbieri
Workshop - Verso il Piano Regolatore di Ascoli Piceno - 02 - V. Barbieri
 
Sharepoint developement tools(webparts+worflows) EBizSoft
Sharepoint developement tools(webparts+worflows) EBizSoftSharepoint developement tools(webparts+worflows) EBizSoft
Sharepoint developement tools(webparts+worflows) EBizSoft
 
AUC Tech-SP 2010
AUC Tech-SP 2010AUC Tech-SP 2010
AUC Tech-SP 2010
 
UX@Vitra - Experience Continuum
UX@Vitra - Experience ContinuumUX@Vitra - Experience Continuum
UX@Vitra - Experience Continuum
 

Ähnlich wie Sharepoint Saturday India Online best practice for developing share point solution

Local data storage for mobile apps
Local data storage for mobile appsLocal data storage for mobile apps
Local data storage for mobile appsIvano Malavolta
 
SharePoint Object Model, Web Services and Events
SharePoint Object Model, Web Services and EventsSharePoint Object Model, Web Services and Events
SharePoint Object Model, Web Services and EventsMohan Arumugam
 
Introduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST APIIntroduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST APIRob Windsor
 
Windows 8 JavaScript (Wonderland)
Windows 8 JavaScript (Wonderland)Windows 8 JavaScript (Wonderland)
Windows 8 JavaScript (Wonderland)Christopher Bennage
 
Wss Object Model
Wss Object ModelWss Object Model
Wss Object Modelmaddinapudi
 
Local storage in Web apps
Local storage in Web appsLocal storage in Web apps
Local storage in Web appsIvano Malavolta
 
SharePoint TechCon 2009 - 907
SharePoint TechCon 2009 - 907SharePoint TechCon 2009 - 907
SharePoint TechCon 2009 - 907Andreas Grabner
 
The uniform interface is 42
The uniform interface is 42The uniform interface is 42
The uniform interface is 42Yevhen Bobrov
 
Taming Core Data by Arek Holko, Macoscope
Taming Core Data by Arek Holko, MacoscopeTaming Core Data by Arek Holko, Macoscope
Taming Core Data by Arek Holko, MacoscopeMacoscope
 
Тарас Олексин - Sculpt! Your! Tests!
Тарас Олексин  - Sculpt! Your! Tests!Тарас Олексин  - Sculpt! Your! Tests!
Тарас Олексин - Sculpt! Your! Tests!DataArt
 
Intro to Core Data
Intro to Core DataIntro to Core Data
Intro to Core DataMake School
 
09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WPNguyen Tuan
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
Entity Framework: Nakov @ BFU Hackhaton 2015
Entity Framework: Nakov @ BFU Hackhaton 2015Entity Framework: Nakov @ BFU Hackhaton 2015
Entity Framework: Nakov @ BFU Hackhaton 2015Svetlin Nakov
 
Android Automated Testing
Android Automated TestingAndroid Automated Testing
Android Automated Testingroisagiv
 
Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript EverywherePascal Rettig
 

Ähnlich wie Sharepoint Saturday India Online best practice for developing share point solution (20)

Local data storage for mobile apps
Local data storage for mobile appsLocal data storage for mobile apps
Local data storage for mobile apps
 
SharePoint Object Model, Web Services and Events
SharePoint Object Model, Web Services and EventsSharePoint Object Model, Web Services and Events
SharePoint Object Model, Web Services and Events
 
Introduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST APIIntroduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST API
 
Windows 8 JavaScript (Wonderland)
Windows 8 JavaScript (Wonderland)Windows 8 JavaScript (Wonderland)
Windows 8 JavaScript (Wonderland)
 
Wss Object Model
Wss Object ModelWss Object Model
Wss Object Model
 
Local storage in Web apps
Local storage in Web appsLocal storage in Web apps
Local storage in Web apps
 
Real World MVC
Real World MVCReal World MVC
Real World MVC
 
SharePoint TechCon 2009 - 907
SharePoint TechCon 2009 - 907SharePoint TechCon 2009 - 907
SharePoint TechCon 2009 - 907
 
The uniform interface is 42
The uniform interface is 42The uniform interface is 42
The uniform interface is 42
 
Taming Core Data by Arek Holko, Macoscope
Taming Core Data by Arek Holko, MacoscopeTaming Core Data by Arek Holko, Macoscope
Taming Core Data by Arek Holko, Macoscope
 
Тарас Олексин - Sculpt! Your! Tests!
Тарас Олексин  - Sculpt! Your! Tests!Тарас Олексин  - Sculpt! Your! Tests!
Тарас Олексин - Sculpt! Your! Tests!
 
Intro to Core Data
Intro to Core DataIntro to Core Data
Intro to Core Data
 
09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP
 
Local Storage
Local StorageLocal Storage
Local Storage
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
Entity Framework: Nakov @ BFU Hackhaton 2015
Entity Framework: Nakov @ BFU Hackhaton 2015Entity Framework: Nakov @ BFU Hackhaton 2015
Entity Framework: Nakov @ BFU Hackhaton 2015
 
Android Automated Testing
Android Automated TestingAndroid Automated Testing
Android Automated Testing
 
Share Point Object Model
Share Point Object ModelShare Point Object Model
Share Point Object Model
 
Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript Everywhere
 
OpenCMIS Part 1
OpenCMIS Part 1OpenCMIS Part 1
OpenCMIS Part 1
 

Mehr von Shakir Majeed Khan

STUG-Client Object Model SharePoint 2010
STUG-Client Object Model SharePoint 2010STUG-Client Object Model SharePoint 2010
STUG-Client Object Model SharePoint 2010Shakir Majeed Khan
 
SPS- Share Point 2010 and Windows Azure
SPS- Share Point 2010 and Windows AzureSPS- Share Point 2010 and Windows Azure
SPS- Share Point 2010 and Windows AzureShakir Majeed Khan
 
SharePoint 2010- Changing business needs
SharePoint 2010- Changing business needsSharePoint 2010- Changing business needs
SharePoint 2010- Changing business needsShakir Majeed Khan
 
STUG- SharePoint 2010 for ASP.net Devs
STUG- SharePoint 2010 for ASP.net DevsSTUG- SharePoint 2010 for ASP.net Devs
STUG- SharePoint 2010 for ASP.net DevsShakir Majeed Khan
 
SharePoint 2010 and its development tools
SharePoint 2010 and its development toolsSharePoint 2010 and its development tools
SharePoint 2010 and its development toolsShakir Majeed Khan
 
Microsoft SharePoint Server 2010-STUG- DCS-KU 9 feb live and on location
Microsoft SharePoint Server 2010-STUG- DCS-KU 9 feb live and on locationMicrosoft SharePoint Server 2010-STUG- DCS-KU 9 feb live and on location
Microsoft SharePoint Server 2010-STUG- DCS-KU 9 feb live and on locationShakir Majeed Khan
 
Stug-paf kiet 28 january live and on location-Enterprise Content Management
Stug-paf kiet 28 january live and on location-Enterprise Content Management Stug-paf kiet 28 january live and on location-Enterprise Content Management
Stug-paf kiet 28 january live and on location-Enterprise Content Management Shakir Majeed Khan
 
Sharepoint introanddevelopementtools
Sharepoint introanddevelopementtoolsSharepoint introanddevelopementtools
Sharepoint introanddevelopementtoolsShakir Majeed Khan
 

Mehr von Shakir Majeed Khan (10)

STUG-Sand boxed Solution
STUG-Sand boxed SolutionSTUG-Sand boxed Solution
STUG-Sand boxed Solution
 
STUG-Client Object Model SharePoint 2010
STUG-Client Object Model SharePoint 2010STUG-Client Object Model SharePoint 2010
STUG-Client Object Model SharePoint 2010
 
SPS- Share Point 2010 and Windows Azure
SPS- Share Point 2010 and Windows AzureSPS- Share Point 2010 and Windows Azure
SPS- Share Point 2010 and Windows Azure
 
SharePoint 2010- Changing business needs
SharePoint 2010- Changing business needsSharePoint 2010- Changing business needs
SharePoint 2010- Changing business needs
 
STUG- SharePoint 2010 for ASP.net Devs
STUG- SharePoint 2010 for ASP.net DevsSTUG- SharePoint 2010 for ASP.net Devs
STUG- SharePoint 2010 for ASP.net Devs
 
FCPakistan: a case study
FCPakistan: a case studyFCPakistan: a case study
FCPakistan: a case study
 
SharePoint 2010 and its development tools
SharePoint 2010 and its development toolsSharePoint 2010 and its development tools
SharePoint 2010 and its development tools
 
Microsoft SharePoint Server 2010-STUG- DCS-KU 9 feb live and on location
Microsoft SharePoint Server 2010-STUG- DCS-KU 9 feb live and on locationMicrosoft SharePoint Server 2010-STUG- DCS-KU 9 feb live and on location
Microsoft SharePoint Server 2010-STUG- DCS-KU 9 feb live and on location
 
Stug-paf kiet 28 january live and on location-Enterprise Content Management
Stug-paf kiet 28 january live and on location-Enterprise Content Management Stug-paf kiet 28 january live and on location-Enterprise Content Management
Stug-paf kiet 28 january live and on location-Enterprise Content Management
 
Sharepoint introanddevelopementtools
Sharepoint introanddevelopementtoolsSharepoint introanddevelopementtools
Sharepoint introanddevelopementtools
 

Último

Trailblazer Community - Flows Workshop (Session 2)
Trailblazer Community - Flows Workshop (Session 2)Trailblazer Community - Flows Workshop (Session 2)
Trailblazer Community - Flows Workshop (Session 2)Muhammad Tiham Siddiqui
 
LF Energy Webinar - Unveiling OpenEEMeter 4.0
LF Energy Webinar - Unveiling OpenEEMeter 4.0LF Energy Webinar - Unveiling OpenEEMeter 4.0
LF Energy Webinar - Unveiling OpenEEMeter 4.0DanBrown980551
 
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - TechWebinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - TechProduct School
 
My key hands-on projects in Quantum, and QAI
My key hands-on projects in Quantum, and QAIMy key hands-on projects in Quantum, and QAI
My key hands-on projects in Quantum, and QAIVijayananda Mohire
 
EMEA What is ThousandEyes? Webinar
EMEA What is ThousandEyes? WebinarEMEA What is ThousandEyes? Webinar
EMEA What is ThousandEyes? WebinarThousandEyes
 
Where developers are challenged, what developers want and where DevEx is going
Where developers are challenged, what developers want and where DevEx is goingWhere developers are challenged, what developers want and where DevEx is going
Where developers are challenged, what developers want and where DevEx is goingFrancesco Corti
 
UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4DianaGray10
 
Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024
Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024
Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024Alkin Tezuysal
 
Automation Ops Series: Session 2 - Governance for UiPath projects
Automation Ops Series: Session 2 - Governance for UiPath projectsAutomation Ops Series: Session 2 - Governance for UiPath projects
Automation Ops Series: Session 2 - Governance for UiPath projectsDianaGray10
 
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptxEmil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptxNeo4j
 
Patch notes explaining DISARM Version 1.4 update
Patch notes explaining DISARM Version 1.4 updatePatch notes explaining DISARM Version 1.4 update
Patch notes explaining DISARM Version 1.4 updateadam112203
 
Extra-120324-Visite-Entreprise-icare.pdf
Extra-120324-Visite-Entreprise-icare.pdfExtra-120324-Visite-Entreprise-icare.pdf
Extra-120324-Visite-Entreprise-icare.pdfInfopole1
 
Technical SEO for Improved Accessibility WTS FEST
Technical SEO for Improved Accessibility  WTS FESTTechnical SEO for Improved Accessibility  WTS FEST
Technical SEO for Improved Accessibility WTS FESTBillieHyde
 
UiPath Studio Web workshop Series - Day 3
UiPath Studio Web workshop Series - Day 3UiPath Studio Web workshop Series - Day 3
UiPath Studio Web workshop Series - Day 3DianaGray10
 
3 Pitfalls Everyone Should Avoid with Cloud Data
3 Pitfalls Everyone Should Avoid with Cloud Data3 Pitfalls Everyone Should Avoid with Cloud Data
3 Pitfalls Everyone Should Avoid with Cloud DataEric D. Schabell
 
Explore the UiPath Community and ways you can benefit on your journey to auto...
Explore the UiPath Community and ways you can benefit on your journey to auto...Explore the UiPath Community and ways you can benefit on your journey to auto...
Explore the UiPath Community and ways you can benefit on your journey to auto...DianaGray10
 
CyberSecurity - Computers In Libraries 2024
CyberSecurity - Computers In Libraries 2024CyberSecurity - Computers In Libraries 2024
CyberSecurity - Computers In Libraries 2024Brian Pichman
 
.NET 8 ChatBot with Azure OpenAI Services.pptx
.NET 8 ChatBot with Azure OpenAI Services.pptx.NET 8 ChatBot with Azure OpenAI Services.pptx
.NET 8 ChatBot with Azure OpenAI Services.pptxHansamali Gamage
 
How to release an Open Source Dataweave Library
How to release an Open Source Dataweave LibraryHow to release an Open Source Dataweave Library
How to release an Open Source Dataweave Libraryshyamraj55
 
Novo Nordisk's journey in developing an open-source application on Neo4j
Novo Nordisk's journey in developing an open-source application on Neo4jNovo Nordisk's journey in developing an open-source application on Neo4j
Novo Nordisk's journey in developing an open-source application on Neo4jNeo4j
 

Último (20)

Trailblazer Community - Flows Workshop (Session 2)
Trailblazer Community - Flows Workshop (Session 2)Trailblazer Community - Flows Workshop (Session 2)
Trailblazer Community - Flows Workshop (Session 2)
 
LF Energy Webinar - Unveiling OpenEEMeter 4.0
LF Energy Webinar - Unveiling OpenEEMeter 4.0LF Energy Webinar - Unveiling OpenEEMeter 4.0
LF Energy Webinar - Unveiling OpenEEMeter 4.0
 
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - TechWebinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
 
My key hands-on projects in Quantum, and QAI
My key hands-on projects in Quantum, and QAIMy key hands-on projects in Quantum, and QAI
My key hands-on projects in Quantum, and QAI
 
EMEA What is ThousandEyes? Webinar
EMEA What is ThousandEyes? WebinarEMEA What is ThousandEyes? Webinar
EMEA What is ThousandEyes? Webinar
 
Where developers are challenged, what developers want and where DevEx is going
Where developers are challenged, what developers want and where DevEx is goingWhere developers are challenged, what developers want and where DevEx is going
Where developers are challenged, what developers want and where DevEx is going
 
UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4
 
Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024
Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024
Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024
 
Automation Ops Series: Session 2 - Governance for UiPath projects
Automation Ops Series: Session 2 - Governance for UiPath projectsAutomation Ops Series: Session 2 - Governance for UiPath projects
Automation Ops Series: Session 2 - Governance for UiPath projects
 
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptxEmil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
 
Patch notes explaining DISARM Version 1.4 update
Patch notes explaining DISARM Version 1.4 updatePatch notes explaining DISARM Version 1.4 update
Patch notes explaining DISARM Version 1.4 update
 
Extra-120324-Visite-Entreprise-icare.pdf
Extra-120324-Visite-Entreprise-icare.pdfExtra-120324-Visite-Entreprise-icare.pdf
Extra-120324-Visite-Entreprise-icare.pdf
 
Technical SEO for Improved Accessibility WTS FEST
Technical SEO for Improved Accessibility  WTS FESTTechnical SEO for Improved Accessibility  WTS FEST
Technical SEO for Improved Accessibility WTS FEST
 
UiPath Studio Web workshop Series - Day 3
UiPath Studio Web workshop Series - Day 3UiPath Studio Web workshop Series - Day 3
UiPath Studio Web workshop Series - Day 3
 
3 Pitfalls Everyone Should Avoid with Cloud Data
3 Pitfalls Everyone Should Avoid with Cloud Data3 Pitfalls Everyone Should Avoid with Cloud Data
3 Pitfalls Everyone Should Avoid with Cloud Data
 
Explore the UiPath Community and ways you can benefit on your journey to auto...
Explore the UiPath Community and ways you can benefit on your journey to auto...Explore the UiPath Community and ways you can benefit on your journey to auto...
Explore the UiPath Community and ways you can benefit on your journey to auto...
 
CyberSecurity - Computers In Libraries 2024
CyberSecurity - Computers In Libraries 2024CyberSecurity - Computers In Libraries 2024
CyberSecurity - Computers In Libraries 2024
 
.NET 8 ChatBot with Azure OpenAI Services.pptx
.NET 8 ChatBot with Azure OpenAI Services.pptx.NET 8 ChatBot with Azure OpenAI Services.pptx
.NET 8 ChatBot with Azure OpenAI Services.pptx
 
How to release an Open Source Dataweave Library
How to release an Open Source Dataweave LibraryHow to release an Open Source Dataweave Library
How to release an Open Source Dataweave Library
 
Novo Nordisk's journey in developing an open-source application on Neo4j
Novo Nordisk's journey in developing an open-source application on Neo4jNovo Nordisk's journey in developing an open-source application on Neo4j
Novo Nordisk's journey in developing an open-source application on Neo4j
 

Sharepoint Saturday India Online best practice for developing share point solution

  • 2. MySelf 5 year of SharePoint Blogger, Speaker, Hobbyist photographer Technical Lead @ Kalsoft
  • 4. #Best Practice Quotes “We cannot control the winds, but we can adjust the sails.”  Anonymous “It's not necessarily the amount of time you spend at practice that counts; it's what you put into the practice.”  Eric Lindros “My secret is practice”  David Beckham
  • 5. Best Practice for Developing SharePoint Solutions
  • 7. SharePoint Solutions  General Consideration  Avoid unnecessary construction of Objects  Disposing objects  Object Caching  Optimizing code performance
  • 8. Avoid unnecessary construction ofSPWeb/SPSite Objects SPWeb  SPSite  SPWebApplication webApplication = SPWebApplication.Lookup(new Uri(System.String);  SPFarm farm = webApplication.Farm;  SPContentDatabase content = webApplication.ContentDatabases[S System.Int32];
  • 10. Disposing objects (Cont..)  Symptoms  Application pool recycle frequently, especially under heavy loads  System perform poorly, especially under heavy loads  System crash or do users experience unexpected errors such as timeouts or page-not-available errors, especially under heavy loads
  • 11. Disposing objects (Cont..)  Why Dispose?  SPSite class and SPWeb class objects, are created as managed objects  Each instance of SPSite and SPWeb contains a reference to an SPRequest object that, in turn, contains a reference to an unmanaged COM object
  • 12. Disposing objects (Cont..)  Rule of thumb Never dispose SPContext, SPContext.Site, SPContext.Current. Site, SPContext.Web, and SPContext.Current.Web.
  • 13. Disposing objects (Cont..)  using (SPWeb web = new SPSite(SPContext.Current.Web. Url).OpenWeb()) { // }  using (SPSite siteCollection = new SPSite(SPContext.Current.Web.Url)) { using (SPWeb web = siteCollection.OpenWeb()) { // }}
  • 14. Disposing objects (Cont..)  SPSite siteCollection = siteCollections.Add(URL, "DOMAINUser", EMAIL);  using (SPSite siteCollection = siteCollections.Add(URL, "DOMAINUser", EMAIL) { }
  • 15. Disposing objects (Cont..)  SPWeb web = siteCollection.AllWebs.Add(URL);  using (SPWeb web = siteCollection.AllWebs.Add(URL) { }
  • 16. Disposing objects (Cont..) Download the SPDispose Check tool http://code.msdn.microsoft.com/SPDispos eCheck
  • 17. Object Caching  public void CacheData() { SPListItemCollection oListItems; oListItems = (SPListItemCollection)Cache["ListItemCacheName"]; if(oListItems == null) { oListItems = DoQueryToReturnItems(); Cache.Add("ListItemCacheName", oListItems, ..); } }
  • 18. Object Caching public void CacheData() { DataTable oDataTable; SPListItemCollection oListItems; lock(_lock) { oDataTable = (DataTable)Cache["ListItemCacheName"]; if(oDataTable == null) { oListItems = DoQueryToReturnItems(); oDataTable = oListItems.GetDataTable(); Cache.Add("ListItemCacheName", oDataTable, ..); } } }
  • 19. Optimizing code performance  SPWeb myWeb = SPContext.Current.Web; myWeb.Lists["Tasks"].Title = "List_Title"; myWeb.Lists["Tasks"].Description = "List_Description"; myWeb.Lists["Tasks"].Update();  SPWeb myWeb = SPContext.Current.Web; SPList myList = myWeb.Lists["Tasks"]; myList.Title="List_Title"; myList.Description="List_Description"; myList.Update();
  • 20. Farm Solutions  Target farm level solutions to the specific web application instead of deploying to all web applications.  Try to deploy all the resource files (CSS, JPG) from within the Solution (Applicable to Sandboxed solution as well)
  • 21. Sandboxed Solutions  Plan which servers will run the sandboxed solutions service.  Plan which site collections will be able to run sandboxed solutions.  Design your Sand Boxed solution as per the Site collection quota
  • 23. Working With Large Lists  SPWeb.Lists[strDisplayName]  SPWeb.Lists[GUID]  SPWeb.GetList(strURL)
  • 24. Working With Large Lists (Cont..)  SPList.Items  SPList.Items.Add  SPList.Items.GetItemById  SPList.GetItems(SPQuery query)  SPList.AddItem  SPList.GetItemById(int id, string field1, params string[] fields)
  • 25. Working With Large Lists (Cont..)  SPList.Items.Count  SPList.Items[System.Guid]  SPList.Items[System.Int32]  SPList.Items.GetItemById(Syste m.Int32)  SPList.ItemCount  SPList.GetItemByUniqueId(Syste m.Guid)  SPList.GetItemById(System.Int32)
  • 26. Working With Large Lists (Cont..)  SPFolder.Files.Count  SPFolder.Files[System.String]  SPFolder.ItemCount  SPFolder.ParentWeb.GetFile(SPU rlUtility.CombineUrl(SPFolder.Url, System.String)
  • 27. Working With Large Lists (Cont..)  Deleting Versions  SPListItemVersion.GetVersionFr omID(System.Int32). Delete();  SPFileVersionCollection. DeleteByID(System.Int32);
  • 29. Event Receivers  Always use Event Receivers to execute the code immediately. Workflows can perform similar function but it will run as a timer job which may delay the code execution.
  • 30. Event Receivers (Cont..)  Instantiate an SPWeb, SPSite, SPList, or SPListItem  Update method  properties.OpenWeb()  properties.ListItem
  • 31. Timer Jobs  Always run the timer job in off hours  Always perform take out the timer job when deactivating the respective feature  Don’t use SPContext,SPContext.Current,SPCo ntext.Current.Web
  • 32. General Considerations  Use proper feature name and description.  Use the feature as it require by design.  Make sure solutions have proper consistent naming convention.  Use the correct older version of WSPs to retract the solution before deploying or upgrading the custom code

Hinweis der Redaktion

  1. Hello every one, good after noon every one, Welcome to SharePoint Saturday India Online and to my session. Let me assure you the next hour will be quite exciting for us.
  2. I am participating in this event from across the border. I am speaking from Karachi, Pakistan
  3. An SPWeb or SPSite object can occupy a lot of memory. Avoid constructing objects of these types simply to get a reference to a parent object. Instead, to get a reference to a web application, use the static SPWebApplication.Lookup(Uri) method, and pass it a Uri object that is created with the URI of the web application. You can then get a reference to the farm by using the Farm property of the web application object. (You can get a reference to a remote farm by using the static Open(String) method.) The ContentDatabases property of the web application object contains a collection of the content databases in the web application. You can get a reference to a particular content database through this property if you know its index in the collection. For more information, see the reference topic for the SPContentDatabaseCollection class.
  4. Each instance of SPSite and SPWeb contains a reference to an SPRequest object that, in turn, contains a reference to an unmanaged COM object that handles communications with the database server. SharePoint Foundation monitors the number of SPRequest objects that exist in each specific thread and in parallel threads, and adds useful entries to the logs.Whenever the number of SPRequest objects exceeds threshold (Default is 8), an entry appears in the ULS logs:
  5. Caching is a good way to improve system performance. However, you must weigh the benefits of caching against the need for thread safety, because some SharePoint objects are not thread safe and caching causes them to perform in unexpected ways.Caching SharePoint Objects That Are Not Thread SafeYou might try to increase performance and memory usage by caching SPListItemCollection objects that are returned from queries. In general, this is a good practice; however, the SPListItemCollection object contains an embedded SPWeb object that is not thread safe and should not be cached.
  6. The use of the cache in the preceding example is functionally correct; however, because the ASP.NET cache object is thread safe, it introduces potential performance problems. (For more information about ASP.NET caching, see the Cache class.) If the query in the preceding example takes 10 seconds to complete, many users could try to access that page simultaneously during that amount of time. In this case, all of the users would run the same query, which would attempt to update the same cache object. If that same query runs 10, 50, or 100 times, with multiple threads trying to update the same object at the same time—especially on multiprocess, hyperthreaded computers—performance problems would become especially severe.
  7. Avoid creating and destroying objects unnecessarily in code, as this may require that extra queries be made against the database and may even involve code that is incorrect. Tasks list must be instantiated each time the indexer is used to set properties and the method for updating is called. This is not a recommended practice.Tasks list object only once and assigns it to the myList variable in order to set properties and call the method.
  8. Target farm level solutions to the specific web application instead of deploying to all web applications unless you are deploying new feature to all the applications in the farm. This way custom feature for the specific web application won’t available on site collection features page or site features page on all the web applications in the farm.Try to deploy all the resource files (CSS, JPG) from within the Solution (Applicable to Sandboxed solution as well)
  9. I wont go into the details of the sandboxed solution here, but these are the general rule of thumbPlan which servers will run the sandboxed solutions service.Plan which site collections will be able to run sandboxed solutions.Design your Sand Boxed solution as per the Site collection quota
  10. Using the GUID is preferable because it is unique, permanent, and requires only a single database lookup. The display name indexer retrieves the names of all the lists in the site and then does a string comparison with them. If you have a list URL instead of a GUID, you can use the GetList method in SPWeb to look up the list's GUID in the content database before retrieving the list.
  11. When you delete multiple versions of a list item, use the DeleteByID() method; do not use the Delete() method. You will experience performance problems if you delete each SPListItemVersion object from an SPListItemVersionCollection object. The recommended practice is to create an array that contains the ID properties of each version and then delete each version by using the SPFileVersionCollection.DeleteByID method.
  12. Do not instantiate an SPWeb, SPSite, SPList, or SPListItem object within an event receiver. Event receivers that instantiate these objects instead of using the instances passed via the event properties can cause the following issues: Significant additional roundtrips to the database (one write operation can result in up to five additional roundtrips in each event receiver). Calls to the Update method on these instances can cause subsequent Update calls in other registered event receivers to fail.
  13. Make sure solutions have proper feature name and description. Feature name and description would be visible on the site collection and site features page.Make sure solutions have proper consistent naming conventionDeployment discipline – During the deployment and retraction process while updating or upgrading custom solutions, please use the correct older version of WSPs to retract the solution before deploying or upgrading the custom code with newer version of WSPs. This would ensure activating or deactivating features reference correct version of WSPs.