0
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.

  • I think the answer to another question may also answer this one, [Should the caller or callee access object fields?](https://stackoverflow.com/q/66219682/1371329) – jaco0646 May 14 '21 at 11:46
  • I'm not familiar with Java. Is `Result` a well-known type? – Mark Seemann May 16 '21 at 18:42

0 Answers0