naming-conventions

Dynamically name a struct variable in MATLAB

僤鯓⒐⒋嵵緔 提交于 2019-12-02 09:35:31
I have several files "2011-01-01.txt", "2013-01-02.txt", "2015-02-01.txt", etc. I wish to create a struct variable for each of the file such that (the values are made up): machine20110101.size=[1,2,3]; machine20110101.weight=2345; machine20110101.price=3456; machine20130102.size=[2,3,4]; machine20130102.weight=1357; machine20130102.price=123; machine20150201.size=[1,2,4]; machine20150201.weight=1357; machine20150201.price=123; And, save('f20110101.mat','machine20110101'); save('f20130102.mat','machine20130102') ; save('f20150201.mat','machine20150201'); As we can see, the struct names are

What naming conventions do you follow with functions that allocate memory?

a 夏天 提交于 2019-12-02 04:53:48
问题 So here are two functions that do almost the same thing. How would you name each one, if you had to include both in your project? void strToLower1(char* str) { int len = strlen(str); int i; for (i=0; i<len; i++) str[i] = tolower(str[i]); } char* strToLower2(const char* inputStr) { char* str = strdup(inputStr); strToLower1(str); return str; // must be freed } EDIT: I modified the above example for code-correctness (sheesh) 回答1: I really like the Taligent Coding Standards, especially the naming

naming convention of temp local variables

心已入冬 提交于 2019-12-02 04:25:01
问题 What is the standard way to name a temp variable in the local function? let me give you an illustration of what I am doing. I get a pointer to a structure, so I want store one of its members locally to avoid a de-referenced, and then any modification assign back to the pointer. To be more concrete: struct Foo { double m_d; }; void function (Foo* f) { double tmp=f->m_d; /***Other stuff***/ f->m_d=tmp; } I don't like tmp . If I have many of them in a function, they only add a confusion. Thanks

What's the significance of TLD-first domain-like identifiers?

大兔子大兔子 提交于 2019-12-02 01:28:51
问题 "TLD-first domain-like identifiers" is a mouthful but that's all I can come up with. I've seen these used in various places over the years and wondered what the history/reason behind this convention is, since you might be forgiven in thinking that there is one true way to mention a domain. I don't use Java but I recall from poking around that namespaces are often done like this: uk.co.tophats.stitchkit A specification file for a "Launch Agent" on Mac OS X: ws.agile.1PasswordAgent.plist A

Why do Cocoa-Touch class ivars have leading underscore character?

戏子无情 提交于 2019-12-02 01:21:37
Is there some purpose for this convention? Apple likes to use underscores to mean "private", according to the Coding Guidelines for Cocoa : Avoid the use of the underscore character as a prefix meaning private, especially in methods. Apple reserves the use of this convention. Use by third parties could result in name-space collisions; they might unwittingly override an existing private method with one of their own, with disastrous consequences. Method names beginning with underscores are reserved according to The Objective-C Programming Language (which means they're reserved even if you don't

What naming conventions do you follow with functions that allocate memory?

别来无恙 提交于 2019-12-01 23:38:06
So here are two functions that do almost the same thing. How would you name each one, if you had to include both in your project? void strToLower1(char* str) { int len = strlen(str); int i; for (i=0; i<len; i++) str[i] = tolower(str[i]); } char* strToLower2(const char* inputStr) { char* str = strdup(inputStr); strToLower1(str); return str; // must be freed } EDIT: I modified the above example for code-correctness (sheesh) I really like the Taligent Coding Standards , especially the naming conventions . The convention about using special names for copy, create, and adopt routines may apply here

What's the significance of TLD-first domain-like identifiers?

空扰寡人 提交于 2019-12-01 22:22:07
"TLD-first domain-like identifiers" is a mouthful but that's all I can come up with. I've seen these used in various places over the years and wondered what the history/reason behind this convention is, since you might be forgiven in thinking that there is one true way to mention a domain. I don't use Java but I recall from poking around that namespaces are often done like this: uk.co.tophats.stitchkit A specification file for a "Launch Agent" on Mac OS X: ws.agile.1PasswordAgent.plist A preferences file on Mac OS X: com.apple.iTunesHelper.plist Why is the TLD first? Is it just hierarchical

(Conventions) C# Class names

北慕城南 提交于 2019-12-01 20:49:26
问题 I'm not too quite sure about what i should do about a grouped set of classes. My situation: I have 11 classes that relate only to the class Character.cs , but all of those classes (including Character.cs and CharacterManager.cs ) are within the namespace Models.Characters . Which is the more "proper" or preferred way of naming the classes: (examples): CharacterDetails.cs CharacterSprites CharacterAppearance CharacterClientRights CharacterServerRights or: Details.cs Sprites Appearance

What is the correct naming notation for classes, functions, variables etc in c#?

怎甘沉沦 提交于 2019-12-01 19:24:52
I'm a web developer with no formal computing background behind me, I've been writing code now some years now, but every time I need to create a new class / function / variable, I spend about two minutes just deciding on a name and then how to type it. For instance, if I write a function to sum up a bunch of numbers. Should I call it Sum() GetSum() getSum() get_sum() AddNumbersReturnTotal() I know there is a right way to do this, and a link to a good definitive source is all I ask :D Closed as a duplicate of c# Coding standard / Best practices Classes should be in camel notation with the first