Rafael T
Rafael T

Reputation: 15679

How is this design pattern called

what is the name of the Design pattern. Simple example

public interface SomeObject{

    public void call();
}

public UnknownDesignPatternImpl implements SomeObject(

    List<SomeObject> objects;

    public UnknownDesignPatternImpl(List<SomeObject> objs){
        objects = obj
    }

    public void call(){
        for (SomeObject obj: objects){
            obj.call();
        }
    }
}

it implements the same Interface but delegates calls to a List of interface objects

Upvotes: 2

Views: 97

Answers (4)

alepuzio
alepuzio

Reputation: 1418

It could be very similiar to Command

References:

http://java.dzone.com/articles/design-patterns-command

Upvotes: 0

TheEwook
TheEwook

Reputation: 11117

It's called Composite

More information here:

http://java.dzone.com/articles/design-patterns-composite

Upvotes: 2

Mureinik
Mureinik

Reputation: 311163

This is an implementation of the Composite Design Pattern - an object implements an interface and delegates to a collection of other objects implementing the same interface.

Upvotes: 5

Kevin Workman
Kevin Workman

Reputation: 42176

Are you talking about the delegation pattern? http://en.wikipedia.org/wiki/Delegation_pattern

Upvotes: 1

Related Questions