Matt said:
I beg to differ.
a) There is no documentation for your script
Yes there is, I just have not published the documentation (and will
not).
b) There are no comments in your script
The version that accompanies the documentation has every line commented.
c) There isn't a summary of the approach that the script
uses to achieve the goal,
It is in the introduction to the documentation.
or caveats about when and where it won't work
Define "work".
d) The code is not tweakable in any way by even most
experienced programmers
Rubbish. There is another version on my site that is entirely a tweaked
version of that that script.
(to add, for example, the ability to lock two columns)
If you mean two (or more) columns that are not both (all) leftmost
columns then no it will not. The strategy employed would not perform
well if asked to lock arbitrary numbers of physically separated columns.
That was not part of the design requirement and so was not designed into
the result.
e) There is no "simplest case" example to start from,
leaving the reader to disect your source to figure out
what is needed for the code to run, and what is specific
to your example
Why should there be? I published the script for no other reason than to
demonstrate that a scrollable table body could be done. The bare script
satisfies that aim.
I have to wonder how much of your code is even necessary
for this specific purpose. Things like retFalse() being
defined 3 times - why?
They are all inner functions in re-usable low-level components, moving
them outside of the components to use only a single example would make
the components themselves less self-contained, and they are very small
functions so the cost is negligible.
I like the result of your code. I haven't tested it in
my specific case yet (I have some pre-work to do) but
since I might require locking of two columns, and your
solution doesn't seem to support that, then I have to
throw yours out entirely.
That is fine by me, you couldn't afford the rights to use it anyway.
There's no hope of me modifying your code to
suit my needs because it's incomprehensible.
And people ask about obfuscation ;-)
But it isn't incomprehensible. You know full well that Yep, Michael
Winter, Lasse Reichstein Nielsen, et al would be capable of
understanding it, even without comments/documentation. All you are
saying is that you don't comprehend it, and presumably that many others
wouldn't either. That is true but what do you expect me to do about it?
I have already written and published the clearest explanation of
closures and their mechanism that I am capable of. I have also written
extensively on this group about my thoughts on script design, and posted
examples with (more or less complete) comments and explanations. There
is no arcane secret here; it is just a matter of people putting in the
effort to understand what javascript is capable off.
If you added comments about intent and purpose of bits
of code, it might make it usable.
Precisely, as a professional programmer it is my responsibility to
provide code that is sufficiently documented to facilitate its easy use,
deployment, and future development by other javascript programmers. But
what I do in my spare time, for fun, is another matter entirly.
I know you're a fan of complex, closure-based code, but
couldn't you accomplish the same task in a more readable
way?
I am a fan of object based code. I use closures because they give me
tidy and simple ways of achieving what would otherwise be complex and
ragged. You presumably would want to achieve the same with structures of
JS objects, but the scope chain in a closure-based script is a structure
of objects. If you don't perceive that structure, and understand its
mechanism and interactions, then the result will look complex. Once you
do perceive the structure you will see simplicity.
I am not a masochist and I do not write code that I perceive as any more
complex than it absolutely has to be. Disregarding the pre-existing
re-usable low-level components, the code that creates and operates the
scrollable table is about 150 lines, and took 4 hours to design, write,
test and debug. That is not a symptom of genuinely complex code, or a
flawed approach to code authoring.
As for "readable"; wouldn't learning the language aid in reading it?
Or at least document your general approach, so others
could take the same approach with different code?
My general approach is a matter of public record. The specific strategy
employed in that script is something you should be able to work out for
yourself. There are, after all, only a limited number of ways of
producing those results and, unintelligible as you may find it, the code
calls a couple of methods that should be a very obvious clue, if you
look for them.
Which is why documentation is vital
Which is why documentation is created and distributed in a development
environment.
Richard.