20

Suggested SharePoint Development Standards

Assembly Development:

 
File Headers:
  • In the top section of each file (code, xml, aspx, etc) supply the following information:
    • Company name and copy rights
    • Author name
    • File
    • Purpose
    • Create Date
Custom Configuration:
Config File:
  • When possible try to not store custom settings in the web.config file. Use a separate file on CONFIG folder.
  • File name should follow this format:
    • [Customer]_[Supplier Name]_[Solution name]_Configuration.config example:Adventureworks_JSolutions_Branding_Configuration.config
  • Entries to web.config keys must be communicated beforehand to the customer.
  • Entries to web.config (user names or passwords) must be encrypted.
  • Entries to the web.config should be inside a block of comment which contains the solution name and description.
Property Bag:
  • Should be used for storing only primitive types.
  • If the values are user-defined, provide a web interface to edit those properties from custom actions on central administration on each property scope.
Features:
  • Ensure that each feature GUID is unique in the farm.
  • Ensure that each feature folder name and title should follow this format:
    • [Customer].[Supplier Name].[Solution name].[Feature Name]
    • example: Adventureworks.JSolutions.Branding.HideLinks
  • Ensure that all the features has a appropriate name, description, updated version number and icon.
  • Features with event receivers should clean up all changes created in activation as part of the deactivation routines. If the feature creates a list that contains user data, the feature should not delete this list.
  • Farm and Web Application features should never be hidden.
  • Site Collection and Site features should be hidden.
