public interface Behaviour<D extends GameComponent, S, R extends Result<S>> {
public String getName();
public R execute(D component, S state);
}
With behaviours being so varied in implementation I am worried that state will become a god object with many different fields. This then seems bit over kill for behaviours that only need a segment of state and not everything. First of all is this even a anti pattern and then how would I go about resolving it?
I have considered making it so the behaviour registers the states or segments it needs on creation but im just not sure how that would look. Furthermore I considered making state a store in which all the fields were stored under a key and value. Only thing I don't like about this is having to cast the objects on retrieval.
Aucun commentaire:
Enregistrer un commentaire