tags:

views:

105

answers:

1

I am trying to design an edifact parser, I was planning on having one class to read the file, one class to map the data and then one other class to deal with data storage. The part where I am having a major problem is in how instances of those classes should communicate with each other. Any advice would be appreciated.

+2  A: 

I don't see a need for the classes to communicate (pass messages) but would suggest some Strategy pattern be used.

You'll have a class to read the file and make sense of it's Syntax. For example, something which can handle whitespace and return formatted information like 'token', 'word' etc.

The class which reads and parses syntax is passed into the Semantic parser. The Semantic parser makes sense of the meaning. For example you might expect "Id, command, token, string" in that order. The Semantic parser might use a Command pattern.

The Semantic class outputs structured data, so is passed into your structure builder (builder pattern).

So your code might look like;

MyDataStructure = DataBuilder(SemanticParser(SyntaxParse(FileReader(filename))));

HTH

Dead account