naming-conventions

C++ Style Convention: Parameter Names within Class Declaration

非 Y 不嫁゛ 提交于 2019-12-05 09:43:32
I'm a fairly new C++ programmer and I would like to hear the arguments for and against naming parameters within the class declaration. Here's an example: Student.h #ifndef STUDENT_H_ #define STUDENT_H_ #include <string> using namespace std; class Student { private: string name; unsigned int age; float height, GPA; public: Student(string, unsigned int, float, float); void setAge(unsigned int); }; #endif /*STUDENT_H_*/ vs. #ifndef STUDENT_H_ #define STUDENT_H_ #include <string> class Student { private: string name; unsigned int age; float height, GPA; public: Student(string name, unsigned int

C# delegates, reference resolution time

混江龙づ霸主 提交于 2019-12-05 05:38:06
I have a simple question about .net delegates. Say I have something like this: public void Invoke(Action<T> action) { Invoke(() => action(this.Value)); } public void Invoke(Action action) { m_TaskQueue.Enqueue(action); } The first function encloses a reference to this.Value . During runtime, when the first, method with generic parameter gets called, it will provide this.Value somehow to the second one, but how? These came into my mind: Call by value (struct) - the current value of this.Value gets passed, so if the m_TaskQueue executes it 5 minutes later, the value will not be in its recent

C type naming conventions, _t or ALLCAPS

拈花ヽ惹草 提交于 2019-12-05 04:49:56
I've always wondered if there are any naming convetions as when to use ALLCAPS for a type and when to append _t (and when to not use anything?). I know back in the days K&R published all kinds of documents about how to use C, but I couldn't find anything about this. Among the C standard library types, _t seem prettys dominant time_t clock_t uint32_t size_t sig_atomic_t ... , as opposed to FILE , va_list or struct tm . Are there actually rules to this or is it completely arbitrary? Microsoft always uses typenames in ALLCAPS in their Windows API, which at least seems more consistent than the C

Protected properties prefixed with underscores

。_饼干妹妹 提交于 2019-12-05 04:30:36
Like: public $foo = null, $bar = 10; protected $_stuff = null, $_moreStuff = 5; A lot of people seem to do this. Why? Isn't this inconsistent naming (like some PHP functions are :))? It really comes down to one thing: personal preference. I, personally, am also one who uses that naming convention. Prefixing anything that is protected or private with an underscore, be it a variable or a function, lets myself and any other programmer who I regularly work with know that that variable is global and will not be accessible outside of the current class/context. An example that helps clarify the use

When to use one or two underscore in Python [duplicate]

坚强是说给别人听的谎言 提交于 2019-12-05 03:40:33
This question already has answers here : What is the meaning of a single and a double underscore before an object name? (14 answers) Closed 9 months ago . Ok I think I have understood the use of one and two heading underscores in Python. Correct me if I am wrong, In the case of one underscore, the underscore prevents the from X import * statement to import this kind of variables. In the case of two underscores, the variable's name is prepended with the name of the class it belongs to allow a higher level of "privateness". My question now is: why not use two underscores only? In which cases one

Naming convention for groovy script files

China☆狼群 提交于 2019-12-05 02:55:59
Is there any convention regarding groovy script files naming? Should I name the script file in camelcase form, like if it was a regular class (i.e. FooBar.groovy )? Or will it be better to name it using small case letters and underscores (i.e. foo_bar.groovy )? I have seen suggestions that say groovy class files should be the camel case just like Java classes, but for groovy scripts, the recommendation was lower case names, at least the first letter. The idea is that you can very easily get an idea of what file is when looking in a directory list or Windows explorer, just by the case of the

Should I keep bad naming conventions?

僤鯓⒐⒋嵵緔 提交于 2019-12-05 02:27:27
I'm currently working on a site which went through god knows how many developers' hands. One of the things I don't like about it is the way every table in the database has the prefix "tbl_" and every field "fld_". I've started work on a new feature and I'm faced with the following problem: should my new tables continue with the old convention, or not? I guess I should, but I feel stupid doing it :) I would keep the same convention.. Regardless of if it's bad or not at least it would be consistent. And consistency will be very important to the next developer who gets ahold of the code. Being a

Do vs. Run vs. Execute vs. Perform verbs [closed]

橙三吉。 提交于 2019-12-05 02:16:51
What list of verbs are you using for method names? What's your personal or team standard? I debate whether to use Do vs. Run vs. Execute vs. Perform and am wondering if any of these are no longer recommended or some that people just don't really use and I should just scratch them. Basically any one of those verbs mean the same thing...to invoke some process (method call). This is outside of CRUDs. For example: ExecutePayPalWorkflow(); that could be also any one of these names instead: DoPayPalWorkflow(); RunPayPalWorkflow(); PerformPayPalWorkflow(); or does it not really matter...because any

Naming a dictionary structure that stores keys in a predictable order?

孤街浪徒 提交于 2019-12-05 01:43:37
Note: Although my particular context is Objective-C, my question actually transcends programming language choice. Also, I tagged it as "subjective" since someone is bound to complain otherwise, but I personally think it's almost entirely objective. Also, I'm aware of this related SO question , but since this was a bigger issue, I thought it better to make this a separate question. Please don't criticize the question without reading and understanding it fully. Thanks! Most of us are familiar with the dictionary abstract data type that stores key-value associations, whether we call it a map,

C# Float vs. VB.net Single - Namin' complainin'

a 夏天 提交于 2019-12-04 23:56:29
Why is it called a single in VB.net? I'm sure there is a good reason but it doesn't seem intuitive to a non formally trained programmer like me. BPAndrew's question seems to be really "why float in C# and Single in VB.NET", which noone actually answered, so here's my 2p... The use of "float" in C# seems to be a throwback to its C/C++ heritage. "float" still maps to the System.Single type in C#, so the keyword just exists for convenience. You could just as well declare the variable as "Single" in C# the same as you do in VB.NET. (And as stated above, naming them Single/Double actually makes