Tuesday, 18 March 2014

Getting to know Angularjs, the easier way.


For sometime now, I had been learning the Angularjs framework. Having imbibed in the mantra of the Mvc framework  for at least three years using asp.net mvc, I went looking for a javascript framework that rightly implements this design pattern with all its goodies. Guess what I found ANGULARJS!!!

I know that most of us have heard all the hype (if thats what you call it) about Mvc and Angularjs, although some of it aren't true but most of it is. Every now and then a new language/framework comes out claiming its own share of being the best thing that had ever happened to programmers since the birth of high level programming languages, in truth most of these framework are really good but some of them are total crap.

So what is the MVC design pattern

In this article, I will try to jot down most of the things that I have learnt about Angularjs and Mvc.  Mvc (Model View Controller) is a pattern that had been around for some time now, as far back as 1970 during the reign of smalltalk programming language and had been used in the development of many different user interfaced app, languages and frameworks. Mvc saw the light of day in the web application development world around 2000 when it was used in the Ruby on rails (I think).

As the name suggests, Mvc is a pattern that aide in the separation of concern in applications. It is used to separate or structure application according to its basic function. The M in Mvc stands for the Model and it is the engine and truth in an application. It is the part upon which the other tier of the application depends on for their structure and shape. Most times, it encapsulates the business logic of the application although its major use is  as DTO (Data Transfer Object) for  passing data from one tier of the application to the other (ie: from the controller to the View and vice versa). In Angularjs it is mostly used as a Data Transfer Object to pass data from the server to the controller and then to the View.

The V in Mvc stands for the View, it is the interface (User Interface) of the application through which the application communicates with its actors (users). It serves as the front end of the application that is used for displaying information, passing user generated events and taking in data from the user. It communicates with the Controller which then decides on the next action to take.

The C in Mvc is the controller. This serves as the traffic warden for the application. It controls and directs the execution of the different parts/facets of the application. Collecting data from the View, Validating the data, Calling the Business Layer of  the application for further processing of the data and saving the data to a persistent store. Generally speaking, the controller serves as the Boss or the manager in charge of decision making in the application and decides what needs to be done so as to make sure that the state of the application is maintained and the application functions efficiently as it should.


We have seen what the Mvc pattern is, in the upcoming post, we will start learning the Angularjs framework and  see how this Mvc model  is used in Angularjs, on our way to becoming masters in the use of the  framework.

No comments:

Post a Comment