Variable name: num_threads or nr_threads? - coding-style

It's a question about coding styles. When you define a variable for storing the information of the number of threads (or the number of anything), do you name it "num_threads" or "nr_threads"? Or are there even better names?
Thank you!
Cui

I would prefer to name that variable "numberOfThreads".

Related

Need to input variable number of variables in TI-nspire CX CAS

I want to write a TIBasic program for the nspire CS CAS which will perform simple finite element analysis. In order to do this, I need to be able to input a non-specific number of variables since the number of members in a problem will vary.
Is there a command or trick I can use to program variables k1,k2,k3,...,kn?
Unfortunately, I don't think there's a way to use multiple variables like that. You might be able to use a list and store all your variables there. Lists can only hold up to 999 elements though, so that'll limit what you can do.

What's the abbreviation of these name in v6 sh source code?

sh.c.
Names like TPAR, DSPR. Any guess is also welcomed. Thank you very much!
TPAR is an abbreviation for this token is associated with a parenthesis. Similarly, the other short identifiers are abbreviations for much longer descriptions of their function. You need to derive them from context (or ask the code's author).

Find Variable Declaration in Mathcad

Is there a way to quickly find where a variable was initially defined/declared in Mathcad.
I'm working in a rather large Mathcad (150 pages get printed). I'll see an equation that is using variables declared in earlier sections however I can't use the Edit->Find since the variable uses subscripting. I resort to eye scanning for the variable declaration.
In Eclipse you can control click on a variable and it will take you to the variables declaration. Is there something similar in Mathcad?
Unfortunately, there isn't a 'search for definition' feature. I believe that there have been a number of requests for it over the years ...
Why can't you Edit/Find, though? Which kind of subscripting are you referring to: index or name? Which version of Mathcad are you using?
Search for an array name shouldn't be a problem, as the index won't form part of the name.
If you want a subscripted name and you are using Mathcad 15 (or lower), then simply type the name as you would enter it; eg if your variable is xsub then type x.sub in the find box.

Environment variable for Windows Questions

I'm having a hard time trying to get multiple environment variables configured at the same time. Here are some issues that I would like answered:
If I do have spaces in my PATH environment variable (i.e. C:\Program Files\Java\jdk1.6.0_25), is there any way to keep the same path, but make sure that nothing unexpected happens? I keep hearing that you shouldn't use spaces like in this link here: http://ist.berkeley.edu/as-ag/technology/howto/install-java-sdk-win.html.
Is there a difference in the ordering of the environment variables as listed in the fields?
What will happen if environment variables in the "User variables for user" fields and the "System variable" fields are different? Is it safe to assume that the result will be all the fields combined for that particular variable?
Thanks for any advice!

Best way of getting path to "Application Data" directory?

There are several possible ways of getting the path to the application data directory:
using the %APPDATA% environment variable
calling SHGetFolderPath with CSIDL_APPDATA
What is the best way to get the path from within an program? Are there any gotchas when I use the environment variable?
Which method is safest across XP, Vista and upcoming versions?
I would suggest that calling SHGetFolderPath() is the most appropriate, and portable method; the alternatives, such as reading an environment variable, or (worse) trying to extract it from the registry are likely to trip you up in the future.
Raymond Chen has an article explaining why pulling such paths from the registry is a bad idea.
string appDataPath =
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
You'll need to use the GetFolderPath method get the actual path as Environment.SpecialFolder.ApplicationData is just an enum.
If you're programming in .NET you can use this:
string appDataPath = Environment.SpecialFolder.ApplicationData;
One important difference in Python: in case of unicode file paths ctypes.windll.shell32.SHGetFolderPathW returns a unicode string, whereasos.environ['APPDATA'] returns a byte string.
In case anyone was wondering, in Ruby the command would look like the following:
appDataPath = ENV['APPDATA']

Resources