Giter Site home page Giter Site logo

Comments (5)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 21, 2024
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 [email protected] on 30 Aug 2010 at 9:09

from lambdaj.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 21, 2024
// 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 [email protected] on 30 Aug 2010 at 11:27

from lambdaj.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 21, 2024
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 [email protected] on 31 Aug 2010 at 4:21

from lambdaj.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 21, 2024
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 [email protected] on 2 Sep 2010 at 12:49

from lambdaj.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 21, 2024
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 [email protected] on 16 Sep 2010 at 10:56

  • Changed state: Invalid

from lambdaj.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.