29. September 2014

Getting started with, Dojo Toolkit

To begin with, Dojo Toolkit or simply referred to as Dojo is one of many libraries in javascript. First thing to do is, like any other javascript libraries, make sure which version of library you are studying and using. Dojo has gone through major upgrades and if you are trying to do things the new way of Dojo then better get to know the new version. We will be focusing on the new version only(currently 1.10) and referring to old one, wherever necessary.

Dojo Toolkit has got a combination following

  • A bare bone of functionality ( dojo )
  • A widget library ( dijit )
  • An experimental library ( dojox )
  • An Unit testing framework
  • A compiler to do the minification and optimisation

A lot of javascript libraries try to implement the classical programming concepts and Dojo is another one of them. So, if you are a purist in Javascript, Dojo will dissapoint you. The functional nature of Javascript is also eliminated here. Dojo clearly disagrees to say that function is a first class citizen, which is again denying another nice feature of javascript. Well, but if you are coming from a classical programming background, that means from a programming language which is class based like Java, then Dojo will seem natural. So, we will refer them in classical terms rather than Javascript terms.

The core functionality of the toolkit is wrapped in a package called dojo. Everythig that runs in the toolkit depends on this basic package. Next is dijit, which can be called as a component library or in dojo’s terms these are widgets. Now dojox is a package containing experimental widgets, which will eventually go into dijit , once they are stable enough. Since widgets have to live a life of their own, there is a flow of lifecycle events. It is now obvious that any application using these widgets have to abide to these lifecycle events and some rules as a whole. In Dojo’s terms these are framework rules.

Happy Coding.

23. August 2014

Checklist to join a corporate

It is a surprise for me, to see the processes these companines follow to get a person on board. I am not talking about interview. The technical interview is kind of rounds after rounds of never ending interviews. But at least, these are ok-ish situation for a tech person.
The real pain starts, once you get through the interview. Now you are selected and need to serve the notice period at old organisation and move on to join the new one. The problem is, once you are through the interview, this new companies will call you at least 5 times a day. This is plain and simple irritating. They will force you (no one can force you, but at least they will talk like that) to join before the scheduled time. If at all, you have joined them by keeping their words, there would be no respect at all for that. Once you come to join them, they will show how much process they follow! Really?!! If you follow all these, why you kept on calling a person who has not joined you? Where were your processes! Or is that a process of yours to trouble someone, who is not from your organisation! Simple stupid. So you make your own process, follow your own process and change that at will.
Well, just keep in mind that once you have come to join a new corporate, keep below things with you. These companies will not tell you, when they should have, that please bring all these with you.

  1. Your own laptop (only windows with Internet Explorer)
  2. Your own datacard for internet
  3. Your phone with roaming activated

Once these are done, keep below things with you.

  1. Your cheque book
  2. Your father’s identity proof
  3. All your previous residing locations proof
  4. Two friends’ addresses and contact from each of all previous location and company
  5. Two local friends’ contacts and addresses (if they are not, create them !)

Well last but most importantly keep “your common sense and simplicity” at home. Just rember that these are just mindless machines working for a factory which does not have and can not respect to have a brain.

Never giveup.

24. June 2014

AngularJS 101

It took me sometime to make me comfortable in AngularJS. There are a lot of tutorials, discussions and videos out there about AngularJS. I would suggest, go through them and go through as many as you can, before jumping into code with this framework. We will be looking at the very basics of the framework here and for version 1.3 and above, of the framework.
You must heard about MVC or Model-View-Controller architecture and AngularJS. While thats true, lets keep that for a little late.
First of all, just remember that $scope is model object and sometimes referred to as ViewModel. Then there are Views, which are either HTML tags or full html files. And then Controllers, which are javascript files. At this point always remember that AngularJS revolves arround these View and Controller. The data this View displays is the same as the data the Controller modifies and is available through $scope. No matter what, $scope remains in the middle as this
View <---$scope---> Controller
Now, since AngularJS already uses 2-way data binding any changes to data or $scope in View or Controller is reflected by each other.
An AngularJS application begins with a module named ng-app and this ng-app is generally only one. So what is a module ? Module is kind of self contained small applications inside a big application. The special module ng-app is the only exception as its the big application and everything else in AngularJS world happens inside it. All other modules generally go inside ng-view, have a look at this html page for the reference.In terms of AngularJS, a module is a combination of a View-$scope-Controller. Everytime you need to load this module, the View gets loaded in the ng-view and its Controller gets initialised along with the $scope. All these mapping are written in a Route, which maps View with Controller, take a look at this. Route is a separate module as of AngularJS version 1.3. So, one need to include the JS file and the dependency. A quick reference of an AngularJS application looks as below

  • HTML page
  • ng-app (root module)
  • ng-view (sub modules load here)
  • first JS file for Route and other things
  • Route maps URL paths with sub-views and their controllers
  • sub-views(HTML partials or pages) are loaded inside the ng-view and initialied with their controllers

So far we are good. The next thing is, we can still make it more modularised. AngularJS allows, something called as Directives, you may think of it as components. Inside a Module, we can write our custom directives, which are custom HTML tags along with its controller. But always remember, Directives are part of View. So the $scope is also available to them. Now, there are different pre-built modules with AngularJS for different job in hand, like $http is for interacting with web services. Refer to the project here, which I have created to better understand the basic of an AngularJS application. Always remember, anything in AngularJS that we write falls upon either View or Controller and there is always $scope available to both of these.

I would love to listen your inputs on this, please leave a comment for discussion.

Happy Coding.