This isn't the first post comparing these two libraries so
I'm going to take a different take on this. I want to compare how viable each
of these is to apply to a new or existing project.
Why this post title is wrong
Firstly it’s not as clear cut as comparing one to the
other. These two libraries are very different and Knockout is just a small part
of what AngularJS does. If you want to compare an equivalent compare AngularJS
to Durandal.
This is a more complete solution for to compete with AngularJS.
http://www.johnpapa.net/compare-durandal-to-angular-not-knockout-to-angular/.
http://www.johnpapa.net/compare-durandal-to-angular-not-knockout-to-angular/.
The history
I was working on one of our legacy projects which only
support IE, god help me. The time had come for us to upgrade this solution, after
all people use other browser now. The main route of the problem was our old
legacy system used XML Data Islands. Most of you will not have used
this; I had never used it to working on this solution. Basically the concept of
these DataIslands was actually really good. First you define you object in XML
and then you bind the XML to the HTML using inline attributes on the HTML,
sound familiar.
If you are also in the position that you need to migrate
away from DataIslands I suggest you also looking at XML2JSON. This library allows you to move to
using something like Knockout without the need of rewriting your backend. It’s
only an interim solution but a great way to move forward when the budget
doesn't allow.
Comparing Data Binding
I'm only in my first 6 months of using these libraries so
this is an early comparison. We started to use Knockout, being a Microsoft
development team this come naturally. Problem happened when I head that Google
had something similar. I had to know what they were doing; most of us can
accept that Google lead web development.
I started to compare these two solutions, for binding only.
In all honestly when it comes to binding it’s hard to find a failure in either
of these libraries. However I did find a few things easier and this is likely
just down to our project.
Structuring your code
It's often one of the hardest things to decide with a new
project "how will I structure my files" is a common comment on new
projects. With AngularJS this is somewhat removed from your decision making.
AngularJS suggest/forces good practice for structure of objects and files. This
in its self is a great thing. The problem comes when you have a 10 year old
solution. Changing files here just isn't possible; the regression test alone
would blow the budget. If working on a Greenfield project I can see the benefit
of this as a starting point.
Syntax
Knockout syntax is great and simple if you are used to XML
Data Binding you pretty much can find a like for like syntax. Although
templating is altogether a different thing. If you again have a Greenfield or
never used binding before project then why learn Knockout when you can
learn AngularJS. Both these libraries have great and ever improving
documentation so you don't need to worry about the learning side.
AngularJS also has some neat syntax that can help make life
easier. Take for example the filter and sorting options when templating. These
really can add great functionality to your code for little effort. I'm yet to
see an ability to sort in Knockout, although I have seen attempts at this on
various boards.
Conclusion
Knockout is a great tool but go for Angular unless you are
migrating from some older form of data binding. For my project I have gone
with Knockout but on our new projects we are using AngularJS. It’s a difficult
choice.
I will keep you updated on how the project continues and our
final result. As the project continues we will face more unforeseen challenges.
References:
Some simple angular examples to get you going:
1 comment:
Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.Nice article i was really impressed by seeing this article, it was very interesting and it is very useful for me.
Angularjs Training In Hyderabad
Post a Comment