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?

  • 10
    "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.