I'm looking for a desing pattern to solve the following:
Read an Input
Process the data (inc validation)
Save the result
Examples would be: Read a csv file, process the data, save as xml Read an MQ message, process the data, save to database.
I was thinking of a BusinessObject that:
IInput
implementation to handle reading and loading itself.IOutput
implementation to handle saving itself.e.g. (pseudo code!)
public abstract class BusinessObject
{
public IInput Input { get; set; }
public IOutput Output { get; set; }
public BusinessObject(IInput input, IOutput output)
{ }
}
and then have a Load, Process and Save method.
However, it doesn't seem right to me. I think the BO should be capable of loading and saving itself?
If anyone knows what pattern this might be so I can read up on it, or give me an example/explanation I would be very grateful.
You could potentially use the Pipeline pattern. In that pattern, you define a chain of components (pipeline components; the chain is then the pipeline) and you feed it input data. Every pipeline component is then executed in turn on the data that is being pushed through the pipe. Any component can read data from and write data to that data.
See also:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With