GWT Place Class 增强可行性

发布于 2024-12-01 18:37:05 字数 2014 浏览 2 评论 0原文

我正在进行思想实验,研究增强地点课程的可行性。假设 Google 会向我们提供这样的增强功能,那么对 Place 类的以下增强功能会有帮助吗?

假设 Place 类被增强为具有该方法

setActivity(Activity act)

然后,我们将能够这样做:

public class StartActivity extends AbstractActivity implements Presenter {

    private ClientFactory clientFactory;
    private String name;

    public StartActivity(StartPlace place, ClientFactory clientFactory) {
        this.clientFactory = clientFactory;
        this.name = place.getName();
        place.setActivity(this);
    }
}

这样 ActivityMapper 就会变得如此简单......

public class DenLapehActivityMapper
implements ActivityMapper{
    @Override
    public Activity getActivity(Place place){
            return place.getActivity();
    }
}

但是,我的思想实验,权衡了当前的情况,使我不得不做这些

abstract public class DenLapehPlace
extends  Place{
    private Activity activity;

    public Activity getActivity(){
        return activity;
    }

    public void setActivity(Activity activity){
        this.activity = activity;
    }
}

public class DenLapehActivityMapper
implements ActivityMapper{
    @Override
    public Activity getActivity(Place place){
        if (place instanceof DenLapehPlace)
            return ((DenLapehPlace)place).getActivity();

        return null;
    }
}

或者更糟糕的是,遵循示例/教程...

public class DenLapehActivityMapper
implements ActivityMapper{
    @Override
    public Activity getActivity(Place place){

        if (place instanceof AyamDenLapehPlace)
            return KurungAyamActivity;
        if (place instanceof ItekDenLapehPlace)
            return KurungItekActivity;
        if (place instanceof KabauDenLapehPlace)
            return KurungKabauActivity;
        if (place instanceof KancilDenLapehPlace)
            return KurungKancilActivity;        
        etc, etc, etc ...

        return null;
    }
}

如果您是 GWT 开发团队,是否会有任何技术动机(或消极动机)来进行此更改?如果您是 GWT 开发团队,那就更好了。你为什么不做出这个改变?

I am having thought experiments investigating the viability of enhancing Place class. Presuming Google would grant us courtesy of such an enhancement, would the following enhancement to the Place class be helpful?

Let us say that the Place class is enhanced to have the method

setActivity(Activity act)

Then, we would be able to do this:

public class StartActivity extends AbstractActivity implements Presenter {

    private ClientFactory clientFactory;
    private String name;

    public StartActivity(StartPlace place, ClientFactory clientFactory) {
        this.clientFactory = clientFactory;
        this.name = place.getName();
        place.setActivity(this);
    }
}

So that the ActivityMapper would be so simple ...

public class DenLapehActivityMapper
implements ActivityMapper{
    @Override
    public Activity getActivity(Place place){
            return place.getActivity();
    }
}

However, my thought experiment, weighing the current situation, leads me towards having to do these

abstract public class DenLapehPlace
extends  Place{
    private Activity activity;

    public Activity getActivity(){
        return activity;
    }

    public void setActivity(Activity activity){
        this.activity = activity;
    }
}

public class DenLapehActivityMapper
implements ActivityMapper{
    @Override
    public Activity getActivity(Place place){
        if (place instanceof DenLapehPlace)
            return ((DenLapehPlace)place).getActivity();

        return null;
    }
}

Or even worse, following the examples/tutorials ...

public class DenLapehActivityMapper
implements ActivityMapper{
    @Override
    public Activity getActivity(Place place){

        if (place instanceof AyamDenLapehPlace)
            return KurungAyamActivity;
        if (place instanceof ItekDenLapehPlace)
            return KurungItekActivity;
        if (place instanceof KabauDenLapehPlace)
            return KurungKabauActivity;
        if (place instanceof KancilDenLapehPlace)
            return KurungKancilActivity;        
        etc, etc, etc ...

        return null;
    }
}

If you WERE the GWT dev team, would there be any technical motivation (or demotivation) to make this change? Better still, if you ARE the GWT dev team. why would you not make this change?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

递刀给你 2024-12-08 18:37:05

原因很简单,因为预计单个给定地点会有许多活动。

请参阅 http://blog.ltgt.net/gwt-21-activities/http://blog.ltgt.net/gwt-21-activities-nesting-yagni/

Simply because it's expected to have many activities for a single given Place.

See http://blog.ltgt.net/gwt-21-activities/ and http://blog.ltgt.net/gwt-21-activities-nesting-yagni/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文