Skip to main content

Cloud

SPDX Released into the Wild!

I have finally posted my SPDX open-source project onto CodePlex (http://spdx.codeplex.com). Feel free to use it on your SharePoint projects. Other people and I have used it on 4 projects already and found it stable and useful.
SPDX is a development tool that makes it easier to write software that works with data stored in SharePoint Lists. It generates strongly-typed entity classes based on the List or the Content Type definition, enabling use of InstelliSense and virtually eliminating run-time errors.
Tool Description
When writing code that accesses the data stored in SharePoint lists, one always needs an in-memory representation for that data. There are two ways to represent the data.

The “Quick and Dirty” way — using SPListItem object directly to represent the data in memory.

Pros:

  • Quick: no need to write additional code
Cons
  • No IntelliSense
  • Not strongly-typed
  • High chance of run-time errors
  • Need to keep code in synch with underlying Content Type or List
The “Right” (but Tedious) Way

Pros:

  • IntelliSense
  • Strongly-typed
  • If custom class code is correct, very low chance of run-time errors
  • Good OO design: can extend the class
Cons:
  • Tedious to map every column
  • Mapping is error-prone
  • Pain to keep in-synch with the underlying Content Type, List or Doc Library
  • Not much fun
Both of these approaches are less than ideal. It would be great to use second approach without the extra work it requires.

Enter SPDX: The “Quick” and “Right” Way

  • Automatically generates and regenerates strongly-typed wrapper entity classes based on List or Content Type definition (the List or the Content Type must already be defined in SharePoint).
  • Works with Lists, Document Libraries, and Content Types
  • Majority of errors are now found at the compile time
  • SPDX is distributed as a SharePoint solution (it is a .WSP file) that installs in the development SharePoint environment and is used to generate the wrappers. There is no need to have it installed in production in order to use the wrapper classes.
  • Batch support – a command line executable that can generate the wrapper classes. Sometimes this can be useful to include in the pre-build event.
  • Automatic vlidation based on SharePoint meta-data
  • Treat SharePoint choice coulms almost like enums
  • Easily traverse lookups columns
  • Detailed exception error messaages (unlike generic SharePoint exceptions)
  • Facilitates good OO practices
  • etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.