Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the correct term for an implementation of an interface that delegates method calls to a collection of the same interface?

Tags:

java

I have an interface thus:

public interface Doer
{
    public void do(Object arg);
}

And I have an implementation that keeps a list of Doers, and does whatever on each:

public class DoerCollectionThing
    implements Doer
{
    private List<Doer> doers....

    public void addDoer(Doer d)
    {
        doers.add(d);
    }

    public void do(Object arg)
    {
        for (Doer d : doers){
            d.do(arg);
        }
    }
}

So, what do I call DoerCollectionThing? Is it a DoerAggregator? Or maybe DoerCollectionDoer? What do you all use for this type of thing?

like image 792
Jesse Avatar asked Jan 22 '23 14:01

Jesse


1 Answers

The correct name for this is a Composite, because you're composing many implementations of an interface together into a single object.

like image 146
GaryF Avatar answered Jan 28 '23 18:01

GaryF