Be mindful of the method names case sensitivity

Today I was trying to rebuild my sample application once again to understand the meteor framework once again (Yes, I like to repeat multiple times) and ran into run time error.

It turned out I had ‘Collection’ as ‘collection’. Collection has to start with capital C. I used webstorm to autocomplete the word and it never occurred to me that could be the problem.

Anyway, this is just note to self so I do not run into the same problem again.

Adding meteor package in Windows

I have been playing with Meteor on my mac after initial hiccups in Windows. Now I got a hang on it, I thought I give it a try again in Windows and turned out, it is was not that hard.

You need to start out at http://win.meteor.com/ it has different ways to get started in Windows.

I was able to get my sample app up and running in no time. After some simple Hello Worlds, when I started to dig in deep to Meteor, I hit the wall when trying to add a package that was not available through Meteor. In mac you can use ‘mrt’ and everything was peachy. It turned out it was not that difficult to install the packages in windows either. It takes couple of extra steps but other than that it is straight forward. There are an excellent set of instructions available here at https://www.discovermeteor.com/blog/using-meteor-and-atmopshere-on-windows/ and also at http://stackoverflow.com/questions/20949780/how-to-install-meteorite-for-windows

The simple idea is to create folder called packages under project root and clone the package project that you want to use from git. In my case I was trying to use iron-router. Here are the steps I did, on DOS box, go to project/packages folder

git clone https://github.com/tmeasday/meteor-router.git

This should create the meteor-router folder, rename it to iron-router and then clone the three dependencies you need to build iron-router. Stay on packages folder and run following git clone commands. This might change as Meteor matures.

git clone https://github.com/tmeasday/meteor-page-js-ie-support.git

git clone https://github.com/tmeasday/meteor-HTML5-History-API.git

git clone https://github.com/EventedMind/blaze-layout.git

After it downloads remove the ‘meteor’ from the folder names. Also make sure all the files made it to the sub folders. If you have problem getting files down, change to the package folder where you need to get missing files and run the following command

git submodule update –init

I had to run the update in both page-js-ie-support folder and HTML5-History-API and then rerun the git clone again.

Once you have all the files are in place. In DOS box go back the project root folder and install the iron-router.

meteor add iron-router

With the above steps, I was able to install and run the router like a charm in Windows.

Good luck.

Getting Started with Meteor Javascript Framework– A Review

As you might have seen from my last post I started poking around Meteor. Meteor has decent getting started guide and videos. I was looking for some decent place for me to start as a total newbie and found Getting Started with Meteor Javascript Framework by Packt publishing. I went through the sample chapter and looked interesting so I ended up buying the book and read the whole book in single sitting (5 hours).  I am going to use this blog to write about my experience with this book as I started learning Meteor.

