MATLAB: Call superclass method without knowing name of superclass

methodobject-orientedsubclasssuperclass

I would like to call a method of a superclass from a subclass after performing some additional operations within the subclass method. However, to make the code general (say I change the superclass name or add an intermediate class later between the super- and subclass), I would like to be able to call the method without explicitly naming the superclass, which would prevent me from using the standard command:
function_name@superclass_of_interest(arg1,arg2,etc)
I have thought of two ways of doing this, neither of which I am enamored of.
First, use an eval statement:
eval(['function_name@' superclass_name '(arg1,arg2,etc)'])
Second, create a "glue class", which subclasses the actual class of interest and contains nothing more than a constructor:
classdef glue_class < superclass_of_interest
methods
function obj = glue_class(varargin)
obj = obj@superclass_of_interest(varargin{:});
end
end
end
Now if I subclass the glue_class instead of the superclass_of_interest, I only need to change the class name within a the (simple) glue_demo file instead of in every function of my actual class from which I would like to call a superclass method.
Is there a more elegant solution? My naive attempts at creating function handles to the superclass method failed, as did trying to use an feval statement.
EDIT: per Daniel's answer, the "glue class" (which MATLAB calls an alias class) described in the second proposal above appears to be MATLAB's recommended solution.

Best Answer

It sounds like you are concerned that if you hard code the superclass name and then you change the name of the superclass you will need to change lots of code in your subclass.
One option is instead of renaming your superclass, to newsuperclass. Create newsuperclass and make superclass a subclass of newsuperclass. Then move all the methods from superclass to newsuperclass. This preserves backwards compatibility and lets you change the name.
I think there is an oop example for this. I will check later.