-5

So I am new to design patterns and C++11, but I have been studying both quite a bit. I am working on developing a C++ application to process some data, and I was hoping that someone with more experience could tell me if I am on the right track.

So the application will take in a large 2-D array of data. Then there is some preprocessing before passing the data to an object that will process the data. Finally, the results of the processing have to be post-processed to set up different types of plots and summary info.

So in studying the design patterns I saw that using the Command pattern or Strategy pattern might be a good fit. But at the same time, seems like I should use the Composite as a way to tie together the preprocessing, processing, and post processing. But I was concerned that tying together 3 objects into a composite might make a very large object--meaning that I would violate separation of concerns type rules.

The reason I want to use a design pattern is because I want a flexible way to add new type of preprocessing, processings, and post-processing chains to the application. So if today I produce one set of charts from the analysis, tomorrow there might be a new chart that someone wants. So I would need a way to add new types of requests or processing chains, without going in and breaking existing objects--which defeats the purpose of OOP design.

Any design tips would be appreciated.

EDIT Note, this question is distinct from: Choosing the right Design Pattern

The reference questions is a general questions about software design approaches. The questions I pose asks for a specific design recommendation based upon a set of requirements.

krishnab
  • 179
  • 1
  • 7

2 Answers2

3

I think what you are looking for is an appropriate software architecture rather than a design pattern.

In your case, I think it will be helpful to study dataflow architecture and employ it in your particular situation.

I see the following distinct types of components in your architecture.

  1. Data source
  2. Pre-processor
  3. Processor
  4. Post-processor
  5. Data sink

The simplest instantiation of the architecture will consist of:

Simple Dataflow Architecture

A slightly more complex instantiation of the architecture may consist of:

More Complex Dataflow Architecture

R Sahu
  • 2,016
2

It sounds like a job for Chain-of-responsibility (https://en.wikipedia.org/wiki/Chain-of-responsibility_pattern) pattern. It allows for loose coupling so you won't have to use composition.

William L
  • 114
  • 3