avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leo Simons" <m...@leosimons.com>
Subject RE: [Proposal] Should we introduce a new idiom for Components?
Date Fri, 18 May 2001 09:35:39 GMT
> > Better yet, lets have an array of roles, in case a single
> > class/interface performs multiple roles:
> > 
> > String[] role;
> > try
> > {
> > 	role = (String[])DataSourceComponent.class.getField("ROLE");
> > }
> > catch( NoSuchFieldException nsfe )
> > {
> > 	role = new String[] { DataSourceComponent.class.getName() };
> > }

whoops...
String[] role;
try
{
 	role = (String[])clazz.getField("ROLE");
}
catch( NoSuchFieldException nsfe )
{
 	role = new String[] { clazz.getName() };
}
...sure everyone got that =)

> This seems to assume that "role" is an inherent attribute of
> the component type and the component type alone (i.e., the
> component's primordial interface.)

uh, nope. Read on.

> However, the same component type may be used by other components
> in multiple, even unforseen roles.

Yep, though I would question whether that's always good
design - I think that in the majority of cases, said
component should instead be extended to create the new
role.

> If this is the case, "role" would be an attribute of the
> component's _usage_ by other components, rather than of the
> component itself.
> 
> Given that roles can be unforseen, the approach of having an
> array of "anticipated" roles may not be sufficient for the
> general case.

A good point. But you are forgetting that the ROLE attribute
could be settable. So _if_ this is not sufficient, it is always
possible to modify the ROLE attribute at any time to 'force'
a component in a particular role:

ROLE = Arrays.join( ROLE, new String[] { "my.new.role" } );

I am -1 on that though. A Component should only be used in
the role(s) for which it was designed: you should not use
a HashMap (which has the Role of a List) in the role of a
Pool, you should create a new Pool interface, and have a
PoolImpl that wraps around HashMap (if you wish) with its
role set to Pool.

> That said, I may be misunderstanding Leo's proposal (he may be
> actually referring to the specific DataSourceComponent case.)

Nah...I just want to enforce "clarity by design".

cheers!

LSD

---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Mime
View raw message