I am using the GWT Activities and Places framework to structure my application and it is turning out nicely. One thing that annoys me though is that the ActivityMapper
One possibility is to have the root of your Place class hierarchy define a createActivity() method, and Place subclasses can return a new instance of the Activity they're associated with.
@Override
public Activity getActivity(Place place) {
return ((BaseAppPlace)place).createActivity();
}
This has the advantage of having eliminated that if/else block, and having one less place to modify when you add a new Place/Activity. The downside of this is that it kindof pollutes your Place class with Activity creation behavior, even if you're just delegating to a Ginjector.