Add Node.JS to your learning plan

I had the pleasure of attending a fast & exciting session at this year’s Microsoft Ignite Conference called “Building Business Apps Like They Do in the Valley with AngularJS, Node.js, and More.” by Andrew Connell. It was one of those sessions that made me very thankful that Microsoft is now recording these sessions and putting them up on Channel9. In case you did not have the ability to see this session yourself, feel free to check it out here: https://channel9.msdn.com/Events/Ignite/2015/BRK4123

Andrew’s session can certainly add more detail than this blog post but I walked away with two very important ideas:

1. Server-side capability – Node provides the ability to for JavaScript to be run on the server vs just the client. That opens it up for some interesting possibilities when building provider hosted applications.

2. Client-side development improvements – Andrew talked about NPM (Node Package Manager) which is a way of downloading libraries/frameworks using Node. He did not go into great details but looking into NPM – I found that there are other libraries that could be used to automate certain development tasks such as Grunt.js which is a JavaScript task runner which can do things like minify JavaScript files.

For those of you out there who are starting to learn JavaScript and are moving from C#, I believe that looking into Node.JS appears to be a very good idea as part of your 2015 learning plan.

 

Advertisements

What’s in a namespace?

If you have attended any of my sessions on beginning Client Side Development you might have heard me talk about ensuring that you do not promote the public namespace. For SharePoint/O365 Developers who are starting to learn client-side the concept of namespaces are common in C#, but not as common in JavaScript. The whole purpose of developing under a namespace is to ensure that your variables do not collide with other variables, resulting in broken functionality, errors, etc.

The approach that I take to address this is by creating a unique object and then working under that object as a pseudo-namespace.

For example:

var jaredApp = jaredApp || {};
jaredApp.GetData = function(){

console.log(“This functionality exists under jaredApp”);

}

You could follow that approach and build out your other functions – and then it is as easy as jaredApp.GetData(); to call the function. The benefit of this is all of your variables fall under jaredApp (or whatever you decide to call it), rather than binding to the window object which is where variables are assigned by default – this is also referred to as the global namespace.

There are a couple of other approaches such as the immediately invoked function execution (IIFE) which looks something like this:

(function(){
console.log(“This functionality exists temporarily within this invoked function”);
})();

The nice things about the IIFE is all variables created within it are scoped within that function therefore they would not be bound to the global namespace, which prevents collisions.

Happy SharePointing & JavaScripting!

2015 – New Year, maybe a bit more blogging

Much like folks make New Year’s resolutions to lose weight, stop smoking, etc.. I’m making the resolution to blog a little bit more. If anything, it’s a place where I can go to lookup my own tips & tricks. 🙂

I’m going to open up 2015 with some posts about getting started with JavaScript development. I’m actually doing this for two reasons:

1) I find that forcing myself to try and teach/help others will only help to improve my existing knowledge of a subject
2) I remember how difficult it was getting started and the type of information that I hunted for (and still look for) when attempting to build SharePoint solutions using JavaScript.

Hopefully this mini-series will be helpful to the 1-2 folks that accidentally stumble upon my blog.. Likely by accident..