Suppressing superclass methods/events
이전 댓글 표시
Is there a way to suppress super class methods and events? For example, a class based on handle:
classdef my_class < handle
inherits methods (addlistener, isvalid, etc.) that users of my_class don't need. I want to preserve a clean interface that prevents access to things defined outside of my_class.
댓글 수: 2
Walter Roberson
2011년 12월 9일
Would it be enough to hide them somehow, so they don't show up in a normal methods listing? Or do they have to be gone?
Daniel Dolan
2011년 12월 16일
채택된 답변
추가 답변 (1개)
Daniel Shub
2011년 12월 10일
0 개 추천
I don't think so. I think this would violate the idea that an object of a subclass is also an object of the superclass. Maybe you do not want to subclass the handle class, this will reduce the number of inherited methods.
You also could switch to the old OOP system where you had to roll your own methods for nearly everything and hence had more control.
It is unclear why isvalid, and the like, would give individuals access to things outside your class.
You also could overload subsref to prevent calls to addlistener and isvalid. This could get ugly though.
카테고리
도움말 센터 및 File Exchange에서 Handle Classes에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!