Hi there,
I'm learning OO principles and for practice I'm developing an application in Java.
The application is to parse the hand history text files issued by poker sites after every poker hand is played and to extract the same types of data from the file no matter which site the hand history is from.
The hand history files can be in very different formats depending on the poker site. Some sites have each hand in a very human-readable style eg:
NL $0.25/$0.50 Texas Hold'em - Tuesday, June 22, 19:55:24 GMT 2010
and others have an XML style.
My question is: When parsing the above line from the text, should I have separate classes to parse each element? For instance should I have a StakesParser class with a parseStakes() method and then a CurrencyParser class with a parseCurrency() method etc. Or should I have a single class that can parse that line and get all the different bits of info from it?
To have a separate class for each thing I want to parse seems more OO, but less efficient. Any advice?
What I want as a result of the parsing process is a GameState class which would hold all the info for one hand of Poker. So no matter what site the hand history file was from I would be able to make an object of type GameState with all the relevant info parsed for it by an HHParser class.
To this end, I thought it would be a good idea to have an interface which would have to be implemented which would ensure that the HHParser for each poker site would end up producing a GameState class. So the interface would have methods such as parseStakes(), parseCurrency() etc. Is this the right approach?
What makes it more confusing for me is that on different sites, the information is in a different order so I possibly need a controller class that makes sure that each method is called in the right order depending on what site the text file is from.
Sorry about the waffle, but I'd be grateful for any pointers on what is might be best to do.
Many thanks in advance. :-)