samedi 27 août 2016

Design pattern for parsing text

I have a kind of logical problem. I have to write a program which should parse messages of different types. Below I show an example how those messages look like:

MESS1

DATE=06.06.2016
CAR_MODEL=OPEL

#Total_Number3
#Max_HP123


MESS2

DATE=12.01.2016
CAR_MODEL=FORD

MARTIN/SMITH
JOHN/PUTIN


MESS3

DATE=13.12.2016
CAR_MODEL=BMW

1/3/4

I know its not a difficult to code in a simple way, but I would like to implement this using design patterns which allow me to easily modify it when new type of message appears, some type of message changes or a message contains data in different order.

P.S I was thinking about Builder but messages does not contain the same fields so in my opinion it does not fit.

Greetings and thanks in advance!

Aucun commentaire:

Enregistrer un commentaire