Solution (WSP):
  • Ensure that new solutions have a unique GUID in the Farm
  • Ensure that the new solution version number is incremented (format V#.#.#)
  • Solution naming convention must be descriptive: 
    • [Client Name].[Supplier Name].[Solution or module name]_[Version number].wsp                                       
    • example: Adventureworks.JSolutions.Branding_v1.0.0.wsp
  • In case of an update solution action is required for installation,solution name must not be  changed. 
  • The solution package should not include any of SharePoint installed files.
  • Referenced assemblies should not be set to copy local = 'true'.
  • All prerequisites must be communicated to the customer and pre-installed as stand-alone components for easier administration.

 Tools for Building the Solution:
Tools for Quality Assurance:
  • Use FXCop for identifying and fixing performance and security issues in source code.
  • Use the CAT.NET to help identify security issues in the solution source code.
  • Use StyleCop to identify code style and naming conventions issues. 
  • Use the SPDisposeCheck tool
Source Control:
  • All source code must be under a proper source control (like TFS or SVN).
  • All internal builds must have proper labels on source control.
  • All releases have proper labels on source control.
Quality Assurance:
Release to Customer:
  • Provide an Installation Guide which contains the following items:
    • Solution name and version number.
    • Targeted environments for installation.
    • Software and hardware Prerequisites: explicitly describes what is all needed updates, activities, configurations, packages, etc. that should be installed or performed before the package installation.
    • Deployment steps: Detailed steps to deploy or retract the package.
    • Deployment validation: How to validate that the package is deployed successfully.
    • Describe all impacted scopes in the deployment environment and the type of impact.
Enjoy !!!

2

Transition to SP2010: Impact on developer part1

Solution Architects (and developers) need to be aware of a few changes between SharePoint 2007 and SharePoint 2010.
Keep this in mind when upgrading SharePoint 2007 or WSS 3.0 web parts or custom code to SharePoint 2010.


WSS 3.0 to SharePoint Foundation 2010:
Deprecated features (will eventually be removed):

  • Stsadm command-line tool: The Stsadm command-line tool will be superseded by Windows PowerShell 2.0.
Features and functionality no longer available in SharePoint Foundation 2010:
  • 32-bit operating systems: SharePoint Foundation 2010 requires a 64-bit operating system.
  • Side-by-side installation: The ability to perform side-by-side installation of Windows SharePoint Services 3.0 and SharePoint Foundation 2010 on the same server is being removed.
  • Gradual upgrade: Support for the gradual upgrade feature is being removed as part of the removal of Side-by-side installation.
  • Web discussions:Web discussions enable users to add comments about documents and pages without modifying their actual content. SharePoint Foundation 2010 does not support Web discussions.
  • SQL Server 2000 data sources: SQL Server 2000 does not fully support many of the newer data features available in SharePoint Foundation 2010 and have been removed.
  • ODBC data sources: Newer and more versatile database connection options have replaced the functionality of ODBC.
  • Version 3 themes: The functionality provided in the version 3 themes is not available in the newly designed version 4 themes.The new version architecture is not compatible with the architecture of version 3 themes.
  • Web bot software agents: Search crawlers and indexers are examples of Web bots. Developers can no longer use Web bot entry points and users cannot add Web bots to SharePoint Foundation 2010 sites. (Use Web Parts instead of Web bots.)
  • E-mail enabled groups and Microsoft SharePoint Directory Management service (DMS): The Microsoft SharePoint Directory Management service (DMS) connects SharePoint sites to an organization's user directory to provide enhanced e-mail features. If a SharePoint farm is using DMS, users cannot enable SharePoint groups to use e-mail.The type of authentication used in DMS is being replaced with claims authentication.)
  • Permissions for sub-webs: In SharePoint Foundation 2010, if you want to give different permissions to a sub-web, you must assign a separate permission level to the sub-web. Site collections that are upgraded from Windows SharePoint Services 3.0 and have these unique permission level structures will continue to work. However, the user interface in SharePoint Foundation 2010 does not have a way to edit an inherited permission level at the sub-web scope, so you cannot change them or create new permission level definitions of this type.
  • Internationalized domain names: removed.
MOSS 2007 to SharePoint Server 2010:

Deprecated features (will eventually be removed):
  • Stsadm command-line tool
  • Site Directory feature:This functionality will be replaced by the social features of the User Profile service.
  • Scorecard export to Reporting Services.
  • Business Data Catalog: Replaced with Business Data Connectivity service.
Features and functionality no longer available in SharePoint Server 2010:
  • All features and functionality removed for SharePoint Foundation 2010 applies to SharePoint Server as well as the items listed below.
  • Office Web Components: The PivotChart, PivotTable, and Trend Chart report types are no longer available as options in the SharePoint Dashboard Designer.
  • Web discussions: Now use the Note Board feature.
  • Storage Management page: The Storage Management (storman.aspx) page is now removed from the Central Administration Web site.
  • Shared Services Provider (SSP): Service applications replace this functionality.
  • Site directory template: replaced by Enterprise Content Management (ECM) solutions.
  • News portal template:replaced by Enterprise Content Management (ECM) solutions.
  • Collaboration portal template: replaced by Enterprise Content Management (ECM) solutions.
Object Model:
There are also a number of Obsolete types and methods.
They will continue to work in your custom code and solutions, but they will generate compiler warnings, and you should update your code to use the new types.

The following site (http://code.msdn.microsoft.com/sps2010deprecated) contains 3 text files:

SPS2010NewlyDeprecated.txt lists the types and methods that have been made obsolete in Microsoft SharePoint Server 2010 since the release of Microsoft Office SharePoint Server 2007.
SPS2010Deprecated.txt lists all of the types and methods that are obsolete in Microsoft SharePoint Server 2010.
OfficeSharePointServer2007Deprecated.txt lists all of the types and methods that are obsolete in Microsoft Office SharePoint Server 2007.

3

Economic Impact of SharePoint 2010

Competitive markets coupled with the poor success rate of software projects make it very hard to justify significant financial investment in renewal of existing I.T. systems.

The total annual cost of worldwide IT failures is $6.2 trillion dollars, according to calculations performed by Roger Sessions, über-expert enterprise architect and CTO of ObjectWatch. (These are without doubt very scary numbers!)

I firmly believe that every I.T. professional has a responsibility to contribute to improving the success (and value) of the industry.
One of my fact-finding journeys leads me to an investigation on how such I.T. failures measure up against I.T. successes. The business value (cost saving, increased productivity and more importantly the role which evolution of technology play on industry advancement) should not be overlooked.

I believe that SharePoint Server 2010 is one of the platforms which provide an organization with enormous financial benefit if implemented successfully. 

Below I summarize a report which supports my statment.

In December 2009, Microsoft commissioned Forrester Consulting to examine the total economic impact and potential return on investment (ROI) that enterprises may realize by deploying Microsoft SharePoint Server 2010


Forrester used a five-step approach for this study:

1. Forrester gathered data from existing Forrester research relative to next-generation collaboration tools, the enterprise collaboration platforms market in general, as well as the emerging trend of using Microsoft Office as a front end for line-of-business information and processes.
2. Forrester interviewed Microsoft marketing and strategy personnel to fully understand the potential value proposition of SharePoint Server 2010.
3. Forrester conducted a series of in-depth interviews with 11 organizations currently using SharePoint Server 2010.
4. Forrester created a composite organization based on the interviews and populated the framework using data from the interviews as applied to the composite organization.
5. Forrester constructed a financial model representative of the interviews. This model can be found in the TEI Framework section below.


Key Findings:
ROI: The risk-adjusted ROI for the composite company — not including any productivity benefits is 108%, with a breakeven point (payback period) of fewer than 12 months after deployment.
Benefits: Quantified benefits accruing to the composite organization, which reflect the experience and the expectations of the companies interviewed for the study, amount to approximately $3.1 million (risk-adjusted, present value [PV]) over a three-year period. 
Costs: The costs for the upgrade to SharePoint 2010 sum to almost $1.5 million (risk-adjusted, PV) over the first three years.
(these costs include implementation labour, professional services fees for taxonomy development of an information architecture, and additional server hardware costs)

Risk-adjusted cash flow:














Total Risk-Adjusted Cost:

Total Risk-Adjusted Benefit:

The data collected in this study indicate that standardizing and centralizing on a platform based on SharePoint Server 2010 has the potential to provide a solid return on the investment. The risk-adjusted ROI of 108%, along with a rapid payback period (breakeven point) raises confidence that the investment is likely to succeed, as the risks and uncertainty that may threaten the project have been considered and quantified.

Based on these findings, companies looking to implement SharePoint Server 2010 can anticipate significant cost savings and efficiency gains. Using the TEI framework, many companies may find the potential for a compelling business case to make such an investment.

References:
The Total Economic Impact Of Microsoft SharePoint Server 2010
Prepared for Microsoft by Jeffrey North, Principal Consultant - March 2010
http://download.microsoft.com/documents/uk/enterprise/75_the_total_economic_impactTM_of_Microsoft_SharePoint_Server.pdf




4

Every Employee Tends to Rise to His Level of Incompetence

This morning a colleague shared with me a very interesting theory (thanks Steph!).


It is called the Peter Principle.


The Peter Principle is the principle that "In a Hierarchy Every Employee Tends to Rise to His Level of Incompetence."


The Peter Principle is a special case of an ever-present observation: anything that works will be used in more challenging applications until it fails.


I gave this theory a lot of consideration and realized that it applies to all aspects of life...


I am a D.I.Y. enthusiast. I have a limited range of tools at home and sometimes I will try to use a tool which works perfectly in its own intended application for something which it was not meant to be used for.... because I push a tool beyond its limits it will in many cases fail and pose a risk of damage, setback, additional costs to be incurred or even injury.


In an organizational structure, the Peter Principle's practical application allows assessment of the potential of an employee for a promotion based on performance in the current job; i.e., members of a hierarchical organization eventually are promoted to their highest level of competence, after which further promotion raises them to incompetence. That level is the employee's "level of incompetence" where the employee has no chance of further promotion, thus reaching his career's ceiling in an organization. The employee's incompetence is not necessarily exposed as a result of the higher-ranking position being more difficult — simply, that job is different from the job in which the employee previously excelled, and thus requires different work skills, which the employee may not possess.


For example, a factory worker's excellence in his job can earn him promotion to manager, at which point the skills that earned him his promotion no longer apply to his job.


Peter's findings states that "in time, every post tends to be occupied by an employee who is incompetent to carry out his duties" and adds that "work is accomplished by those employees who have not yet reached their level of incompetence".


I personally have observed situations from within the organization as well as in social circles where individuals need to face new challenges and responsibilities. It is very interesting to learn how many individual's potential is choked by a fear of such challenge and I have seen them stagnate. In other situations I have seen that an individual are not able manage the stresses and challenges and thereby retract (demote) himself to a safe and comfortable position – and thereafter show fear of such challenges again.


One way that organizations can avoid this effect is by having a policy that requires termination of an employee should they fail to attain a promotion after a certain amount of time. Even in instances where an employee can handle their current job but fail to do any better, they can still cause harm within the company, by way of preventing those beneath them with higher potential of moving up, as well as lowering morale once such employees become aware of this fact.


Another method is to refrain from promoting a worker until he shows the skills and work habits needed to succeed at the next higher job. Thus, a worker is not promoted to managing others if he does not already display management abilities.


Some organizations recognize that technical people may be very valuable for their skills but poor managers, and so provide parallel career paths allowing a good technical person to acquire pay and status reserved for management in most organizations.


References:
http://en.wikipedia.org/wiki/Peter_Principle






10

Developing a List Definition in SharePoint 2010



This tutorial will guide you through creating a SharePoint 2010 List Definition using Visual Studio 2010.

Open Visual Studio 2010

From the Visual Studio 2010 menu, select File --> New --> Project....
Select the Visual C# --> SharePoint 2010 --> List Definition project template.
Enter "Music" in the Name textbox and click on OK.

In the SharePoint Configuration Wizard select "Deploy as farm solution" and click on "Next"




















Enter "Music" in the What is the display name of the list definition? textbox.
Select Custom List in the What is the type of the list definition? drop-down box.




















In the Solution Explorer, expand ListInstance1 and open the Elements.xml file (do not confuse this Elements.xml file with the other Elements.xml file which is on the same level as ListDefinition1)


 
Within the ListInstance element change:
      the Title attribute to Music
      and change the TemplateType attribute to 10001.


Now, open the Elements.xml file which is on the same level as ListDefinition1.
Within the ListTemplate element, change the Type attribute to 10001 and add the DisallowContentTypes=”FALSE” attribute, as shown below.

<?xml version="1.0" encoding="utf-8"?>

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Do not change the value of the Name attribute below. If it does not match the folder name of the List Definition project item, an error will occur when the project is run. -->
<ListTemplate
Name="ListDefinition1"
DisallowContentTypes="FALSE"
Type="10001"
BaseType="0"
OnQuickLaunch="TRUE"
SecurityBits="11"
Sequence="410"
DisplayName="Music"
Description="My List Definition"
Image="/_layouts/images/itgen.gif"/>
</Elements>

Insert the following xml into the top of the Elements element in the Elements.xml file. This XML describes the Music Item content type the list will store.
<ContentType

ID="0x010089E3E6DB8C9B4B3FBB980447E313CE94"
Name="Music Item"
Group="Custom Content Types"
Description="Music item content type."
Version="0">
<FieldRefs>
<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" />
<FieldRef ID="{cb55bba1-81a9-47b6-8e6c-6a7da1d25602}" />
<FieldRef ID="{0248c82f-9136-4b3a-b802-d0b77280b3bc}" />
<FieldRef ID="{aa4a82dd-5b32-4507-9874-4e1c7bca3279}" />
</FieldRefs>
</ContentType>

Insert the following xml into the top of the Elements element in the Elements.xml file. This XML describes the Fields the Music Item content type uses.
<Field Type="Note" DisplayName="Description" Required="FALSE" NumLines="6" RichText="FALSE" Sortable="FALSE" ID="{cb55bba1-81a9-47b6-8e6c-6a7da1d25602}" StaticName="Album Description" Name="Album Description" Group="Custom Columns" />The Elements.xml file should now look like the following.


<Field Type="Text" DisplayName="Title" Required="FALSE" MaxLength="255" ID="{0248c82f-9136-4b3a-b802-d0b77280b3bc}" StaticName="AlbumTitle" Name="AlbumTitle" Group="Custom Columns" />


<Field Type="Text" DisplayName="Artist" Required="FALSE" MaxLength="255" ID="{aa4a82dd-5b32-4507-9874-4e1c7bca3279}" StaticName="Artist" Name="Artist" Group="Custom Columns" />












































In the Solution Explorer, open Schema.xml
Add the EnableContentTypes=”TRUE” attribute to the List element inside of the Schema.xml file












Insert the following XML into the ContentTypes element in the schema.xml file. This XML describes the Music Item content type this list will store.

<ContentTypeRef ID="0x010089E3E6DB8C9B4B3FBB980447E313CE94" />



















Insert the following XML into the Fields element. This XML describes the fields the list will store. These are directly related to the fields in the Content Type we added in the previous step.

<Field Type="Note" DisplayName="Description" Required="FALSE" NumLines="6" RichText="FALSE"

Sortable="FALSE"
ID="{cb55bba1-81a9-47b6-8e6c-6a7da1d25602}" StaticName="Album Description"
Name="Album Description" Group="Custom Columns" />
<Field Type="Text" DisplayName="Title" Required="FALSE" MaxLength="255"
ID="{0248c82f-9136-4b3a-b802-d0b77280b3bc}"
StaticName="AlbumTitle" Name="AlbumTitle" Group="Custom Columns" />
<Field Type="Text" DisplayName="Artist" Required="FALSE" MaxLength="255"
ID="{aa4a82dd-5b32-4507-9874-4e1c7bca3279}"
StaticName="Artist" Name="Artist" Group="Custom Columns" />

Insert the following XML into the ViewFields element in the 2nd view, BaseViewID="1". This XML describes which fields should be visible in this particular view. BaseView 1 is set as the default view and this is the view the newly created fields should display in.

<ViewFields>

<FieldRef Name="Attachments"></FieldRef>
<FieldRef Name="LinkTitle"></FieldRef>
<FieldRef Name="Album Description"></FieldRef>
<FieldRef Name="AlbumTitle"></FieldRef>
<FieldRef Name="Artist"></FieldRef>
</ViewFields>
 
 From the menu, select Build
From the menu, select Deploy
Open your target SP2010 website in a browser session.
Under Lists in the left-side navigation, click on Music to view the new list.

















Enjoy !

6

Nice Tool to Troubleshoot SharePoint Exceptions




When developing custom solutions for SharePoint 2007 (or WSS3.0) it might at times be very challenging to troubleshoot exceptions.

The exceptions can be caused by anything from the underlying SQL database (eg. incorrect roles assigned or a full log file) to Native SharePoint problems.
(many cases by incorrect usage of the SP object model during custom assembly development).

Many times SharePoint will only provide an user with an error description as follows:
HRESULT: 0x80004004 (E_ABORT))
Cannot complete this action – please try again.

It is therefore very hard for a developer, administrator or tester to pinpoint the problem.

The UBER COOL news is that there is a nice utility to help to monitor SharePoint diagnostic tracing.


SPTraceView moniors in real time all SharePoint diagnostic tracing (also called ULS tracing) and can notify you using a balloon-style messages in the tray bar when any information of particular interest to you is sent (traced) by any of the MOSS services and components.

For example if you haven’t disposed all SPSite/SPWeb objects properly from your code, which also will cause unmanaged memory leak, you will see a message similar to the one below as soon as the page that contains your web part is rendered:









Even configuration errors will be shown:







Because SPTraceView processes the tracing in real time you can identify errors and events as they happen. That is as soon as you interact with the SharePoint GUI when testing/debugging your custom SharePoint solutions including web parts, event receivers, workflows and all other SharePoint technology components.

As soon as you run it, SPTraceView will start receiving all messages from MOSS and will start checking if any of them match filters defined by you. The default filter matches all messages which severity level is: Critical Event, Unexpected, Exception, Warning Event, Assert or Unassigned.

If you click on the SPTraceView icon in the windows tray you will notice the following action menus:








You can configure your settings by choosing “Configure” from the context menu. The configuration form will show up and you will be able to choose the monitored levels and what you want SPTraceView to do when any of the messages match your filter.















SPTraceView allows more complex include/exclude filters to be configured by selecting the “More Settings” button.

If you want to intercept the trace messages from more than one server in your farm you will need to have SPTraceView running in each of the servers you want to monitor
The default option is a “Local Machine Viewer” (also called “Stand Alone Viewer”). In this mode SPTraceView will only capture and process the trace messages on the local machine. This is probably what most developers need when they develop in a single server farm or virtual machine.

To view the list of historic messages, double click on the SPTraceview icon in the system tray and you will see the following window:


For more information check out http://sptraceview.codeplex.com/
















4

SharePoint 2010 Visual Web Part

This is a tutorial to develop a simple Visual Web Part for SharePoint 2010.

Open Visual Studio 2010
From the menu, select File --> New Project.
In the New Project dialog window, choose Visual C# --> SharePoint 2010.
Select Visual Web Part from the Project Items.

Give your project an appropriate name. I used "WPHello2010".
Click on OK to proceed.

In the SharePoint Customization Wizard, provide the url of the SharePoint 2010 site on which you want to deploy your web part and set the trust level to "Deploy as a farm solution".
I will in another blog explain sandboxed solutions. It is also possible to change the settings later (see the new ShrePoint tab in your Visual Studio Project Properties dialog - later in this tutorial)
Click on 'Finish' to allow Visual Studio to generate the project.

When VS2010 is done with generating the project files open the solution explorer pane and check out the new files which was automatically generated. This is a great improvement from the VS2007 way constructing a deployable web part solution !

You will see that a Feature was generated, a Pacakge was generated and a Visual Web Part was also generated.


In the Solution Explorer, select the project and view the properties in the Properties pane. You will see that you can set the "Active Deployment Configuration". This setting will allow you to control the actions which gets executed when you deploy your web part from within Visual Studion. In a step below I will show how to setup your own custom actions profiles.
You will also see that you can set the Assembly Deployment Target. This is a great way to ensure that you assemblies are directly deployed to the GAC instead of the bin folder.
The Sandboxed solution is set to false - I will explain in another post.
The Site URL is the target SP2010 site where your solution (web part feature) will be deployed to.

You will also notice the VisualWebPartUserControl.ascx which was automatically added.
  
Lets explore the new VS2010 Project Properties Dialog. (for information only)
You will see that a new "SharePoint" tab is now available - jipeee !!
On this tab you can setup and select a "Active Deployment Configuration" (ADC)
The selected ADC can contain a number of steps which gets executed in a specific order to control deployment and retraction of the solution.

If you select an existing configuration and click on "View" you will see which available actions have been selected for deployment and retraction within this action set.
This means that I can select an existing action set or create my own custom action sets. I can then specify which action set my solution must use during deployment and retraction.

One important thing to remember is that in SP2010 Beta, you cannot use the .Net framework 4.0. So please ensure that your solution targets the .Net framework 3.5
  
OK, so lets get back to our web part development for SharePoint 2010.
In the solution explorer, select the VisualWebPart1.webpart file and click on code view.
Change the properties of "Title" and "Description" to something more meaningful.
  
Switch to design view and add controls to your usercontrol.
I added a Button and a Label.
  

Double-click on the button to view the Button1_Click method... (please ignore my lack of good naming conventions !)
Add a bit of code to the Button1_Click event. I added code to change the Label1.Text value.

In the solution explorer right click on the project and select "Build". After the build was successful right click on the project again and now select "Deploy".

If your project's "Active Deployment Configuration" was set to "default" the solution should be deployed to the target SP2010 site and the feature should be activated by default.

This means that you can open your SP2010 site (or refresh) and edit the default page.


Select "Insert" and then "Web Part".
In the "Categories" list you will now see a "Custom" folder.
When you select the "Custom" folder you will see your new developed visual web part.
Double click on the web part to add it onto the page.


If you now click on the button in the visual web part you will notice that the label changes.

 There we go... we have successfully developed a very simple Visual Web Part for SharePoint 2010 !!!

Enjoy !!