How to display aggregation and composition in Class Diagram Viewer?
10 次查看(过去 30 天)
显示 更早的评论
I note that there are no aggregation or composition in the legend. Is it beause Class Diagram Viewer doesn't support them?
If it support them, how do I make sure these relationships are working?
2 个评论
Jon
2022-10-13
I have the same question. It seems that you have not gotten any responses though. So specifically if a class A has as a property an instance of a class B, then how do you diagram that A "has a" B?
回答(2 个)
Aneela
2024-2-14
Hi, Mahmoud Elzouka
The “Class Diagram Viewer” shows inheritance relationships very effectively.
Currently the association relationships like aggregation and composition are not supported by the “Class Diagram Viewer” app.
For more details regarding the class diagrams and creating them in “Class Diagram Viewer” app, refer to the following link.
0 个评论
Jan Kappen
2024-6-18
编辑:Jan Kappen
2024-6-18
It does!
You just need to tell MATLAB which type of object you're expecting.
Assuming:
myClass.m
classdef myClass
properties
composition compositionClass % type hint here!
end
methods
function obj = myClass(compObj)
obj.composition = compObj;
end
end
end
compositionClass.m
classdef compositionClass
properties
prop (1,1) double = 1
end
end
This is properly one of the best features added to MATLAB in the last years. See details here: Function Argument Validation - MATLAB & Simulink (mathworks.com)
Be sure to check the box "associations".
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Properties 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!