As discussed on prior threads you should have both. There will need to be static convenience methods for a user who wants to make a very simple call, say Stats.mean() . But, as Alex said, this convenience class will just be a front end for the statistics functionality itself. That needs to be in its own classes (Mean(), Variance()) which can produce instances that give the user more flexibility, For example storeless statistics like Mean() or Variance(), or StandardDeviation(), should be updatable, as Gilles said, or handle different kind of streams like Alex said. Yet these classes need to be designed so that they perform as well as simple implementations when desired.
On Sun, Jun 2, 2019 at 5:45 AM Virendra singh Rajpurohit < [email protected]> wrote: > I've been trying to make summary statistics class. I have some doubt. > There is a class DoubleSummaryStatistics in java.util package(There are two > more for Int and Long). I'll attach this file here. > Do I have to design SummaryStatistics in this way only? I mean, > description on DoubleSummaryStatistics is "This class is designed to work > with (though does not require) streams > <https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html>. > For example, you can compute summary statistics on a stream of doubles with: > > > DoubleSummaryStatistics stats = > doubleStream.collect(DoubleSummaryStatistics::new, > > DoubleSummaryStatistics::accept, > > > DoubleSummaryStatistics::combine);" > Earlier my understanding of the project was that the user just have to > call the function "getSummary()" & all the calculations will be done > automatically in streams. but As we can see in DoubleSummaryStatistics we > have to call collect() method. > There are some functions like max, min, sum, count, average which are > already defined in this class. So should I extend this class in my class or > not? Also, I'll have to add more statistics other than max,min,sum for that > I have to override accept() function which will be used for streams. > > Warm Regards, > -- > *Virendra Singh Rajpurohit* > > *University of Petroleum and Energy Studies,Dehradun* > Linkedin:https://www.linkedin.com/in/virendra-singh-rajpurohit > > > > > > [image: Mailtrack] > <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> > Sender > notified by > Mailtrack > <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> > 06/02/19, > 6:14:27 PM > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected]
