Google’s Web Alerts service reminded me of a question I once asked in a newsgroup. Since I didn’t get a response back then, I thought I’d post it here again.
The Top Level Design:
The class Base is a factory class with a twist. It uses the Assembly/Type
classes to extract all types that inherit from it and add them to the list
of types that inherit from it. During run time, using a static method, the
class creates an instance of the derived class using the Activator class and
returns it. This design pattern is very similar to the design pattern
applied by the Assembly class.
The twist is that all inheritors of Base must specify a small amount of
metadata. The metadata will be hard-coded into the derived classes and a
lack of the said metadata must be discovered at compile time.
- Base is not a component.
- Derived classes may be inherited as well.
- All derived classes must have unique metadata.
There are several ways to approach this problem…”