Original Post
I'm working on future-proofing my architecture. Currently, interested components can sign up for notification of events through a templated system that keys event handlers to a string. (I am considering GUIDs for the key, but that isn't the point). The data that is passed around within the event is usually either a simple type (int/bool/char*) or an abstract base class. The problem the abstract base class is brittle. When I go to refactor the base class, all the client code must be recompiled to reflect the modified vtable, or it will spew access violations left and right. This isn't suitable for a system that is designed to be extensible. It should be more failsafe than relying on the virtual function table matching up exactly. I considered only loading components that match the API 'version' so these sorts of inconsistencies could be detected, but that seems half-assed. Another solution is fairly creative: * Rewrite abstract base classes to be concrete * Base class implementation is little more than a call to GetProcAddress() with the 'polymorphic' function explicitly named (e.g. AccountConnect(void* acct, const char* server, unsigned short port)). Since all components are loaded from DLLs, the 'contract' between components changes from a brittle vtable to a string lookup managed by the OS. The behavior is still polymorphic -- but a little more code has to be written. Additionally, there is the issue of adding method calls and existing components not implementing them. This gives me pause. I thought it was an interesting take on the problem, and I'm sure its been implemented elsewhere, but I'd like to know what you think.