フィルターのクリア

function call and return readability

2 ビュー (過去 30 日間)
Kambren Rowlan
Kambren Rowlan 2017 年 8 月 10 日
回答済み: Walter Roberson 2017 年 8 月 10 日
I'm refactoring some code and am coming across some functions that have a lot of inputs and outputs which is causing some readability issues. Is there a good practice to handling this, my intuition is pushing me to create structs and pass those around (because I personally like structs), but I'm rather unsure of convention around things like this.

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 8 月 10 日
Probably the more modern method would be to create a class or several and pass objects around. To be honest I have never done that myself, and instead use struct or cell array or table objects.
Way Back When, when I was studying software design, the books emphasized that you should beware of "coincidental" bundling of data structures. That happens when you put multiple data items into one data structure not because they have any meaningful relationship to each other, but just because they both happen to be needed by some routine.
The books also emphasized separation of "control" variables from "data" variables, but I don't think I have consciously paid attention to that for decades. Especially in MATLAB, where "control" information such as masks might well be arithmetically multiplied by data

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by