Peter said:
Not accounting for certain browser bugs/incompatibilities due
to not having a long enough history working with browsers to
know about particular bugs. Testing would show the bugs but
testing in currently rare browsers (eg. IE4, Sunrise, Lobo)
may not be considered a wise cost by the business. Using a
prepackaged library that already works in all cases would be
much cheaper and more attractive to a project manager even
with a certain amount of increased download time. Project
timelines and idealism clash on occasion.
That pre-supposes that the 'prepackaged library' was written by someone
familiar with this type of historical browser behaviour (whether is it
be a bug or not). But in practice this is precisely the problem being
discussed in the "when is a function not a function" thread. The authors
of dojo and jquery have themselves not had the experience to know that
it is normal for collections to report 'function' from a typeof
operation. So when they encounter a browser that is doing no more or
less than has been done by many browsers in the past they find that
their code cannot cope, and start reporting that as a bug. Obviously
these individuals are not aware that there code has these issues
following from their inexperience, but now your project manager cannot
solve his problem by just using a library unless he has someone who
knows the issues themselves and so can point out which libraries
properly handle them and which doe not. At which point the original "not
having a long enough history working with browsers" has stopped
applying.
That may be true of a library like Prototype that is distributed
as a single file. Libraries like Dojo, YUI are distributed in
multiple files so even as the library gains capabilities it
doesn't mean the whole library has to be downloaded for each
page.
The extent to which that solves the problem depends on the sizes of the
chinks and how their dependencies work. The base part of dojo is 3500
odd line of code and is pretty much essential for anything else. It is
unlikely that that will tend to get any smaller with the passage of
time.
It seems granularity of a library's distributed source code
is a core source of contention. Should a library be distributed
as one file like Prototype and jQuery or distributed as many
files like YUI to be combined as needed by a developer working
on a particular page? If multiple files how small should each
file be. If multiple files, how should they be combined for a
particular page?
Generally javascript code should be sent to the browser in as few chunks
as possible. how code is handled before that is optional (and probably
best driven by the requirements of the development context).
I think there is another way to look at what the library is
providing to the user.
The user is the person sitting in front of a web browser interacting
with the end result. Users should not be confused with programmers as
programmers have much more responsibility for what they do.
In the terms you use below, the library is providing an
interface and a base implementation of that interface.
In the simple cases where it is excessively complex, I
can see that some developers would just say "we will
never agree how simple the simplest implementation of
this interface should be." It may make sense to some
people that the simplest interface should at least work
in the popular 80% of the browsers and having a simpler
version for particular browsers is just more code to
maintain. Although performance and download times are
important it is also necessary to retain a small code
base and so a medium complexity implementation of the
interface as the base implementation may be better to
some people than having many simpler ones kicking around
the hard drive.
For the general problem of maximising code re-use it is not advantageous
to maintain a small code base (quite the opposite). For an individual
project that may be an advantage, but then you can maintain the
distinction between the modules that are in the application and those
that are not.
So the library provides a medium complexity base
implementation and when it is insufficient for a less
common case
And over the top for the more common cases.
the developer writes code to handle the less
common case.
But only if the developer has learnt how to do that.
This is very similar/identical to
what you are suggesting below.
Getting there, but it is still important that the interface design stage
takes into account the need to accommodate the whole range of possible
implementations of the interface.
Ideal, and so the question is to what extent it can be achieved in
reality.
When you write "larger-scale" what do you mean? Do you mean
distributed in a single file or a low number of multiple files?
Or do you mean just many lines of code?
Files and code are largely irrelevant. Mostly I am getting at
interdependence and the number and diversity of facilities provided in
interdependent units. Physical size does follow when many facilities are
strongly interdependent, but that is just a consequence.
I think this is a great strategy overall. It formalizes the
idea of "a sufficient implementation."
Many 'sufficient implementations', where each is 'sufficient' for
differing requirements.
Why adhere so strictly to this "and no more" requirement?
Because that criteria provides constant direction. Abandon it and there
is no telling how far things may end up drifting in the opposite
direction.
It is ok performance-wise or more profitable overall
(development dollars vs net income) in many situations
to send 5-10% unused code to the browser.
Maybe 5-10% but without direction there is nothing to make you stop at
(or near) 10%, and there a plenty of real world cases where an imported
library is being so slightly used that almost all of the downloaded code
is not being used.
This seems to be an argument against having the absolute
simplest implementations in the collections of objects.
By having a medium-complexity interface implementation as
the base implementation, when a CSS re-design occurs there
_may_ be no need to swap out the simplest implementation
for a slightly more complex implementation.
But that is a very big "may". One CSS change may bring scrolling
overflow into the picture, another may change a floating block element
into a list item, and a whole spectrum of other possibilities exist.
Your "medium-complexity" implementation just cannot take everything into
account without actual being the complex implementation that everyone is
trying to avoid even writing (let alone using).
Because the future re-design cannot be predicted there is no point in
trying. It makes most sense to deal with the current situation but to do
it in a way that has the flexibility to minimise the effort needed to
accommodate the unknowable future changes.
This saves developer time which is more expensive then
production server time.
Yes, so make the task of accommodating any possible future changes in
requirements as quick and simple as possible.
It seems that to implement your strategy of multiple interface
implementations that multiple source files grouped in a directory
for each interface would be a practical approach.
Yes that certainly would be one sensible structure for such a
collection.
Some sort of configuration file and build process could
concatenate the various appropriate files together for a
particular page.
Could, but aggregating the components necessary for a project with copy
and paste gets the job done. Changes in an application's source files
during the development of a project tend to mostly be additions rather
than changes in what has already been created, so any elaborate "build
process" might be added complexity for no good reason.
Is that similar to
the approach you take?
I have not got to the point of expressing capabilities and dependencies
in the sort of machine readable form that would be necessary for an
automated build process. Eventually that may become desirable (or even
necessary), but I prefer to get a good handle on the issues involved
before moving in those sorts of directions (as if you commit yourself to
something inadequate you usually end up getting stuck with it).
Richard.