Posted on 2006-03-22
We are trying to do the following.
We have a program where we want a "black box". The black box will take in a Person object and return back a Result object.
We can do this in several ways. One method was to have every black box have a "RunTest" function. It could be static class or a Singleton pattern. If we go with instances then we do not ever need more than a single instance of a given black box, hence looking at the Singleton pattern.
However, here is where we hit a problem.
We would like to enforce a few certain things in each black box. For example, it must have a private function that loads settings from a config (xml) file.
Therefore an interface will not work.
So, we thought that we could create a base class of BlackBox and have all actual black boxes inherit from that one. However, we are not sure how this can be implemented without losing the ability to restrict to a single instance.
Is there any design pattern that addresses this issue. Basically a black box that has a defined function signature, and some pre-defined settings/initialization actions, but that anything else that it does is up to the programmer. Also a way to restrict to only one isstance if possible.