First time here? You are looking at the most recent posts. You may also want to check out older archives or the tag cloud. Please leave a comment, ask a question and consider subscribing to the latest posts via RSS. Thank you for visiting! (hide this)

August 2011 Blog Posts

Summer time learning: Getting started with Node.js

It is now a consolidate tradition for me to publish, during summer time, a list of the books I liked reading or that I bought and are sitting on my shelves (or, lately, more and more on my iPad) waiting to be read.

In the last years these lists contained .NET and development methodologies books and web development books (jQuery and JavaScript). The topics of the book in this year’s list are a bit different. There will still be a bit of web development on .NET, but due to the nature of the projects I did in my spare time, the list will mainly be about WP7 development, Arduino/InternetOfThings and one of the cool technologies with which I’m experimenting lately, which is Node.js.

Instead of 11 or 13, this year there will be more books, so I’ve split my summer reading list over 4 posts:

Why Node.js and what it is

Lately there has been a lot of talking about this new technology, that replaced Ruby and Rails as the cool technology of the moment. While Ruby and Rails never caught on me, Node.js really did.

I declared in a few other occasions I’m a web developer at heart, and my first programming language was LiveWire, the first implementation, on Netscape server, of a server-side JavaScript library, in 1996. Node.js immediately sparked my interest: a return to my origins.

Node.js is basically a server-side JavaScript library that handles web requests in an asynchronous and event-driven way. It’s low level API, but the cool thing is that tons of libraries and modules have been built on top of it; what at first sight can look just like a super-scalable low-level networking and parallel library, is becoming a complete development platform full of high-level libraries. If you look at similarity in the .NET universe, Node.js is like an asynchronous HttpHandler, on top of which all Microsoft web frameworks, WebForms and ASP.NET MVC, have been built.

Node.js runs on as standalone server, on Linux, Mac and Windows, but lately there has been a lot of discussion in the .NET twitter/blog-sphere about a project developed by Microsoft that allows running Node.js directly from inside IIS.

Scott Hanselman wrote a very nice post explaining what Node is, why it matters and how you can run it inside IIS, and Tomasz Janczuk, the author of the IIS-Node.js bridge, wrote a few post explaining how to install and get started with it, how to host an Express based application on IIS (more on Express later) and how to use WebMatrix and IIS Express to work with Node.js.

Are you convinced now?

Books and resources to learn Node.js

This post was meant to be about books, wasn’t it? Unfortunately there are not many Node.js books around and most of the knowledge is available in form of online tutorials and screencasts. But here there two (probably the only ones?) that are targeted for beginners that don’t want to hunt for information on the web.

The Node Beginner Book

A very concise 86 pages (at least that’s what my iBook says) eBook that will guide you from “novice to advanced-novice” while building a image uploading application. It won’t teach you best practices but will show you all the various aspects of building a Node.js application. The book is available online for free, or on github, together with code samples. Or if you don’t want to kill trees printing the book or want the convenience of having it nicely formatted as eBook, you can buy it for 10USD in bundle with the Hands-on Node.js book. For the cost of 3 coffees you get all you need to get stared with Node.js

Hands-on Node.js

Once you have completed the sample application presented in the previous book, the next step is Hands-on Node.js, also available on Amazon Kindle (as well as in bundle together with The Node Beginner Book). It starts by giving a bit of theoretical explanations on the eventing model of Node.js, and later it covers all the built-in modules of Node.js. It covers some automated unit testing and debugging tips as well. The thing I liked is the extensive usage of exercises that will make you learn the concepts even better (and it has the solutions at the end of the book).

Node.js in Action

UPDATE: As Maurizo says in the comment, there is also Node.js in Action from Manning. Still in MEAP (Early Access Preview), scheduled for release in Spring 2012, you can read the first chapter “Why the Web needs Node.js”.


The books are over, but the same author of Hands-on Node.js has a screencast called NodeTuts in which he explain how to work with Node.js. The first episodes are about installation and basic stuffs, but the following ones are more advanced and cover also external libraries and frameworks.

How To Node

Another good source of information is How To Node. More advanced topics than NoteTuts but based on older version of Node.js and lately not updated that much. The geeky thing about this blog is that it runs on Node.js powered blog engine called Wheat and contents are hosted on GitHub.

JavaScript books

Node.js is Javascript, so everything you know about programming in JavaScript still apply here. And to learn the best way to write JavaScript you can also read the books about client-side JavaScript development, like the ones I listed in my previous summer reading lists. For example, JavaScript: The Good Parts by Douglas Crockford or Pro JavaScript Techniques and Secret of the JavaScript Ninja by John Resig.

External modules and libraries

But Node.js by itself will take you nowhere: it shines if used with external modules that will help you build web apps without having to deal with low-level processing. There are tons of modules, but I want to highlight some of what I think are the most popular and useful:

  • Backbone.js and underscore.js – not specific to Node.js, they are standard JavaScript libraries than can also be used in client-side JavaScript development, even in conjunction with jQuery. One is a library that helps making sense of all data used in a JavaScript application, with the help of key-value lists and more. The other brings functional development to JavaScript.
  • Spine.js is again a standard JavaScript library that implements the MVC pattern. Can be used with Node.js to build a MVC web application.
  • Express.js is a generic web framework for Node.js, but not MVC based.
  • Mustache is a templating engine for JavaScript, and many other languages, including .NET.
  • Mongoose.js is a MongoDB “driver” for Node.js.
  • is a library for building applications based on the HTML5 WebSockets specs. Both server and client side.


