Closed GoogleCodeExporter closed 8 years ago
Hi Paul,
of course I have no reason to not believe in you. Indeed the scenario you are
experiencing is very worrying. If what you are reporting is true (and once
again I haven't any reason to think the opposite), you can imagine that should
be unbearable to have an interface with both the size() and getSize() methods
that even worse return 2 different values. And I also cannot safely remove the
getSize() method without breaking the backward compatibility. I am not saying I
don't want to do that at all, but I need a very good reason to do that. I hope
you can agree.
Since I am also very curious of what you found and also to properly write an
unit test for this issue, I'd be glad if you could give me a bit more details
about it.
Thanks a lot
Mario
Original comment by mario.fu...@gmail.com
on 30 Aug 2010 at 9:09
// both of these fail.
package ch.lambdaj;
import ch.lambdaj.demo.Person;
import ch.lambdaj.group.Group;
import org.junit.Test;
import static ch.lambdaj.Lambda.by;
import static ch.lambdaj.Lambda.group;
import static ch.lambdaj.Lambda.on;
import static java.util.Arrays.asList;
import static junit.framework.Assert.assertEquals;
public class GroupsVarianceTest {
private Person mario1 = new Person("Mario", "Fusco", true, "01/01/1999" );
private Person peter = new Person("Peter", "Pan", true, "02/02/1999" );
private Person mario2 = new Person("Mario", "Two", true, "04/04/1999");
@Test
public void oneGroupsRecognizedSuggestingNoVariance() {
Group<Person> grp = group(asList(mario1, mario2), by(on(Person.class).getFirstName()));
assertEquals(1, grp.getSize());
}
@Test
public void twoGroupsRecognizedSuggestingVariance() {
Group<Person> grp = group(asList(mario1, peter, mario2), by(on(Person.class).getFirstName()));
assertEquals(2, grp.getSize());
}
}
// I must be misunderstanding the doco.. my apologies of this is the case.
Original comment by PaulHamm...@gmail.com
on 30 Aug 2010 at 11:27
The interesting thing about this, is that as you gaze at 'grp' in the debugger,
the toString() is reporting the right numbers - "size = 1" for the first test
and "size = 2" for the second.
Original comment by PaulHamm...@gmail.com
on 31 Aug 2010 at 4:21
Well our problem was new useritis.
What we really wanted was either
grp.subgroups().size()
or
grp.keySet().size()
We found that the unit tests as you have them, have one example that shows
this. Perhaps the Group.getSize() javadoc could be changed to:
/**
* Returns how many items are present in this group, wherever they are in the implicit tree-map
*/
Original comment by PaulHamm...@gmail.com
on 2 Sep 2010 at 12:49
Yes, the problem was caused in a misunderstanding in the documentation. The
javadoc of the getSize() method has been updated as per your suggestion.
Original comment by mario.fu...@gmail.com
on 16 Sep 2010 at 10:56
Original issue reported on code.google.com by
PaulHamm...@gmail.com
on 30 Aug 2010 at 8:31