Design pattern for "Read, Process, Save" pattern?

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:

  • Has an IInput implementation to handle reading and loading itself.
  • Can be validated through "rules"
  • Has an 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.

-------------Problems Reply------------

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:

  • C# -Pipeline Style event model
Category:c# Views:0 Time:2011-11-28

Related post

Copyright (C), All Rights Reserved.

processed in 0.063 (s). 11 q(s)