Design Pattern for Read, Process, Save Template?

I am looking for a template to solve the following problems:

Read input

Process data (with verification)

Save result

Examples: Read the csv file, process the data, save as xml Read the MQ message, process the data, save it in the database.

I was thinking about BusinessObject, which:

  • It has an IInput implementation to handle reading and loading itself.
  • Can be confirmed using the "rules"
  • It has an IOutput implementation for saving itself.

eg. (pseudo code!)

 public abstract class BusinessObject { public IInput Input { get; set; } public IOutput Output { get; set; } public BusinessObject(IInput input, IOutput output) { } } 

and then apply the Load, Process, and Save methods.

However, this does not seem right to me. I think BO should be able to load and save itself?

If anyone knows which template can be such that I can read it or give me an example / explanation, I would be very grateful.

+4
source share
1 answer

You could use the Pipeline template. In this template, you define a chain of components (pipeline components, a chain is a pipeline), and you feed it with input. Then, each component of the pipeline is queued for data that is pushed through the pipe. Any component can read data and write data to this data.

See also:

+4
source

Source: https://habr.com/ru/post/1383416/


All Articles