Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How cohesive is high cohesion?  RSS feed

Joe Lemmer
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

Just for practice and fun I'm making a Poker Hand History reader. When you play online poker a text file containing every hand played during that session is produced while you play. I want my Hand History Reader to parse the text file and get all the data into the appropriate chunks for analysis or display. As I'm reasonably new to OO design I'm having the following problem:

This is some sample text from a single line of a single hand in the text file:

On that one line there are 5 separate bits of information that I want to parse:
1. It's a no-limit game (as opposed to pot-limit or limit).
2. The currency is dollars.
3. The blinds are 0.25/0.50
4. The game type is Texas Hold'em
5. The date

This information is on the same line at the site that I play on, but it's possible that in the hand history files for other sites the same info is on different lines. How I've decided to design things is to have seperate classes such as StakesParser, CurrencyParser, GameVariantParser, DateParser etc. Each class would have a public API of just parseCurrency(StringBuilder data) for the CurrencyParser, or parseStakes(StringBuilder data) for the StakesParser class. What I want to know is "Is this a good example of a design with high cohesion, or is this over the top and I should be thinking of having one class that has all the methods needed for parsing all the info on that line?"

I'm going to have a HandHistoryParser interface that outlines what a hand history parser should do (Parse all the info needed to create a GameState object for that particular hand) and then I could have a class which implements to HandHistoryParser interface for each poker site so that it deals with the specific hand history layout in the text files from that site. Is this OK also?

Any comments on design would be greatly appreciated.

Many thanks

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!