avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niclas Hedhman <nic...@hedhman.org>
Subject Semantic bug in Framework?
Date Thu, 29 Jul 2004 06:58:05 GMT

Gang,

Since I am digging in Framework, I also stumbled upon another problem. Either 
it is a semantic bug in the intentions, or a bug in the 
ConfigurationUtils.equals() method.

The problem is highlighted in an added testcase, which now fails in Framework 
implementation.

It goes something like this;

The two configurations
Configuration a = 
<a>
  <b>1</b>
  <b>2</b>
</a>

and 

Configuration b =
<a>
  <b>2</b>
  <b>1</b>
</a>

then
a.equals( b ) --> TRUE

It is not specified in the Javadocs of Configuration, but it is said in 
Javadocs of DefaultConfiguration that getChild( String element ), will return 
the FIRST child.

SO;
String v1 = a.getChild( "b" ).getValue();
String v2 = b.getChild( "b" ).getValue();
return v1.equals( v2 );

evaluates to FALSE !!!!
In which case the two Configurations can NOT be considered equal.

I can imagine this is quite a headache, and the only way out as I see it, is 
that Configurations must be same in order of its children as well, to be 
considered equal. 

Furthermore, the current equals() implementation is very slow for large 
configurations, as it does at worst O(n!) iterations through the tree.

What are we going to do about this?


Cheers
Niclas
-- 
   +------//-------------------+
  / http://www.bali.ac        /
 / http://niclas.hedhman.org / 
+------//-------------------+


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


Mime
View raw message