E
E
edwardoid2011-04-04 11:34:42
Design patterns
edwardoid, 2011-04-04 11:34:42

What pattern to use?

The task is this:
There is a certain application, some of its module works with dynamically connected plugins and itself performs some other task.
Plugins work and return some structure as a result. Plugins can use each other, even cyclically. Those. one plugin can call another as an assistant (or maybe several, depending on which ones are available at the moment), and that one, in turn, is the third plugin or even the first one.
The structure of the application is as follows:
42d0394a8bc6.png
I can't choose a pattern, such that further writing plugins, and maybe expanding the interface, does not turn into torment. How to implement correctly ?
I write in C++/Qt

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Golovanov, 2011-04-04
@Colwin

It is necessary to specify the requirements, namely:

  • Are the plugins written for internal use, or can there be third party plugins?
  • Is it correct to assume that all plugin calls to each other occur within the same thread?

I would implement it in the following way.
To decouple dependencies between plugins, we create a plugin manager that can load a plugin by name. I would like the calling code to pull the plugin through a single interface. Moreover, each plugin, logically, has its own set of input parameters. If it is not possible to select common parameters for all plugins, then, apparently, there is no escape from parameter type casting.
It may make sense to return a result not as a structure, but as a callback (if within the same thread). This will make it possible to implement staged processing (if any data stream is used as a parameter).

A
Alexey Shein, 2011-04-04
@conf

Maybe "Team" and "Chain of Responsibility" will help you.

Z
zizop, 2011-04-04
@zizop

It seems to me that in this case it is necessary to use the "Strategy" pattern .

Strategy, Strategy - a behavioral design pattern designed to define a family of algorithms, encapsulate each of them and ensure their interchangeability. This allows you to select an algorithm by defining the appropriate class. The Strategy pattern allows you to change the selected algorithm regardless of the client objects that use it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question