Thursday 30 May 2013

Learning JavaScriptMVC Review

JavaScriptMVC is an open-source Rich Internet Application framework based on jQuery and OpenAjax. It extends those libraries with a model–view–controller architecture and tools for testing and deployment. As it does not depend on server components, it can be combined with any web service interface and server-side language.

Packt Publishing requested that I review their new book on the subject, Learning JavaScriptMVC by Wojciech Bednarski, available to buy from Packt's website here:
http://link.packtpub.com/hFZPlQ

The book starts with a preface which points out that the JavaScriptMVC framework is a client side only technology and gives an overview of the six chapters and what they cover, as well as the usual intended audience and conventions used in the book.

Chapter one starts with an introduction to JavaScriptMVC, giving details of its constituent parts: StealJS, FuncUnit, jQueryMX and DocumentJS. The chapter moves on to describe the advantages of using the JavaScriptMVC framework over other alternatives, and spends some time discussing the advantages and disadvantages of different web application architectures.

With the what and why of JavaScriptMVC laid out the author goes on to offer three methods of getting up and running with the framework:

  1. Download the complete package from the official website.
  2. Pull code and libraries from the authors GitHub.
  3. Use Vagrant to download and configure a ready to go virtual machine.

The author discourages using the first method for anything other than a fast try-out, recommends the second method for actual deployment, and advocates the third method for development as it provides an encapsulated development environment.

I'd never used Vagrant before, and liked the idea of a preconfigured and encapsulated dev environment, so I was exited to try out the third method. In retrospect I should have been suspicious of any method which requires you to download literally gigabytes of software to use a JavaScript framework.

Installing Vagrant and it's dependencies on my Linux Mint machine was pretty straight forward, just using:

apt-get install vagrant

VirtualBox is a dependency of Vagrant which was also installed. Next I downloaded the specified Vagrant configuration file and issued the command to fire up the preconfigured server and dev environment, very exciting:

vagrant up

Hundreds and hundreds of megabytes of downloads later and Vagrant reports that the server cannot start because VirtualBox required me to make changes to my BIOS settings.

Lets just think about this for a minute, installation of multiple software packages, a 1.3 GB virtual machine image download and a BIOS setting change just to run a client side JavaScript framework – and this is the recommended method to get started - absolute madness.

I persisted with the Vagrant method and continued to follow the instructions in chapter one to build a Todo list, until I noticed that changes I was making to the pages HTML and JavaScript files were not being reflected in the browser when refreshed.

After some Googling, I found this explanation and solution - clear the nginx cache in Vagrant:

http://jeremyfelt.com/code/2013/01/08/clear-nginx-cache-in-vagrant

The commands I executed in addition to the above information:-

vagrant ssh
vagrant@lucid64:~$ sudo vi /etc/nginx/nginx.conf
vagrant@lucid64:~$ sudo service nginx restart

Finally after getting a working dev environment I typed out the code in the chapter to get the basic foundation of the application. I fired up my browser to the URL specified and it didn't work.

I'd already wasted too much time on this method and decided to abandon Vagrant, and try method two - get the files from GitHub.

I quickly installed Apache web server on my machine and cloned the authors GitHib repository. I moved my source files and reloaded the project in my browser. It didn't work again.

Last but not least I decided to try the first installation method described by the author - downloading the complete JavaScriptMVC package from the official website. This method gave me an installation of JavaScriptMVC which worked. I would recommend this method.

I completed chapter one, typing out the remaining code for the application, only to find myself with an app which did nothing and reported no errors.

I also took the downloadable source code for the chapter provided by the author and ran it, only to achieve the same result.

At this point I have given up on the book, I can't waste any more time trying to get the code to work. There is no point in learning how to document and test an application which doesn't work.

This book has made me frustrated and angry and I couldn't recommend it any less. I can only assume this book is a cruel joke by the author make me feel stupid and unproductive. Hopefully I can still get some use from this book, come winter I will be using it as a £14.99 fire lighter.

You may find other reviews of this book less ranty:


Downloads From Packt