Need a design pattern for representing multiple information sources
- by hsmit
I'm building a Java application that retrieves information from differing information sources. I'm using a sensor, a set of RecordStores and a few online web services.
In the basic application all these resources are loaded by default. Some of these sources are directly read in a separate thread (load database, read sensor etc.).
From this basic application some functions are started that use these sources.
The classes that contain these functions (usually combining multiple sources information) are currently paramterized with a set of resources like this:
AppPart a1 = new AppPart(source1, source2, source3);
I could also do it like this
AppPart a1 = new AppPart(this);
..where I need to make my sources public in order to read them.
I'm also thinking about a kind of stage/collection to publish all sources on, e.g:
public SourceCollectionStage sStage = new SourceCollectionStage();
and later:
sStage.getSensor();
.. for example.
What do you guys think is the best or most often used way to do this?
Btw: the user interface is often implemented by the specific funtion classes, not by the main class. Should I do this in another way?