A few years ago, I mentioned that the registry pattern was my favorite pattern in Python. Well, it may also be my favorite C++ pattern.
I’ve implemented this pattern in most of my production code, when different algorithms are needed for some computation. Some weeks ago, a colleague asked to use one of my production codes, because the parallel I/O were hidden inside a job scheduler. The only thing he had to do was deriving a base class, implement the algorithm, and he could use the massively distributed framework. Of course, the derived class builder was registered in a map, registry pattern inside.
The idea of the plugin emerged when he didn’t want to compile the whole distributed system. As his class was automatically registered on startup, the plugin system was quite easy to implement: just dlopen() the library, and the build would be registered. Usually, you have to extract some function from the library before being able to use it. With a registry pattern, this is no longer the case. So I did just that, and now all the complicated algorithms can now be exported as plugins, which eases the building process (through SCons) and of course the algorithm development (big time).
Now, I just need to optimize the distributed framework for I/O…