You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Leo Simons <ls...@jicarilla.org> on 2004/03/04 14:11:18 UTC
[RT] The big metadata topic (again!)
In response to the recent threa(d|t)s, I just wrote:
http://www.jroller.com/comments/lsd?anchor=rethinking_attributes
for lazy people (though the blog page has embedded links), here's the scoop:
=== Rethinking attributes ===
The new JDK 1.5 attributes are nice (they're powerful and easy to read
just like the .Net ones), but if you can't use them yet, you'll have to
do something else (BeanInfo files, MBeanInfo files, xml files, javadoc
attributes, bytecode hacking, ...). Its been the topic of (sometimes
heated) debate over at avalon for far too long now. I think I've just
figured out why.
Its obvious really. I should've listened to the little voice in the back
of my head that said "too much magic, too much magic, too much
magic...". What's the simplest thing that can possibly work to associate
arbitrary attributes with any class or instance? This:
public interface Attributes
{
/* stuff */
}
public interface AttributeProvider
{
public Attributes getAttrbibutes()
}
class MyComponent implements AttributeProvider
{
public Attributes getAttrbibutes()
{
/* implement contract */
}
}
Who was it that jumped to language extensions, BeanInfo classes, coding
conventions, javadoc tags, pagelong specifications, and worse? Shame on
you! You should've thought of the simplest possible thing first!
If that had happened, and basic OO rules about decoupling and
composition had then been followed, none of all the current attribute
headache would have ever existed. We would just have
public interface AttributeHelper
{
MethodAttribute[] getAttributesFor( Object instance, String methodName );
MethodAttribute[] getAttributesFor( Class class, String methodName );
/* etc etc */
}
public class AttributeProviderBasedAttributeHelper
implements AttributeHelper { /* ... */ }
public class JDK15BasedAttributeHelper
implements AttributeHelper { /* ... */ }
public class QDoxAttributesAttributeHelper
implements AttributeHelper { /* ... */ }
/** Detects which delegate attribute helper to use based on some
heuristics. */
public class IntelligentAttributeHelper
implements AttributeHelper { /* ... */ }
Fortunately, its not too late (its never too late). We can always
refactor. Let's refactor. Jakarta Commons Attributes is nearly there
already. We just need to make the internals of the Attributes class into
a set of proper components (with an interface and multiple
implementations), and then add a lightweight container (I can think of a
few ;)) inside the facade.
--
cheers,
- Leo Simons
-----------------------------------------------------------------------
Weblog -- http://leosimons.com/
IoC Component Glue -- http://jicarilla.org/
Articles & Opinions -- http://articles.leosimons.com/
-----------------------------------------------------------------------
The contents of this e-mail are copyright (c) Leo Simons, and licensed
under a Creative Commons License, available at
http://creativecommons.org/licenses/by-nc-sa/1.0/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org