jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes How cohesive is high cohesion? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How cohesive is high cohesion?" Watch "How cohesive is high cohesion?" New topic

How cohesive is high cohesion?

Joe Lemmer
Ranch Hand

Joined: Oct 24, 2008
Posts: 171
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


I agree. Here's the link: http://aspose.com/file-tools
subject: How cohesive is high cohesion?
jQuery in Action, 3rd edition