フィルターのクリア

Matlab style: should table names be capitalized?

8 ビュー (過去 30 日間)
KAE
KAE 2017 年 1 月 17 日
編集済み: KAE 2017 年 1 月 17 日
In Elements of Matlab Style, Richard Johnson recommends capitalizing structure names to distinguish them from variables. Now that tables have been introduced, should table names be capitalized for the same reason? I am writing code that will be shared with users who are unfamiliar with tables, so I want to make things easier for them if possible.
  1 件のコメント
Adam
Adam 2017 年 1 月 17 日
編集済み: Adam 2017 年 1 月 17 日
I never use tables and rarely structs, but I always use lower case for variable names (well, camelCase) and capitalisation for class names (though not their objects, which are variables, hence lower case) since I use OOP. It's all personal preference though. Our company's development team arbitrarily switched over from using camelCase to snake_case a few years ago. People just work with whatever standard is dictated. If you are lucky enough to be the one doing the dictating (as I was for our Matlab repo which retained its camelCase approach) then you can choose whatever you want that makes sense.

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

採用された回答

Image Analyst
Image Analyst 2017 年 1 月 17 日
I agree with Adam (whose comment above should have been an Answer). I use camelCase for all variable names regardless if it's a double, a table, a structure, or whatever. I don't know why a structure name would need to be distinguished from other types of variables. Variables come in all types from simple double scalars to more complicated arrays and structures, to even more complicated classes. I don't know why it would help to change capitalization since you need to know what kind of variable it is in the first place just to use it. However most of the other recommendations are good, such as using descriptive variable names, avoiding cryptic code, using lots of comments, using proper indentation, a line of code should contain only one executable statement (despite the fact that he himself violates it in the document), etc. Loren Shure also has a blog entry: http://blogs.mathworks.com/loren/2014/01/29/coding-best-practices-a-good-read/
I usually use snake_case for m-file names for my demo scripts, but not often for variable names.

その他の回答 (0 件)

カテゴリ

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