This project has moved and is read-only. For the latest updates, please go here.

Constructing a reusable framework

Mar 23, 2014 at 4:46 PM
Hi Marc! I'm creating an AngularJS framework & am very inspired by SPServices. Any recommendations for best way to structure a JS library for reuse?
Mar 23, 2014 at 4:50 PM
Of course the answer is "it depends". ;+)

Is your library going to be the middleware between AngularJS and SharePoint? If so, check out the excellent work Andrew Connell has done with AngularJS and Breeze:

Can you tell me more about what you are trying to accomplish?

Mar 23, 2014 at 7:13 PM
Thanks Marc. The more I dig into Breeze, it seems to do a lot of the stuff I am trying to accomplish. The reason I started the framework was to provide a reusable angular module to quickly interact with SharePoint data when building an app.

The main reason I wanted to gain your insight is to see what guidance you may be able to offer to make the code as reusable as possible, like you did with SPServices. Things like method chaining, error handling, etc.
Mar 24, 2014 at 2:14 PM
You're probably best off jumping on the train with Andrew, as he's been working with the Breeze folks to make everything work well with SharePoint.

My biggest recommendation about building anything client side with SharePoint is to try to think like a Web developer first and a SharePoint developer second. By that, I mean that the patterns that are considered "best practice" on the client side have usually been solved outside the SharePoint realm.

With SPServices, I was lucky in a sense that there wasn't anything already there from Microsoft for patterns. It was the SharePoint 2007 timeframe, so CSOM didn't exist yet.

I looked at other jQuery libraries and plugins that had nothing to do with SharePoint to determine the best way to build SPServices. I'd change a few things if I could, but generally I built something that makes sense to Web developers. This means that to many people, SPServices feels easier to use than CSOM, which was written with the .NET developer in mind. In a sense, my own ignorance of .NET development served me well.