Frage

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?

War es hilfreich?

Lösung

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/

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top