Is is necessary to use set/get functions?

2 ビュー (過去 30 日間)
TADA
TADA 2019 年 2 月 12 日
コメント済み: TADA 2019 年 2 月 12 日
Is it still necessary to use the set/get methods to set/get the properties of UI components?
fig = figure();
fig.Color = 'white';
% works the same as
set(fig, 'Color', 'white');
So is it just for backwards compatibility or what?

採用された回答

Guillaume
Guillaume 2019 年 2 月 12 日
It's not been required since R2014b, where all graphics handles became proper objects. Now, it is just an alternative way of settings the graphics property. set still has a few advantages over a plain property assignment:
  • you can set several properties at once
  • it can be used inside anonymous functions
  5 件のコメント
Adam
Adam 2019 年 2 月 12 日
編集済み: Adam 2019 年 2 月 12 日
GUIDE and programmatic GUIs (and even AppDesigner) all have their uses, it's just a case of deciding which tool is best for the job, like an artist deciding what type of pencil to use for a drawing. Programmatic GUIs are like a well and continually sharpened pencil, GUIDE GUIs are like a bit of a blunt pencil that can, nevertheless, get a simple job done faster, and AppDesigner is, well, still being developed and improved so won't always be like a child's crayon hopefully! In my own code I tend to only use set/get now for setting properties on an array of handles, as one of the cases Guillaume points out. I write most of my code in classes so the newer syntax for ui components matches that and is very intuitive for me.
TADA
TADA 2019 年 2 月 12 日
didn't change my mind, but well said nonetheless...
+1 (if it was possible to vote for comments...)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by