Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Good evening.
Recently I've been thinking of making a simple TBS game in Java for fun and I was wondering if my logic is correct.
Basically, I have the following classes:

public abstract class Effect {
    protected EffectType type; //enum which contains all the possible effect types
    protected int value;
    protected int duration;
    ....
    }
    public abstract void cast(Hero hero);
    ...
}
public class Hero {
    ...
    public void sufferEffect(Effect effect){
        effect.cast(this);
    }
    ...
}

I don't know why but it feels a bit clunky to me. Do you think this is a good approach?

share|improve this question
1  
Looks great to me. Not sure you can attempt to actually answer such a question though. In the end, it's all about your coding style, and the style of those who answer. From a technical point of view, your approach can't cause issues unless you cause them yourself. – Bogdan Marginean Apr 21 at 22:40
I understand you; it's just that we've been studying OOP design patterns at school lately and I'm incredibly confused about how to apply them in the real world and how far to go with the abstractions before everything becomes silly. – Cristian Apr 21 at 22:51
Perhaps it's a nuance, but a better name would be applyEffect Or addEffect. – Sidar Apr 21 at 23:59
Doesn't really feel like there's an answerable question here. Does your code work? Does it do what it needs to do? Some problems in game development are "clunky" because their design doesn't necessarily fit into neat little code patterns. – Tetrad Apr 22 at 3:24
2  
I was going to answer that this looks clunky because Hero.sufferEffect seems like using double dispatch, and was going to offer an alternate design with hero methods such as TakeDamage, but this question was closed :( – Cong Xu Apr 22 at 3:26
show 1 more comment

closed as not a real question by Anko, Josh Petrie, Tetrad Apr 22 at 3:24

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

Browse other questions tagged or ask your own question.