Suppose you have a function that allows you to find the sum/minimum/maximum of a data field:

void g(DataField* d, Operation* op){
  // applies op->f(...) on all fields of d

Operation would be defined something like:

struct Operation{
  virtual void f(...) = 0;

struct Sum : public Operation{
  virtual void f(...) { currentSum += argument; }

struct Max : public Operation{
  virtual void f(...) { currentMax = max(currentMax, argument); }

What would be a good name for those many-to-1 operations as sum/min/max, and how should I therefore name Operation?

closed as primarily opinion-based by gnat, Justin Cave, Bart van Ingen Schenau, Robert Harvey, Kilian Foth Sep 29 '15 at 8:05

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 9
    "Aggregate" would be a pretty conventional name – Justin Cave Sep 29 '15 at 4:59
  • 2
    @gnat: I ask for the "name of a concept", therefore the question should be ok. – Michael Sep 29 '15 at 5:25
  • 1
    aggregate aka fold aka catamorphism aka reduction – jk. Sep 29 '15 at 7:07
  • 1
    @JustinCave: That's pretty .NET-specific, I think. The usual name is "fold" or "reduction", as jk. mentioned. "Catamorphism" is the category-theoretical name. C++ calls it "accumulate". – Jörg W Mittag Sep 29 '15 at 7:26
  • 1
    @JörgWMittag - Not really. That's the term that databases use for those functions. As does Java. Which isn't to say that there aren't other options. But "aggregate' is used across a reasonably wide domain. – Justin Cave Sep 29 '15 at 8:24

Browse other questions tagged or ask your own question.