简体   繁体   English

这个设计模式是如何调用的

[英]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 它实现了相同的接口,但委托调用接口对象List

这是Composite Design Pattern的一个实现 - 一个对象实现一个接口,并委托给实现相同接口的其他对象的集合。

It's called Composite 它被称为复合材料

More information here: 更多信息:

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

Are you talking about the delegation pattern? 你在谈论代表团模式吗? http://en.wikipedia.org/wiki/Delegation_pattern http://en.wikipedia.org/wiki/Delegation_pattern

It could be very similiar to Command 它可能与Command非常相似

References: 参考文献:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM