java - 这个 "method linking"对其他组件的(最佳)名称或描述是什么

标签 java design-patterns naming-conventions naming method-chaining

首先,很抱歉这个奇怪的“标题”,但由于我不知道这个名字,所以很难用简短的句子来描述。

我以前来过这里很多很多次,但这是我第一次真正的 Activity 。 我通常会通过我想知道的东西来搜索、阅读和奋斗。然而,这次我似乎无法得到答案,我觉得很遗憾。

最近我读了《Head First Design Patterns》,我不记得其中有涉及到它。另外,我在框中输入了相当多的谷歌术语,但没有正确的定义。我只是找不到正确的搜索词组合来确定答案。

我对“转发共享/链接”的正确名称有疑问 方法及其参数。

我正在编写 JavaDocs 注释,以使我的代码易于理解,但我无法获得适合于此的正确术语或设计模式名称。

但我认为,仅仅问这个并不能得到我需要的东西。所以我有一个小样本来尽可能基本地演示我的问题。我希望这有点容易理解。

public class Framework()
{
    private Game game = new Game();

    public Framework()
    {
         loadComponents();
    }
    public void loadComponents()
    {
        // first loading framework requirements.. (lets say a button graphic)

        game.load();    // lets start loading the game....
    }

    public static void main (String[] args)
    {
        new Framework();
    }
}

public class Game()
{
    private World world = new World();

    public void load()
    {
        // now we load some of the basic graphics.. (lets say a few borders)

        world.load(); // lets start loading the world!
    }
}

public class World()
{
    private Textures textures = new Textures();

    public void load()  
    {
        // now we load the worlds grid...

        textures.load(); // ofcourse we need textures, lets load...
    }
}

public class Textures()
{
    public void load()
    {
        // loading the textures...
        // end of this loading link.
    }
}

在这个例子中,我们从 Framework 开始,调用 Game 中的 load 方法,然后调用 World 中的 load 方法, 然后调用Textures中的load方法。让我们把它变得简单一点:

Framework.load()->Game.load()->World.load()->Texture.load();

但是我们当然得到了更多这样的“链接”。

Framework.load()->Editor.load()->Entities.load();

Framework.input(输入输入)->Game.input(输入输入)->Player.input(输入输入);

Framework.draw(Graphics2D g2d)->Game.draw(Graphics2D g2d)->World.draw(Graphics2D g2d);

我该如何描述或称之为最好的“链接/链接”?因为 Java 中的链接就像: Player.getLocation().setLocation(12,12).etc();

我希望我的问题现在有点清楚了, 感谢您提前抽出时间!

  • 埃德温

最佳答案

我相信这被称为 Delegator pattern

关于java - 这个 "method linking"对其他组件的(最佳)名称或描述是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31414099/

相关文章:

java - 扩展到另一个包中的类的最快方法,与当前包中的类同名

java - 代码在应用程序中不起作用

java - 远程调用的事务管理

html - 使用 html 5 模式进行名字验证

c# - 类型/接口(interface)契约(Contract)的任务 - 指南?

java - 包含字符串格式的变量是否有通用的命名约定?

java - Android Studio - 无法实例化 Activity

javascript - MVC 模式中的 "Hello World"

c# - 我应该停止与 Visual Studio 的默认命名空间命名约定作斗争吗?

python - Python 正则表达式的命名约定?