On 2010-07-18 02:42 PM, David Mark wrote:
ext-touch-debug.js..............458k
[...]
Where does this "native-first dual approach" term come from? I know
what you mean, but I've never heard it called that.
I have named the query antipattern Native First Dual Approach, or "NFD
approach".
The NFD approach is to try to use `document.querySelectorAll`, where
supported and where it is either unsupported or where it throws an
error, a fallback selector matching engine is used.
Libraries that use NFD include jQuery, YUI, and Ext-js, among others.
Native-first Dual Approach Diagram
(query input)
|
<Native QSA Support?>
Y N
| |
| |
[Try Use QSA] +-- [Use Fallback]
| / |
<error thrown?> / <Fallback Supports Input?>
Y N-+ Y N
| /| | [Throw error]
| / | | |
[Use Fallback*] | [perform match |
| and return result] |
| | |
[return result] | |
| | |
END END END
Diagram of native-first dual approach. Notice the three different
possible endings.
Most queries with attribute or pseudoclass selectors will have a
different path depending on the browser, version, and rendering mode.
Libraries that use NFD include jQuery, YUI, and Ext-js, among others.
Dojo does the opposite. Dojo uses the fallback first and then, if that
works, tries to use querySelectorAll. This might seem odd, but when the
problems with NFD query engine is understood, it is much safer. Another
approach is to filter all input by defining an `isValidQuery` type of
function to make sure that it is valid.
CSS Selectors are recursively defined:
| selector
| : simple_selector [ combinator selector | S+ [ combinator? selector
| ]? ]?
As such, it is not possible to parse one with a javascript RegExp
because javascript RegExps are not recursive. The input must be parsed.
Normative Reference:
CSS2.1 said:
Each bug in Ext-JS's selector engine necessarily propagates to a higher
level. When the selector engine's behavior is changed, that change is
propagated to all of the higher level dependencies. Such behavioral
changes cause instability. The alternative to causing such changes is to
not fix the bugs.
I haven't bothered tracking down all of their problems as nobody has
offered me any money to do so.
[...]
If it had simply handed queries off to `querySelectorAll`, it would not
have created as many problems.
Yes, I forgot about their inexplicable preprocessing.
It's like car with shoes for wheels. I could never forget that.
Clearly tacked on my author(s) who had no idea what they were doing (a
common theme with these things). Who knows what they were thinking as
there are no explanatory comments.
There are from me. I explain exactly what the code does. I did not have
to test it before making the analysis to know exactly how the code would
perform and where it would fail.
I was able to find the defects very quickly.
For such a Frankenstein-like effort it probably is. Much of it sounds
like it is describing ExtJS.
Actually the current Ext-JS version does not support XPath. The code
comment appears to be a hold-over from past jQuery copying efforts which
had, in older versions of Ext, supported XPath.
Regardless, to code comment is wrong. The code does not do what it says
it does.
It is a singleton in the sense that there is only one of them.
The various "privete" code comments are false claims.
[...]
There's very little CSS3 in Sencha, despite the disingenuous ad
campaign. Not much HTML5 either. Who knew marketers lied?
The source code explains what it does. Those who are unable or unwilling
to analyze the source code won't know. Fortunately that does not include
me.
The thread isn't as negative as some might see it. I showed that I can
provide good code reviews that anyone at any level of experience -- the
authors included -- should be able to appreciate. The review on the
query engine provided a good model for making code review. I would like
to encourage such reviews more.
In addition to writing code, I provide assessments of code (in-house
reviews) and mentor other developers. If the code is not awful -- and
unfortunately most front end code is -- I can show how the code can be
made to run twice as fast, on more devices, at less than half the size.
The documentation does not reflect reality.
If at all. The first question on the mind of Web developers seems to
be about popularity. They seem to think that popularity implies
continuous improvement and easy support, despite overwhelming evidence
to the contrary (see jQuery).
Appeal to popularity.
Yes. What is surprising is that anyone would listen to "experts" who
advocate scripts based on pretty graphics and snazzy demos.
What else can they listen to? You think they want to come on usenet and
read code reviews? And if they do, do you think they can understand your
code reviews? Try and read the code review you wrote from the point of
view of someone who is ignorant.
My code review outline:
<
http://groups.google.com/group/comp.lang.javascript/msg/316e025b15e466a3?dmode=source>
and follow-up:
<
http://groups.google.com/group/comp.lang.javascript/msg/c8f81b8b3486e3e8?dmode=source>
Should those be linked from the the Code Guidelines doc and Code Review
Guidelines docs?
The Ext people think they are qualified, though that misconception has
likely been shaken at this point (unless they are locked up in sound-
proof booths with blinders on).
What the Ext people think of themselves does not matter.
"Is the salesman trying to make the product look good? Is there anything
that he might not have told me, out of ignorance or otherwise?"
This would not have been much investment and could have helped avoid
such an amazing waste of money[1].
Yes. It's a shame to see people throwing good money after bad.
They seem misguided.
Hell, I did it for free. Well, not really. I just touched on the
highlights here. I charged for the full analysis. Some people
So they paid you? You wrote above that nobody offered you any money to
do so.
realize that spending a little money to avoid wasting a lot makes good
business sense. It didn't take me a week and I didn't charge anywhere
near $5,000. But I could definitely write a similar (and much better)
framework in that neighborhood (and did so for one client about a year
back).
The investors may not have known that such an analysis was even
possible. Can the source code be analyzed by an independent third party?
Who knows?
Returning to the car-purchasing example, a buyer might want to take the
car he so likes (nice radio, comfy seats, looks cool, etc), down to his
own mechanic for an analysis.
Someone in the predicament of making assessments of the framework, but
not having the skill to do so does not need a "mobile applications
development framework shop"! What he needs is one or a few individuals
who are qualified of making an assessment.
Basically, what the investors needed was an expert analysis prior.
The uninformed cannot know the least amount of time it will take to make
such assessment. A very complicated framework that had good code and a
sophisticated build process might take considerable time to and effort
investigate and drawing metrics for it is going to be very involved and
complicated.
It turned out that such rigorous investigations would not have been
necessary in this case because the code is so bad that it can be
dismissed. Continued analysis beyond that point is pointless.
What is the point in finding out how they've packaged and organized
they're bugs? By accident, the `hasRightMarginBug` identifier was found
to be absent and with the many false comments about properties being
"private" (they aren't).
Oh, I bet somebody from Sencha is taking notes. The question is
whether they have anyone on the payroll who can interpret them in a
timely fashion.
I don't much care for giving free help to the Ext-JS guys. About 8
months ago, a colleage of mine informed me that they were in need of a
JS developer. I re-familiarized myself with their code and found room
for major improvement.
And so I gave my colleage the "OK" to pass on my contact info. So,
rather helping them, I get to do remote project postmortem, pro bono.
[...]
Happens all the time.
And the choice to use Sencha Touch is exponentially worse, which could
only be described as insane.
No, it could be described as misguided or not fully informed, or
informed, but not understanding the ramifications.
Do not consider "misguided" to be an insult; it is a position that most
of us are in, in more ways than we realize.