commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitri Plotnikov <dmi...@apache.org>
Subject Re: [clazz] Accessing the properties
Date Tue, 29 Oct 2002 01:22:10 GMT
Stephen,

----- Original Message -----
From: "Stephen Colebourne" <scolebourne@btopenworld.com>
To: "Jakarta Commons Developers List" <commons-dev@jakarta.apache.org>
Sent: Monday, October 28, 2002 8:03 PM
Subject: [clazz] Accessing the properties


> (I'll use the terms property and metaproperty in this email as per the
> checked in CVS)
>
> On the Joda project I created a subinterface and subclass for each basic
> type. Thus a StringProperty is a subinterface of Property that makes it
> specific to a String. It adds a lot of type safety, but is a bit of a
pain.
> (Lots of classes in the API, lots to maintain, there's always a class not
> covered).
>
> However, for Lists and Maps it works well to have subinterfaces.
>
> Thus I propose:
> Property - get() and set(Object)
> ListProperty - extends List
> MapProperty - extends Map
> (This is instead of IndexedAttributeAccessor/MappedAttributeAccessor)
> The trick is to re-use the List and Map interfaces, rather than redefining
> our own pale imitations using a few add/set/remove methods.

> In java reflection the code is
>  field.get(Object instance)
> For the MetaProperty concept I would change this to:
>  metaProperty.getProperty(instance).get();
>
> Thus the getProperty() method returns a suitable wrapper for that property
> for that instance. ie. it creates the delegate. Thus at the meta level,
> there is no need for specific List and Map subinterfaces.
>
> I think the key to all APIs like this is to re-use what Java offers, and
> thats the collections API in this case.
It would indeed be very appealing to re-use the Java collections interfaces.

However, I'll have to be honest with you. I must be old-fashioned, but the
allocation of all these wrappers bothers me.  I have noticed that wrappers
have become quite fashionable lately (e.g. WrapDynaBean), but I am still not
convinced that allocating all these stateless objects is worth the literal
reuse of standard interfaces.

Also, I am not convinced that we need interfaces as wide as those of
Collections.  The implementation of those APIs can be quite an effort,
especially in the case where the target object is a Java bean, not a
DynaBean.  We then have to map all these APIs to some methods on the bean.

Anyway, I am not opposed to the use of collections APIs - just expressing
some concerns.

> Stephen

- Dmitri


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message