For starters, there are very few items specific to 0.8 changes are missing in the book Like Handlebar to Blaze, {{login to {{> login etc., nothing major but I am sure they will update Errata with those changes soon. Since the framework is still not in production there might be more changes coming along the way. Also if you are going to try in Windows, I am not sure it is going to work, I tried few times but ended up switching to Mac and then everything just worked. I used webstorm as the editor. Since I have bee using it to develop my Angualr Apps. Back to the book, Version specific things aside, my over all experience with the book is outstanding. Let me tell you why.

The whole book is arranged in such a way, you learn the basic building blocks progressively and then put them together to build a decent application. I would strongly recommend learn by doing and this book is written with that intention. Fire up your mac and start reading the book, by the time you finish chapter 4, you will have a working application build with Meteor and as a side effect now you understand the fundamentals of Meteor.

This book is short and sweet. This does not go into the internal working of Meteor that much, rather focus on as a developer how do you go about building an application. That is exactly what I expected from this book. This book has only 7 chapters and that’s all you need to learn and get your self running in Meteor, each chapter is well thought out and has an excellent flow. On the side note, it is also testament to the beauty of Meteor framework, it is easy to learn and hit the ground running fast.

The whole book was like a conversation between the author and the reader. The first chapter get to you setup Meteor and create simple application to showcase the components of Meteor and get you acquainted with their basic structure. It shows, with simple example, where does the view, controller and model go.

From chapter 2 to chapter 4, author walks us through building Lending library application step by step. This where he explains the meat of Meteor why it shines and why Meteor could change the way we think about web development altogether.  One of the core feature or its shining light is ‘Reactive Programming’.  In this model, client and server are aware of data and meteor automatically pushes the model changes to client and server with out us writing ton of code and learning another new protocol. It just happen. Like I said, since it is one of the core things of Meteor, the author explains this idea very clearly with very less code so that as a reader we can appreciate the power with out walking through too much code.

Chapter 3 started out with some theory on MVC, MVVM to explain how Meteor fit into MVVM model. Even though it make sense, I was not completely sold on the idea Meter falls in to MV* pattern. When I think about MVVM (Silverlight/Angular) though, VM was pure code and which is not aware of anything about View. The underlying silverlight framework glued the view model properties to view. But in Meteor, when I look at the controller code, there was so much of view bleeding to it. Again, I am still a newbie so there might be better way to do it so that view is totally isolated from controller. But do not skip this theory part since the section titled ‘Cached and Synchronized data’ is crucial to understand how Meteor keep the data in sync with client and server.

Chapter 4 is where we put lot of meat to the code to make it like an decent application. This chapter covers lot of ground and I did not like the flow on this chapter though. This is the only chapter I had some heartburn. In this chapter as you make changes, you have to wait till end of the chapter to see the fruit of your labor. So I ended skipping the author’s flow and start implementing view/controller at small yet complete so that I can see I am making progress. Even then I was making lot of mistakes (like missing . or _ or missing semi colons) so if I was going to put all together and then debug the code, it would have been miserable. Oh by the way, I was writing every line of code instead of copy pasting. I did on purpose so that I get used to what ad why am I typing? So as I said before, I jumped between this chapter to identify each feature associated in template/model and javascript code so that I can see my progress and debug the code in small chunks.

By the time you come to chapter 5, you already have a decent size application running. From here on out, next three chapters are required for you to understand, as we start building public facing website, how do we control our ‘Reactive Programming’ so that only the users who need to see the changes see the changes and also how to fine tune the data flow between client and server. They were explained very well and stayed at a level it made perfect sense. Also the additional links in the book for anyone interested to learn more also helped.

Chapter 6 and 7 closes the book explaining more about how to setup your project directory structure and how to deploy your application. Meteor deployment was really pleasant surprise. Author explained the three models how to deploy and what are the things to watch out for really helped as well.

Overall I really enjoyed the book and in 5 hours I was able to develop a good application and learned the basic fundamentals of Meteor and starting to love the new way to develop web application. The book highlighted the core features very well and as I developed the application, I really started to appreciate the simplicity of Meteor.

On the flip side, I thought one very important aspect was missing in the whole book. There was no mention of how to go about doing TDD or to write end to end testing. As a software developer I start to enjoy TDD and if it is not supported as first class citizen in the framework, we will be missing out a lot. I did search and found couple of videos on the testing but did not watch them yet.

But over all it is an great book for anyone new coming into Meteor, it is worth the money and time well spend.  I really looking forward to develop more application in Meteor.

Starting out in Meteor

Its been a long time, I blogged, I have been very busy at work, learning and doing lot of work on software architecture area like Domain Modeling and understanding overall structure of our application using Struct 101 and other goodies.

I am still learning and developing application on both Angular and CujoJS when I get time.

I am still enjoying cujoJS but for a change and to learn something new I started looking at Meteor framework. By the way, I recommend using Mac to learn Meteor purely because of the support.

As I was progressing through example, I did run into small problems but they are important ones so I though I will document them here for my future reference.

1. Make sure you have mongodb installed.

npm install –g mongodb

2. When you starting out to use Mangodb to get the collection, the collection definition must be outside isClient check like the following

People = new Meteor.Collection(“People”);
if (Meteor.isClient) {
    Template.People.PeopleCollection = function() {
            return People.find();
    }
}

** Two things to watch out here.

** See there is no var infront of People in collection definition on line (1)

** Make sure the collection definition is outside if condition so that it runs on client and server.

There are ton of great videos, tutorials out there, as I go through them I will try to collect them and put them in a list.