The Artima Developer Community
Sponsored Link

Legacy Design Forum
Designing with Interfaces

Advertisement

Advertisement

This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

factory with one create method or several special ones

Posted by chantal on January 30, 2002 at 11:22 AM

hello all,

for some time now, I'm trying to solve a design problem. First, I will give you a quick summary of what I want to do (use cases) and then I will propose my solutions (I am not satisfied with).

Summary: The big goal is to parse files and put relevant data into a database. The problem is, that there are different kinds of sources coming with different kinds of files: sometimes only a single file, sometimes several files of the same format (same parser for all), sometimes several files and each has a different format, sometimes a zipfile with severel files of the same/ a different format.
These differences concern the allocation of the data and the opening of an inputstream of any kind, and the parsing of the data.

What I like to do is, to keep most of the program independent of these differences.

My "overall" design is a DataExtractor that is independent of these differences and delegates the work to an InputAllocator and a Parser. From the Parser it gets back a DataBlock that is passed to a DataInserter.

The InputAllocator:
1. solution: An InputAllocatorFactory with a single create method.
2. solution: An InputAllocatorFactory with a create method for each source target.
3. solution: An InputAllocatorFactory with a create method for each kind of filepackage (single file, multiple/different files, zipfile etc.) != solution 2
4. solution: One InputAllocator with several private methods for the different cases.

Which solution is best depends greatly on the answer to the question: in what way transforms the Allocator the data and is the returning method for all kinds of source targets the same?

As I write this, I realize that my problem is not really to decide between one of the above solutions but to find a way to get the Allocator and the Parser to work in a most general way together. But is that really possible? In case the source is a zipfile or several different files, the parser has to know which file is to parse and how to get it. Or am I in need of some more classes here?

most confused,
Chantal



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us