You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Roland Turner <ra...@arrakis.com.au> on 1999/11/30 14:18:04 UTC

Re: cvs commit: jakarta-tools/ant/src/main/org/apache/tools/ant/taskdefs Javac.java

James Duncan Davidson wrote:

> Stefano Mazzocchi wrote:
<snip>
> > so that setxxxElement methods know that they can be called multiple
> > times.
> 
> I could go for this pattern except that the methods for this use should
> be addXXX, not setXXX since there are multiple possibilities here.

Maybe it's a little soon for me to be jumping into the guts of design
issues, having been lurking for just a couple of days, but here are some
thoughts, the last of which may resolve the dilemma:

- Definining our own text structuring syntax when XML already does so
seems undesirable. Defining an element is a preferable approach in most
cases.

- Repeated calling of setXXX where the actual semantic is "add" not
"set" also seems undesirable. addXXX() would certainly be nicer.

- Nicer still might be to have this multi-valued item appear as a
property, even through the JavaBeans design patterns. There is a clean
approach. The JavaBeans design patterns provide for "indexed"
properties, where the accessor methods are:

	void setDir(String[] values);
	void setDir(int index, String value);
	String getDir(int index);
	String[] getDir();

This way, we have all of the bases covered. The XML is clean (no
additional text formatting conventions), the API is clean (no use of
"set" to mean "add"), and bean introspection will work in the desirable
fashion (the multi-valued property will indeed appear as an "indexed"
property).

Is this useful, or have I missed the point completely?

- Raz

Re: cvs commit: jakarta-tools/ant/src/main/org/apache/tools/ant/taskdefs Javac.java

Posted by Roland Turner <ra...@arrakis.com.au>.
Stefano Mazzocchi wrote:

> Roland Turner wrote:
<snip>
> >         void setDir(String[] values);
> >         void setDir(int index, String value);
> >         String getDir(int index);
> >         String[] getDir();
> >
> > This way, we have all of the bases covered. The XML is clean (no
> > additional text formatting conventions), the API is clean (no use of
> > "set" to mean "add"), and bean introspection will work in the desirable
> > fashion (the multi-valued property will indeed appear as an "indexed"
> > property).
> >
> > Is this useful, or have I missed the point completely?
> 
> It is, but I like addxxx() more than using arrays since they don't
> provide problems in introspections, the design is clean and the
> implementation effort doesn't change.

OK, no problem. It's not at all critical that this be exposed as a
JavaBeans property.

I am interested in your "problems in introspections" comment,
particularly in light of the above pattern being a part of the JavaBeans
spec. What problems are you referring to? Just the increase in
complexity in specifying an array type, or something else?

- Raz

Re: cvs commit: jakarta-tools/ant/src/main/org/apache/tools/ant/taskdefs Javac.java

Posted by Stefano Mazzocchi <st...@apache.org>.
Roland Turner wrote:
> 
> James Duncan Davidson wrote:
> 
> > Stefano Mazzocchi wrote:
> <snip>
> > > so that setxxxElement methods know that they can be called multiple
> > > times.
> >
> > I could go for this pattern except that the methods for this use should
> > be addXXX, not setXXX since there are multiple possibilities here.
> 
> Maybe it's a little soon for me to be jumping into the guts of design
> issues, having been lurking for just a couple of days, but here are some
> thoughts, the last of which may resolve the dilemma:
> 
> - Definining our own text structuring syntax when XML already does so
> seems undesirable. Defining an element is a preferable approach in most
> cases.
> 
> - Repeated calling of setXXX where the actual semantic is "add" not
> "set" also seems undesirable. addXXX() would certainly be nicer.
> 
> - Nicer still might be to have this multi-valued item appear as a
> property, even through the JavaBeans design patterns. There is a clean
> approach. The JavaBeans design patterns provide for "indexed"
> properties, where the accessor methods are:
> 
>         void setDir(String[] values);
>         void setDir(int index, String value);
>         String getDir(int index);
>         String[] getDir();
> 
> This way, we have all of the bases covered. The XML is clean (no
> additional text formatting conventions), the API is clean (no use of
> "set" to mean "add"), and bean introspection will work in the desirable
> fashion (the multi-valued property will indeed appear as an "indexed"
> property).
> 
> Is this useful, or have I missed the point completely?

It is, but I like addxxx() more than using arrays since they don't
provide problems in introspections, the design is clean and the
implementation effort doesn't change.

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche