samedi 14 mai 2016

How to design a Data Processing class in Java

Part of an application that I am trying to make requires data processing.

I need to read data from different sources(web pages, local text files, databases,etc), then parse the data which will be in different formats(HTML, JSON, etc) and finally write the data somewhere else(database, text file, etc) or possibly return an object(such as an array of strings).

I have tried to use a Strategy Pattern to make a DeckProcessor class that has a ReadStrategy a WriteStrategy and a ParseStrategy except the problem I encountered is that reading from different sources requires different parameters, for example reading from some web pages requires just a parameter for a url while others require a parameter for a url and another one for a password. Furthermore, writing the data has to return different things, for example sometimes it has to write to a file while other times it has to return an array.

What would be the best way to design a DeckProcessor class so that it can be easily extended in the future, for example adding a new ParseStrategy that will parse XML documents.

Thank you for your time.

Aucun commentaire:

Enregistrer un commentaire