Re: Design Question
Novice <novice@example..com> writes:
The game is capable of showing the score either during the game or at the
end. In both cases, I simply display a dialog showing the score.
As a user I am annoyed by such informational dialogs,
because they hide something and require my action.
The score should better be displayed as a text field
somewhere in the main game window.
finished, I entitle the dialog "Final Score". When the player is given the
interim score, the button at the bottom says "Quit" and he is returned to
?Quit? a score dialog? I think the usual button is ?OK?,
which is also nonsense, but at least common nonsense.
At the moment, I have a single class that gets invoked to show both the
interim score and the final score.
Classes can not be invoked. Methods can be invoked. What you
mean is ?a class, an instance of which is created to show ...?.
While the dialog is simple and works just fine, I suspect I'm
violating some OO principles by making the behavior of the
class change depending on what kind of score is being shown.
I am not aware, whether such a principle exist, but you
could also use:
class InterimScore extends Score { public InterimScore(){ super( true ); }}
class FinalScore extends Score { public FinalScore(){ super( false ); }}
Or is there a better way?
If your boolean approach is working fine, I see no need to
change it. What you think of are the template method or
strategy patterns, but there is no need to apply them here.