C
Chris Smith
Okay, so I've been running things through my head recently, and
wondering about opinions on this. I spoke yesterday evening to the
Pikes Peak Java Developers Group, and explained among other things how
to set up an RPC bridge between JavaScript and JSF 1.1 backing beans
using JSON, XmlHttpRequest, and JSF phase listeners. The response was
interesting.
One concern brought up very strenuously by one member of the audience is
that if people are using Prototype's AJAX support, then we shouldn't
develop new APIs even if Prototype doesn't address how to map its
incoming requests in the right context in the existing application. It
was implied that avoiding the reimplementation of these components is
sufficient justification for it being harder to integrate these
components into a web application.
As I've been thinking about it, I have come to the conclusion that this
is not only silly, but is in fact responsible for a good bit of the
complexity of software development. I could very easily design a better
interface for sending mail than JavaMail, but it might not be generic
enough to send other kinds of messages through other transport
protocols; so we make it difficult for a million developers to send
email so as to avoid potentially having to learn a new API to send
something that's not email. JNDI sucks at each of the many individual
things it's supposed to do (LDAP, DNS lookup, etc.) because someone is
afraid to create a different API to do different things.
It all seems to me to come down to a flawed conception of reuse, both of
code and of APIs. Reuse is valuable for two reasons:
1. When there are consistent sets of requirements, and those
requirements may change, then implementing them in one and only one
place makes it easier for application software to be updated to match
the changing requirements.
2. Reuse may save effort.
#2 is the one that's most often applied incorrectly. There should be a
ton of emphasis on the word "may" in that sentence. There are any
number of scenarios in which it's not true. In particular, when usage
scenarios differ, it's often better to write something ten times in
order to save a million people from a small amount of hassle setting it
up. In this case, a more complex interface in order to facilitate reuse
in different environments is not justified!
Thoughts? (If your thought is: "but there's already an AJAX framework
that integrates well into JSF, and here it is..." then that would be
interesting, too. I have evaluated a number of options and haven't
found it yet.)
wondering about opinions on this. I spoke yesterday evening to the
Pikes Peak Java Developers Group, and explained among other things how
to set up an RPC bridge between JavaScript and JSF 1.1 backing beans
using JSON, XmlHttpRequest, and JSF phase listeners. The response was
interesting.
One concern brought up very strenuously by one member of the audience is
that if people are using Prototype's AJAX support, then we shouldn't
develop new APIs even if Prototype doesn't address how to map its
incoming requests in the right context in the existing application. It
was implied that avoiding the reimplementation of these components is
sufficient justification for it being harder to integrate these
components into a web application.
As I've been thinking about it, I have come to the conclusion that this
is not only silly, but is in fact responsible for a good bit of the
complexity of software development. I could very easily design a better
interface for sending mail than JavaMail, but it might not be generic
enough to send other kinds of messages through other transport
protocols; so we make it difficult for a million developers to send
email so as to avoid potentially having to learn a new API to send
something that's not email. JNDI sucks at each of the many individual
things it's supposed to do (LDAP, DNS lookup, etc.) because someone is
afraid to create a different API to do different things.
It all seems to me to come down to a flawed conception of reuse, both of
code and of APIs. Reuse is valuable for two reasons:
1. When there are consistent sets of requirements, and those
requirements may change, then implementing them in one and only one
place makes it easier for application software to be updated to match
the changing requirements.
2. Reuse may save effort.
#2 is the one that's most often applied incorrectly. There should be a
ton of emphasis on the word "may" in that sentence. There are any
number of scenarios in which it's not true. In particular, when usage
scenarios differ, it's often better to write something ten times in
order to save a million people from a small amount of hassle setting it
up. In this case, a more complex interface in order to facilitate reuse
in different environments is not justified!
Thoughts? (If your thought is: "but there's already an AJAX framework
that integrates well into JSF, and here it is..." then that would be
interesting, too. I have evaluated a number of options and haven't
found it yet.)