in reply to Best practice for a module which can use one of multiple image modules

(In any programming language ...) This is a great place to use classes. The image-handling operations are defined by what (in other languages) would be called an "abstract parent-class" which defines how the rest of the application sees it. Then, for each actual implementation, you have a "concrete" child class that inherits from the parent and implements all of its methods.

It is also common practice to build a "factory" which, given various appropriate parameters to describe the input that is to be handled, automatically returns a child object of the appropriate concrete class. The rest of the application, therefore, doesn't have to care. It simply treats the returned object as though it were the abstract parent.

  • Comment on Re: Best practice for a module which can use one of multiple image modules