Is it advisable to have a handle object inside a handle object?
Show older comments
Hi,
I would like to create two classes, say, class1 and class2 both of which inherit from the handle class. Therefore I have
classdef class1 < handle
properties
prop1
end
end
classdef class2 < handle
properties
prop2
end
end
Now suppose I create an instance for each of the classes, say a1=class1 and a2=class2. Is it advisable to set
a1.prop1=a2
a2.prop2=a1
?. That is, I have put each object inside each other. The advantage of this strategy is that I can easily manipulate a2 from within the body of a1 and vice versa. The problem, I don't know whether it is really a problem, is the clear circularity or infinite loop this strategy creates: a1 is inside a2 which is inside a1, inside a2,...
Is this advisable to do this? Is there an alternative way of dealing with this? i.e. being able to manipulate each object from within the body of the other.
Thanks
Accepted Answer
More Answers (0)
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!