Hi Jack,
I'm certainly not as productive / good as you are (that's an overstatement, I'm way way less productive than you are) but while reading your code there are certain things I wish you'd have done that will make life much easier for the reader.
In many occassion you'd use a closure to protect the local variables when you define a top level objects
For instance while I was reading EventManager.js
at the beginning I see
At first glance I was thinking that this
is the constructor of Ext.EventManager.
Not until I see something like
I start to feel strange and then at at line 321 I see
Of course at line 322 we can cleanly see that it is a closure.
So my humble opinion is that if we wrap the function{} literal in parenthesis then it would be very clear from the start that it is not a constructor but a closure.
So instead of
this would be much easier to read.
I hope this makes sense. Maybe 10 years later this will help you pickup ext1.0 again faster :-)
I'm certainly not as productive / good as you are (that's an overstatement, I'm way way less productive than you are) but while reading your code there are certain things I wish you'd have done that will make life much easier for the reader.
In many occassion you'd use a closure to protect the local variables when you define a top level objects
For instance while I was reading EventManager.js
at the beginning I see
Ext.EventManager = function(){
.............
600 lines below
}
function(){...}
Not until I see something like
var pub = {.........}
return pub;
}();
So my humble opinion is that if we wrap the function{} literal in parenthesis then it would be very clear from the start that it is not a constructor but a closure.
So instead of
function() {
......
600 lines
......
}();
(function() {
......
600 lines
......
})();

|
#2
|
|
Considering how I am constantly trying to trim bytes, adding extra ones that serve no purpose doesn't look too appealing. At the top of the file and in the docs it is defined with @singleton (right before the closure starts) which should signal for you that it is a closure (since it can't be a constructor).
![]() |
本文通过解析《EventManager.js》中的具体实例,指出使用闭包保护顶级对象局部变量的做法可能带来的阅读障碍,并建议采用括号包裹函数声明的方式以提高代码可读性。
1307

被折叠的 条评论
为什么被折叠?