At the end this turned out to be more a Node.js jump-start guide rather than a list of recommended books, but I hope you find it useful anyway.

Did I miss some good book or Node.js online reference? Do you have any other Node.js module you cannot live without? Please comment and let me know.

In the next days I’ll blog about more books for this (end of) summer.

Tips I got from the Umbraco community

I’m not a Umbraco expert, actually I never did a real website in Umbraco till now. So being a developer that tries to adopt agile methodologies and tries to remove as much “friction” as possible I was a bit disappointed by the development and deployment experience in Umbraco. But the great community compensate pretty well the missing features (at least missing for my scenario) of Umbraco, and at the end my site came out fine, and thanks to their suggestion I’m now a much better “umbraco developer”.

I want to share with you some of the suggestion I received on twitter.

One site per instance vs many sites per instance

For “historical” I had to develop the site inside an instance together with other sites. Well… never do that, unless you develop, deploy, maintain the sites in the instance all together. Also, don’t do that if the sites don’t share the same media contents and the same templates. Unlike Orchard and DNN where “tenants” are completely separated and multi-tenancy is just a way to increase site density, in Umbraco all media, styles, scripts, templates, macros are shared between all the sites.

So, it’s ok if you want to have a multilingual web site (, and, or if you want to do a site for each event of a series (like the triathlon world championship series which has, and so on). But not if you want to have and

Document Types

For people not initiated to umbraco, a Document Type is something like the “model” of the page. They have fields, and they are hierarchical, just like normal POCO classes. But unfortunately they are not as “agile” as normal classes.

I started creating all my nodes in a list with the same DocType, with the basic fields. But then I realized that for some pages I needed more fields. So I thought: “I just create a new DocType that inherits from the base DocType, I add the 2-3 fields I need, and I change the type of the node”. That’s also I do when I write normal applications. It was great until I tried to change the type of the node: that is not possible. So at this point I had two options which I didn’t like:

  • Create a new node with the new type, and copy all the contents
  • Manually change the type of the node in the database

I understand why changing DocType of a published node can be a bad idea (data loss), but in some situation (when changing to a child type) this operation is safe. Also, the child type is not automatically allowed where the parent node is: remember to add it to the allowed nodes or you won’t be able to add nodes of the child doc type.

Here the community came to the rescue and suggested me this awesome extension, called “Doc Type Extensions” that allows extracting a base type from a DocType.

In some other cases inheritance might not make sense, for example when each page have a title, a description and tags. If you adopt inheritance to solve that situation, you will have all your DocTypes inheriting from a base doctype. What about composition over inheritance? Another extension suggested to me via twitter introduces “mixins” to DocTypes creation: DocTypeMixins. With this you can reuse the same group of fields in different document types.

Additional data types

Data Types are the type of each field in a Document Type. They both define the real type of the field (integer, string, boolean, etc), but also, and most importantly, the control that will be shown to the user to edit its value.

Umbraco has a lot of them already, but if you want more, go and download the uComponents library.


This is another super weak point of Umbraco, and despite all the time spent discussing this on twitter this morning, I think a lot can be done to improve the deployment experience.

Let me explain where the problem lies:

  • everything (both development artifacts and contents) in Umbraco has a id (well, obviously you might say), but this id is not a GUID, but it’s a numeric id.
  • everything is referenced with everything via these ids.

You probably might already see where this is heading: if you copy the content to a new server, ids will change, so references will break. Not a problem for development artifact as they are usually referenced via their alias. Same happens when you have links: they are done via the friendly url which doesn't change with the id. Problems are when you reference images or other nodes via their id: you'll end up with tons of broken images and links.

Unfortunately there is no easy solution for this without the help of external components. One solution might be the backup and restore of the DB, but that will work only if deploying to an empty instance, and will not work if upgrading an existing site, or if you have more than one site per instance.

The umbraco HQ released, at the beginning of this summer, Courier 2, an evolution of the old syncronization tool for umbraco: it automatically takes care of the changing ids, fixes the references and is also supposed to fix hard-coded links and references in templates and CSS. Looks good. Too bad I find it out only when I had already manually copied and fixed all my content.

Browser based development

Another thing I don’t like is the fact that Umbraco needs you to work inside the browser: datatypes, document types, macro have to be developed from within the web application. In theory you could also write templates and scripting files in the web browser, but unless you have to apply a quick (and dirty) change to fix a urgent bug in production, you’d better put all your files in a Visual Studio solution and work from there.

Another suggestion I received, to have a complete out of the browser development experience also for document types is uSiteBuilder. I still have to try it, but it seems like this package might also make automated deployments possible.

Is community a feature?

Most consulting companies, when comparing software solution don't give the right importance to the community factor: my short experience with the umbraco community showed that even a relatively small community, if full of smart and helpful people, can even overcome technical defects, weak points and missing features of a software.

What about Orchard

I think I'll now try to redo the same website in Orchard, to be able to compare the development and the user experience of the two main CMS in the .NET space.

Tags: , ,

Summer Courses on HTML5, Windows Phone7, ALM and Azure


This August, if you are on holiday and are not in snorkeling in a lagoon in a tropical island, or if you are work but not many things to do due to the summer period, you could spend half an hour (or half a day, or a full day) getting up to speed with the latest cool technologies of the moment:

All these pages contain lots of links to videos, books and other useful information and tools to help you learn the technologies of your choice.