[MUSIC]
Before we get started examining Angular in more detail, let's ask ourselves
the fundamental question, why do we need this JavaScript frameworks?
What exactly are they, and what do they help us
accomplish that we cannot do by using Standard JavaScript?
Let's examine some of these questions in a little bit detail in this lecture.
First, why JavaScript frameworks?
Obviously, from your prior experience with JavaScript and
also perhaps experience with web UI based frameworks like Bootstrap and
the use of jQuery, you more or less figured that you can
get most of the things that you want to done on a website accomplished,
using all these tools and techniques that you already have on hand.
Indeed, many successful websites can be implemented by using
these simple techniques and tools.
But as the complexity of your application grows,
the amount of DOM manipulation that needs to be done and the amount of
data updates that need to handled manually becomes significantly complicated.
The simple approaches like using the jQuery Library may
not sufficiently address the needs that you have on hand.
This is where the availability of well structured frameworks
like Angular which rely on standard,
software engineering paradigms or software engineering patterns like the model view
controller or the model view view model or the model view whatever, helps us to
implement these web applications effectively and scalably.
Now in this context, we're going to could talk about this in a little more detail
as we go along in this course.
We'll also talk about how we bind the model to a view and
the use of controllers and the view models to accomplish these things.
Will be discussed in a little more detail as we examine Angular in this course.
Let me quickly remind you of what a software library is,
a software library is a collection of implementations of
behaviors that you repeatedly use within your applications.
So these behaviors can be implemented by using functions with well-defined
interfaces so
that making use of them in implementing your application becomes straightforward.
If you have done programming in any language, you would often
see that many of the standard functionality that is supported
in these languages are implemented through libraries that you make use of.
For example, the input output libraries and perhaps even
the GUI libraries that many standard programming languages support.
This is where the concept of reuse of behavior is very,
very effective because we are able to implement it once in a library and
then reuse that behavior wherever we need within our software application.
This also brings in modularity to the way our application is implemented.
A good example of a software library that is used in the web world is jQuery.
If you had taken the previous Bootstrap course,
you would have seen some elements of jQuery in that course.
In this context,
let me also differentiate a software library from a software framework.
A software framework is an abstraction
in which the software provides such generic functionality and
then provides you with the ability of customizing that functionality for
implementing the solutions for your specific application.
So you will augment the software framework with your own code
in order to accomplish whatever that you are trying to accomplish.
So this is a different way of thinking about how you
attempt to solve the problem as opposed to using a software library.
Now, this software framework provides a universal, reusable environment
with certain functionality that is part of a larger software platform.
We'll look at Angular as an example of how this is accomplished in more detail.
There are several other such software frameworks that are used in the web world
including Ember, Backbone, and many others.
Now here, you might obviously think of the question.
How do you distinguish a library from a framework?
What are the salient characteristics of each and
why would you classify one as a library and another one as a framework?
Where do you draw the distinction between the two?
Now this I should say,
there is a fine line separating a library from a framework.
Depending on how you approach this, you may view one or
the other as either a library, or a framework, and
depending on who you ask, some people may classify a particular
approach as a library approach as opposed to a framework approach.
Again, let's not split our hairs about trying to exactly
classify things into a library or a framework.
From our perspective, if something helps us accomplish our task,
then we are satisfied with that approach.
Again, having said that, let's distinguish between a library and
a framework in a bit more detail.
In order to understand how you approach
that entire way of writing your application.
When you use a library as opposed to using a framework.
So in this context the following definition that I have borrowed
from AngularJS documentation sort of, I feel
gives a bit more clearer distinction between a library and a framework.
So, this definition says that a library is a collection of functions
which are useful for writing web applications, jQuery being an example.
So this is a set of functions that are available to you.
You make use of this functions when you implement your software
solution to your problem.
When you use this approach, it is you the programmer that is always in control
of how you leverage the functions that are provided
by the library to accomplish whatever that you are trying to do.
A framework on the other hand is a specific implementation or
particular implementation of a web application,
where the framework itself gives a broad generic structure for
your application and then you are asked to fill in the details.
The details that are necessary to customize that application
to solve the specific problem that you're trying to address.
So here, the framework takes complete control over how this applications run and
then it'll call in to your user supplied code that helps it to get the work done.
The app specific code is something that you will write and
supply it and that'll becomes part of the entire application,
together with the framework, and it helps to accomplish your task.
Again, this may not completely, clearly enable you to
understand the distinction between a framework and a library.
Let's again, as I said,
let's not spread our hairs trying to figure out all these details.
What we need to understand is Angular is an example of a framework and
when you write applications in Angular, the framework takes control and
you basically supply the missing pieces of the code that are required
to customize the framework to implement your specific web application.
Examining the word framework in a bit more detail.
When we talk about a framework, one of the important aspects about how a framework
operates is summarized by this term called as the Hollywood Principle.
What exactly do I mean by the Hollywood Principle?
Now, if you sort of know how a Hollywood agent works, when an actor or
an actress wants to find work in Hollywood,
they would approach an agent and the agent usually will tell you,
we'll call you back when we have some work for you.
Don’t call us, we'll call you back.
So, essentially a framework is reflecting the same kind of principle.
The framework says, you supply whatever you can do and
the framework will call your supplied code whenever it needs to do something.
That's the reason why we use this term Hollywood Principle in the software world.
This can also be summarized by using this other
expression called Inversion of Control.
When you use a library, you, the programmer is in control, and
you dictate how the code functions and how the code executes.
When you use a framework,
you are essentially surrendering your privilege to the framework and
lets that framework take charge and then dictate how the application is run.
Now while you may seem that this is like surrendering your independence,
certainly that is not the case, if framework has a certain reason for taking
up the responsibility of accomplishing whatever it needs to do on your behalf.
So this is a place where we would make a distinction between
two approaches to writing programs.
One called as the imperative way of writing programs, and
the second one called as a declarative way of writing programs.
If you have done any programming languages course,
you'll have seen that programming languages are usually using one or
the other approach that this support in writing programs.
In imperative programming,
you are going to specify the of program functions in a step by step manner.
So you are completely and control and
then you are essentially saying, this is how you have to accomplished the task and
then you'll write down step by step way of accomplishing the task.
So you as a programmer is completely in control in specifying exact steps
to solve the problem.
In declarative programming on the other hand,
which is effectively used by frameworks like Angular.
You are essentially saying this is what I want to get accomplished, and
this is how I customized what specifically I want to get accomplished.
How it is done is not of concern to me.
But I will hand over that responsibility to the framework.
So, essentially, you're supplying your user supply code to the framework and
saying, now this is what I want you to do, you take charge and make this happen.
So that way in declarative programming, you're only declaring what is your
intention and let the framework decide how that is going to be accomplished.
Two different ways of thinking about how you approach solving your problem.
This is something that you have to get your head around when you learn
Angular because if you are coming from the imperative programming world,
your general tendency would be to control everything and
dictate step by step how you want to accomplish.
So it takes some time to wrap your head around this concept that you
don't necessarily control every step.
Instead, you tell the framework what you want to become, to be accomplished.
And give the responsibility to the framework to accomplish
the task on your behalf.
Again, don't worry too much about it, and don't read too much into this definitions.
These are from an academic interest, these are base of identifying different
patterns of behaviors from the perspective of a web application developer.
All you care about is how you get your work
done using Angular as the web application framework.
Coming to the JavaScript frameworks world,
you will hear a lot of terms being used with JavaScript frameworks.
You'll often hear people talking about something called single pPage
application or a allied term called rich internet application.
Again, we will examine what this means in one of the later
lessons in this course in the context of Angular.
Similarly, you will also hear people talking about Model-View-Controller,
Model-View-ViewModel, Model-View-Whatever, and so on.
Again, this is as I said, a software architecture paradigm
that we use for developing software applications.
We'll talk a little bit more detail about this in the context of Angular,
in one of the later lessons.
And in this context, you would hear in Angular, things like data binding,
routing, one way and two way data binding, and so on.
Again, don't be thrown off by all these terms.
We will understand them as we go along in this course.
Similarly, you will often hear about scalable,
reusable, maintainable JavaScript code, and so on.
These are wonderful concepts or
wonderful attributes that we want to achieve with our application.
We will see how Angular helps us to do this in this particular course.
And another term that you will often hear people talking about is
test driven development.
Angular indeed support test driven development, so even before you develop
your application you will write the test in order to ensure that the code
that you implement actually accomplishes what you're trying to accomplish.
We will examine a little bit of test driven development towards the later part
of this course.
Although, if you want to adopt this test driven development approach for
implementing applications, that is a wonderful approach.
But before we go to that point, it is better for
us to understand what the framework itself helps us accomplished.
So, in this course, I will briefly deal with test driven development.
But if you were implementing a real Angular application, you would adopt
a test driven development approach for developing Angular applications.
There are many, many JavaScript frameworks that are available out in the real world.
Angular being a start.
Angular in its earlier incarnation
as AngularJS has been one of the most popular JavaScript frameworks.
We'll look at Angular in more detail as we go along.
Similarly, if you look at the JavaScript frameworks world,
you will hear people talk about Ember, Backbone, React.
Although, some people classify React as a library rather than a framework.
Again, depending on who you asks,
some people may say it is a framework and some people may say it is just a library.
Again, let's not worry too much about what it is but it is available for
us as an approach for implementing complex web applications.
Similarly, other smaller frameworks like Aurelia, Meteor, Polymer,
Google's Polymer which is an upcoming framework, Knockout, Vue and many others.
And there are more and more being added to this every single day.
What is the JavaScript framework flavor of today?
Angular.
It just got out of the development phase and out in to the real world.
And people are scrambling to develop applications using Angular.
So that's why we are interested in Angular in this particular course.
Now once you learn one of them,
you would begin to understand the gentle approach that this frameworks use.
You maybe able to pick up other frameworks similarly using
the general concepts that you learn in this particular course.
[MUSIC]