GWT Place Class 增强可行性
我正在进行思想实验,研究增强地点课程的可行性。假设 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原因很简单,因为预计单个给定地点会有许多活动。
请参阅 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/