Is this OK practice?

Started by
1 comment, last by nilkn 18 years, 8 months ago
I wrote a hangman game the other day when I had nothing better to do, and I did something about which I'm unsure as to it's general acceptability. I wrote the game in C#, and essentially did it in two classes, one pertaining to the game logic, the other to the game interface. The game logic class had such public methods as CheckForWin, EnterUserInput, StartNewGame, and ChangeDict. There was no all inclusive Run method. Certain properties were also exposed, the more important of which being CurrentWord, RevealedWord, WrongLetters, Misses, NumGuessesThisRound, and RoundNum. So basically the game logic class was not totally self-contained -- the game couldn't be played without additional coding, namely the interface. It was also left to sort of "manage" the game class, since, because it was responsible for getting user input, it had to call such methods as those listed above explicitly. Ultimately this has the advantage of additional flexibility in design, such that the game logic is portable without modification between different interfaces. In other words, I could easily change the interface without needing to modify game logic. This seems good to me -- however, is the method about which I went to accomplish this as acceptable? Namely, are there better methods which in this case could be applied such that more elegance is gained, by way of perhaps fewer public interface components (methods, properties, etc.) being exposed? Are there general methods which are often applied to solve such problems as these?
Advertisement
Well... if you do not code it at all it will be maximum flexibility. User can recode game by his needs.

I mean... every stick got 2 ends
Quote:Original post by Anonymous Poster
Well... if you do not code it at all it will be maximum flexibility. User can recode game by his needs.

I mean... every stick got 2 ends


My question was about methods by which the flexibility in design could be achieved. Specifically, I asked for methods better than the one I've already employed. Yours clearly does not satisfy this latter criterion.

If you're implying that such flexibility is bad in the first place, however, perhaps you could elaborate?

This topic is closed to new replies.

Advertisement