OO Design Issues

I learn the principles of OO, and for practice I am developing a Java application.

An application should analyze the hand history text files issued by the poker sites after each hand in poker is played and extracts the same types of data from the file, regardless of where the hand history is located.

Hand history files can be in a variety of formats, depending on the place of poker. Some sites have each hand in a very human-readable style, for example:

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 line above, do I need to have separate classes to parse each element? For example, should I have a StakesParser class with the parseStakes () method, and then a CurrencyParser class with the parseCurrency () method, etc. Or should I have one class that can parse this string and get all the different bits of information from it?

To have a separate class for each thing I want to parse seems more OO, but less efficient. Any tips?

What I want as a result of the parsing process is the GameState class, which will contain all the information for one poker hand. Therefore, no matter where the hand history file was created on, I could create an object of type GameState with all the relevant information analyzed for it by the HHParser class.

, , , , HHParser GameState. , , parseStakes(), parseCurrency() .. ?

, , , , , , , , , .

, , .

.: -)

+3
2

, " ". , , - factory, .

public class ParserFactory {
  public static Parser get(String url) {...};
}

, Parser, - java bean, .

public interface Parser {
  public Collection<Hand> parse();
}

Parser , , factory. Commons Digester XML ANTLR -XML.

+4

, , , .. .

OO, Java-. Java .

+1

Source: https://habr.com/ru/post/1757687/


All Articles