M
Matt Kruse
Richard, perhaps you missed this followup...
You had asked for me to be clearer about what I meant by 'general' and
'exhaustive' and 'partial solution'.
I was curious if you had a response after I made things clearer?
Matt
You had asked for me to be clearer about what I meant by 'general' and
'exhaustive' and 'partial solution'.
I was curious if you had a response after I made things clearer?
Matt
Matt said:Let's clear things up...
Richard said:And I was writing about Matt's specific problem. In theory he has the
problem of the general. Ideally he wants to create something that can
be drooped unaltered into any web page context at all and will then
successfully function as expected.
'Ideally', yes, that would be nice. Realistically, no. That's not the
goal. The goal would be able to have code which works when dropped
into the majority of typical situations.
And his expectation is that the
person doing the dropping will not have any technical understanding
of what they are doing and so will be incapable of doing anything
about it when his products do not work as expected.
If they have a case not covered in the generalized solution, they can
provide a test case and ask for the condition to be covered in the
code. If it is likely that the condition is common to more than just
a single situation, then it could be considered for addition.
That means either Matt's code takes into account all the factors
pertinent to its being dropped into any web page context or it cannot
be dropped into any web page context.
Perhaps you used wrong words, but that is not true at all.
Even if all factors are not considered, it might work correctly in the
majority of contexts.
Your point, I assume, is that unless all contexts are considered,
then it could not be dropped into ALL web page contexts. Which is, of
course, true. But since that is never my goal, I have no problem with
that.With the latter case suggesting
that Matt should state the restricted contexts in which the code can
be successfully used, and that the individual employing the code
should be able to recognise whether those restrictions are satisfied
in their particular situation
It's impossible to list every context where such a generalized
solution will work. It might be possible to list all the conditions
that are considered in the code, although I don't think most people
would find value in that. Instead, it would be best to list the
contexts where the code does _not_ work, so a user can identify if
such a context exists in their case.When 'providing general solutions' uses general to mean no more than
non-specific and solutions may be 'partial' the whole thing looks
like a marketing exercise rather than the altruistic contribution to
the betterment of the web development world he sometimes makes it out
to be.
I've thought about definitions a bit, and I offer this...
A specific solution is only useful in a single case. For example, if
you have an IE-only app and you want to get the color applied to an
object, you could use:
function getObjectColor(obj) {
return obj.currentStyle.color;
}
This solution is not generalized at all. It returns the value of one
attribute, and only in some user agent(s).
The term 'general' is relative. A 'more general' solution would take
into account multiple user agents:
function getObjectColor(obj) {
if (obj.currentStyle) {
return obj.currentStyle.color;
}
else if (obj.document && obj.document.defaultView &&
obj.document.defaultView.getComputedStyle) {
return
obj.document.defaultView.getComputedStyle(obj,'').getPropertyValue('color');
}
return null;
}
A even more 'general' solution would consider the case of a null
object, etc, but I will not list that here for the sake of brevity.
An EVEN MORE 'general' solution could take the property as an
argument, so the method could be reused for obtaining any style
attribute:
function getObjectStyleValue(obj,property) {
if (obj.currentStyle) {
return obj.currentStyle[property];
}
else if (obj.document && obj.document.defaultView &&
obj.document.defaultView.getComputedStyle) {
return
obj.document.defaultView.getComputedStyle(obj,'').getPropertyValue(property);
}
return null;
}
An EVEN MORE 'general' solution might take into consideration some
specific browser quirks, or NN4, etc.
I would consider the improved 'getObjectColor' function to be a
general method of obtaining the color of an object. But the
'getObjectStyleValue' method is even better, since it's a general
method to obtain any style value.
None of these are 'exhaustive' solutions, however. There are
certainly cases and browser quirks which are not considered. However,
these functions in their finished form would surely provide the
desired functionality for most people in most contexts, so they could
be presented as a 'general' solution.
The goal of building 'general' solutions is to provide functionality
that works in the majority of contexts that arise in typical
development. The goal is never to build an exhaustive solution which
covers all possible situations. That's not possible in most cases.
(In cases where it is possible, it is certainly a good goal!)
Your insistance that a 'general' solution must be 'exhaustive' is
incorrect (or at least, not the typical opinion). I've checked with a
number of other developers in a forum I participate in, and they all
agreed that they do not necessarily consider a 'general' solution to
address every possible need which might arise.
So, when I attempt to build a 'general' solution for finding the
position of an object, for example, I'm attempting to address the
majority of typical contexts in which it would be used. So most
people, under most conditions, _could_ in fact drop the library into
their code and have it work correctly. In other libraries, I have
built in functionality which will be used by some people but not
others, because I thought that the need for the functionality was
typical enough to warrant inclusion. In other cases, people have made
specific requests that I did not include because I didn't think most
people would ever have the need for the feature.
If exceptions happen (and they will) then I would hope that the person
finding it would tell me details and provide a test case so I could
determine if the need is typical enough (in my own opinion) to be
included in the general library and should be fixed, or if their
context is so specific to their situation that they would need to
write specific code for their case. Of course, when people such as
yourself claim to find an exception and refuse to provide details or
a test case, that doesn't help to make the general routine more
solid. In fact, since you refuse to provide any evidence, I'm not
sure I even believe you. It's easy to make empty claims. *shrug*
A 'partial solution' is valuable because it solves a specific case
and can be used in a more general solution. For example, the code
using currentStyle to find the style applied to an object is a
'partial solution' because it does solve the problem for a subset of
all cases. Combined with other 'partial solutions' they form a more
general solution which is more valuable.
A 'partial solution' can also be a library in itself. For example,
finding the position of an object. By itself, it provides no
functionality to the user. It must be used with other code to achieve
some bigger goal. But it can be used as a black box to solve the
problem of finding the position of an object, so the coder doesn't
need to go into detail programming that portion of the bigger picture.
<snip about my 'advertising' and supposed real motivations>
Nothing will change your opinion of my efforts, Richard, so what I
write won't even matter.
But, the truth is that when I direct people to my stuff, it's always
because it _specifically_ addresses their needs, and I think they
will benefit from it. I don't advertise. If you have specific code
which solves their specific problem, you may post it. If I have
already written a solution which solves their problem, I may direct
them to it.
I happen to offset the cost and development time with donations and
google ads, although I certainly do not 'come out ahead' in the game.
If I were trying to make a profit, I would be charging for my work
rather than giving it away with almost no useage restrictions. My
goal is to provide solutions which help average web developers
perform complex tasks which they may not be able to do themselves. I
get personal satisfaction knowing that I've helped thousands of
people solve their problems when people like you would have told them
that they didn't even deserve to be helped. If I'm ever seen as
'promoting' my stuff, it's because I want people to be made aware of
packaged solutions which can solve their problem, rather than being
faced with people telling them how stupid they are, or resorting to
finding terrible code at some copy-n-paste javascript site.
If you don't believe me, that's fine. I don't care.