Hi,

Thanks first for your pointing out that I did not provide enough fact to 
support my belief.

JS itself has already taught me that OO is not everything since 6 years ago 
when I first started to write js code. And I totally agree with you on this 
spot. I love functional patterns as mush as you as a long-term JS coder. But 
the thought of OO, although we are coding functionally, is used everywhere in 
that code. My point is that this part of using the thought of OO can be more 
intuitive and concise instead of writing code that is hard to read by others.

Let us put this belief on some facts.

There is some code of the angularjs source. 
https://github.com/angular/angular.js/blob/master/src/jqLite.js

I wonder how much time it takes you to figure out the following questions.

1. Is jqLite a constructor or a function? -- yeah, it is used as both a common 
purpose function and a constructor. Without read the fully code or detailed 
document, it's hard to guess how to use it. Ok, maybe not a big problem.

2. Which kind of object does jqLite construct or what methods does the object 
constructed by jqLite provide? -- This becomes a little tough to figure out, 
right? It seems that it owns 3 methods only by the line jqLite.prototype = ... 
. But it doesn't. The code following adds many other methods to the prototype. 
So, without reading the whole file, you even can not know how many methods an 
object owns. Still not a big problem? Maybe.

3. Is the code following the ':'s the methods of objects constructed by jqLite? 
( e.g. ... find: function(element, selector) ...) Is the 'this' of those 
functions refer to an jqLite object? You probably will say yes and yes,  and to 
be honest, this is also what I would say when I read this file the first time. 
But in fact, no and no. The code near the end of this file 
(...JQLite.prototype[name] = function..) wrap the methods above it in another 
anonymous function. So, even with little unread code, you still will make a bad 
understanding of the code. Isn't it a problem? Ok.

Another fact. If intuitive OO isn't as much needed as I said, why ECMAScript 6 
standard adds 'class' to the language? 

Best Regards,
Leo

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to