Skip to main content
Glimpses of Daniel's world

M101JS Week 1

On August 12th the first M101JS (MongoDB for Node.JS developers) course started. Previously I completed both the M101J (MongoDB for Java developers) and M102 (MongoDB for DBAs) courses available through 10gen's education site.

What new material could I gain from completing yet another developers course? The main reason is that Node.JS caught my attention as a development platform. The second reason is that it's being a while since I tinkered with MongoDB. When I finish this course I will have refreshed my MongoDB knowledge and got some experience with Node.JS in the form of a blog application.

I decided to document my progress in (at least) weekly summaries. This will be part one of seven.

For this series of blog posts I will structure each post into an introduction (you just passed it) and two sections. The first section, Lectures, will summarize what I learned from the videos and related examples. In the second section, Homework, I will mention what I learned from practicing the homework assignments and anything I might have done extra because of it.

Lectures

From the first few video lectures it is already clear that the mindset of a developer should be different. Most of my interactions with JavaScript, and I believe many developers, never went further than simple HTML DOM manipulations or form validation using frameworks like JQuery. Most of those little JavaScript tasks can be done in a synchronous manner, blocking until the task is completed. In order to write highly responsive applications with JavaScript it is best to make asynchronous calls, something most commonly seen when using AJAX to build the user interface of a website. The outcome of tasks is dictated by responding to feedback whenever it might arrive, or timing out in an appropriate way. In other words, there is heavy use of callback functions which might not be easy to understand because the data flow isn't easily captured in the code.

Even if asynchronous programming is new to me, MongoDB isn't. This means I can focus on understanding the JavaScript part, since I probably already know the Mongo way. If the setup and difficulty level of this course is the same as the others I worked through, then most of the code will be handed to me and all I have to do is complete some part of a function until it returns the correct value. I do hope some of the evaluation scripts will be able to weed out any inefficient JavaScript I will inevitably produce.

Skimming through the curriculum I saw that the Mongoose library will only be mentioned in week 7. From previous experience I know that means it's primarily bonus material to the course. This means my fellow students and I will wrestle with the Node.JS Mongo driver throughout the course. I expect to learn how to optimize MongoDB interaction in ways that would mostly be abstracted by libraries like Mongoose. At the moment my opinion is that Mongoose is to Node.JS and JavaScript like Hibernate is to Java. Most will use it as a decent performing  intermediary between the data in storage and the objects that will be manipulated by the application.

Homework

At the end of the week you've got to do your homework. So that's what I did. Actually it's ok to miss a week of homework, because the week will the lowest scores (or a random week if you're perfect) won't count in the grading. I decided to do the homework assignments anyway, because for the first week it's usually configuration checks of your learning environment.

This time I put considerable time into setting up my learning environment. The first plan was to set it up in the cloud. I would use some Mongo hosting service and an online IDE to do all the assignments. Remembering that some weeks might require you to start several mongo server instances or load lots of data into the database, this was not an option anymore. The second plan was to mix cloud and a local virtual machine. I failed to properly set up Cloud9 IDE on my virtual machine, which made me go with the last plan. The last plan is to just use a virtual machine. No hosting, no cloud, just a virtual machine on my laptop.

Setting up the environment isn't that difficult if you understand the minimum requirements of MongoDB and the course. Through the course you can use a 32-bit system, but you will get some nagging remarks from MongoDB saying it won't run in optimal and recommended configuration.

I went with a 64-bit CentOS VirtualBox virtual machine with 3Gb of RAM memory available to it. MongoDB required met to have at least 3Gb of free disk space, without it the server wouldn't start in normal mode. This made me create a virtual hard disk that could dynamically expand until 12Gb if needed. Most of the time you won't used much disk space, it just needs to be available. Another option would have been to set a flag for MongoDB to use smaller journaling files. I specifically chose not to use smaller journaling files for now.

CentOS came with a default firewall configuration that prevented me from accessing any service but SSH from outside of the machine. A while ago I decided to always have two network interfaces in my virtual machines, one in a private network and the other able to download through a NAT configuration. This meant I just had to enable any traffic on the internal network interface and I would be ready to use the system.

I'm looking forward to what next week will bring. Of course I will write about that as well.