C#C
C#2y ago
29 replies
BenMcLean

OOP design pattern question

I have an interface called IModel for voxel models. I don't want to change it because it has lots of existing implementations without a base class.

There are about a dozen different operations that can be done on the IModel interface. Currently these are static methods in a static class with no global state.

Certain special implementations of IModel have special implementations of some of these methods that get the same result more efficiently from taking advantage of their internal data structures beyond what IModel offers. These are only available for some operations on some IModel implementations some of the time, not consistently.

I want to make it so that when user code calls one of these operations, the program will choose the more efficient special implementation when available or resort to the default IModel version if not available.

What OOP design pattern should I be following to make that happen?
Was this page helpful?