cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Larson <timlarsonw...@yahoo.com>
Subject [cforms] Forwarding: Explanation of derived classes
Date Mon, 05 Jan 2004 15:36:59 GMT
[Forwarding email from discussion with Marc.]

--- Marc Portier <mpo@outerthought.org> wrote:
> I saw a different mail for that, no?

Here are a couple emails:
  http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=107090293001052&w=2
  http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=106953358228020&w=2
Summary:
  We may want to parameterize "class" to allow it to define (or "new"
  to allow it to create) modified versions of a class, such as to give
  nested unions a different default case than their parents, or to add
  or remove widgets in nested widget structures.

Let me see if I can describe this more clearly.  In Java you can
define a class that extends another class to allow for additional,
modified, or restricted behavior.  This is the main concept I am
referring to when I mention derived classes.  I would like to be
able to create a class of widgets, and then be able to define
additional classes which extend the first class.

What may be throwing you is that I am mixing in an idea that is
not from Java.  Some languages allow "classes" to be specified by
example, rather than requiring a separate class definition.  Think
of it like being able to take an object *instance* and say:
  Object newObject = new oldObject();
to create a new object with the same variables and methods as the
oldObject instance.  Now add Java's concept of anonymous classes
to allow you to say:
  Object extendingObject = new extendedObject() {
    // Place extending variables and methods here
  }
To bring this back to the cforms context, look at NewJXPathBinding
to see how it can create an "instance" (remember: really just an
object reference) of either a defined "class" or of another active
binding.  This is like the first example above, "new oldObject()".
In general, I want to be able to take a "class" or an example
binding, definition, or template and be able to "extend" it either
while defining a new "class" or while creating an instance with
"new".  This last case, creating an extending object using "new",
is like the second example above, "new extendedObject() { }".

You are probably thinking, "What's this for?"  Classes are good
if you want to create more than one instance, or if you need to
specify the definition (e.g. for interfacing reasons) separate
from creating the instance data.  When your use case does not have
either of these requirements, being forced to define a class is
syntactic overhead, slowing you down and cluttering your code.

Similarly, if you will never need to reference a class's name
except to create the only instance of the class, then having
support for anonymous classes can cut the overhead of having to
create and maintain a non-conflicting name for the class.

Is this explanation clearer, or is you head spinning now?

> >>>>- thinking also about proposing define/use in stead of class/new

We could do this name change, but what do you think in light of
the explanation given above?

--Tim Larson


__________________________________
Do you Yahoo!?
Find out what made the Top Yahoo! Searches of 2003
http://search.yahoo.com/top2003

Mime
View raw message