naming

What kind of prefix do you use for member variables?

走远了吗. 提交于 2019-11-27 07:05:32
No doubt, it's essential for understanding code to give member variables a prefix so that they can easily be distinguished from "normal" variables. But what kind of prefix do you use? I have been working on projects where we used m_ as prefix, on other projects we used an underscore only (which I personally don't like, because an underscore only is not demonstrative enough). On another project we used a long prefix form, that also included the variable type. mul_ for example is the prefix of a m ember variable of type u nsigned l ong. Now let me know what kind of prefix you use (and please

Does the use of the “Async” suffix in a method name depend on whether the 'async' modifier is used?

心不动则不痛 提交于 2019-11-27 06:51:25
What is the convention for suffixing method names with "Async"? Should the "Async" suffix be appended only to a method that is declared with the async modifier? public async Task<bool> ConnectAsync() Or is it enough that the method just returns Task<T> or Task ? public Task<bool> ConnectAsync() I think the truth is ambiguous even from Microsoft documentation: In Visual Studio 2012 and the .NET Framework 4.5, any method that is attributed with the async keyword ( Async in Visual Basic) is considered an asynchronous method, and the C# and Visual Basic compilers perform the necessary

Is the XML declaration node mandatory?

自作多情 提交于 2019-11-27 06:37:01
问题 I had a discussion with a colleague of mine about the XML declaration node (I'm talking about this => <?xml version="1.0" encoding="UTF-8"?> ). I believe that for something to be called "valid XML", it requires a XML declaration node. My colleague states that the XML declaration node is optionnal, since the default encoding is UTF-8 and the version is always 1.0 . This make sense, but what does the standard says ? In short, given the following file: <books> <book id="1"><title>Title</title><

When setting environment variables in Apache RewriteRule directives, what causes the variable name to be prefixed with “REDIRECT_”?

半城伤御伤魂 提交于 2019-11-27 06:17:50
I am trying to set Apache environment variables (for use in PHP) with the [E=VAR:VAL] flag on RewriteRule rules in an .htaccess file. I have already discovered the variables are accessed in PHP as server variables $_SERVER rather than $_ENV (which makes a certain amount of sense). However, my problem is for some rules the [E=VAR:VAL] flag works as expected and I end up with a variable $_SERVER['VAR'] but for other rules I end with a variable $_SERVER['REDIRECT_VAR'] or $_SERVER['REDIRECT_REDIRECT_VAR'] , etc A. What causes an environment variable set in Apache using the [E=VAR:VAL] flag to get

Which characters are illegal within a branch name?

那年仲夏 提交于 2019-11-27 06:06:55
Which characters are illegal within a branch name? Manoj Govindan Naming rules for refname: Git imposes the following rules on how references are named: They can include slash / for hierarchical (directory) grouping, but no slash-separated component can begin with a dot . or end with the sequence .lock . They must contain at least one / . This enforces the presence of a category like heads/ , tags/ etc. but the actual names are not restricted. If the --allow-onelevel option is used, this rule is waived. They cannot have two consecutive dots .. anywhere. They cannot have ASCII control

What's the best approach to naming classes? [closed]

≡放荡痞女 提交于 2019-11-27 02:35:27
Coming up with good, precise names for classes is notoriously difficult. Done right, it makes code more self-documenting and provides a vocabulary for reasoning about code at a higher level of abstraction. Classes which implement a particular design pattern might be given a name based on the well known pattern name (e.g. FooFactory, FooFacade), and classes which directly model domain concepts can take their names from the problem domain, but what about other classes? Is there anything like a programmer's thesaurus that I can turn to when I'm lacking inspiration, and want to avoid using generic

Why are x86 registers named the way they are?

青春壹個敷衍的年華 提交于 2019-11-27 02:34:07
问题 For example, the accumulator is named EAX and, while the instruction pointer is called IP . I also know that there are bytes called CL and DH . I know there must be a convention to all of the names, but what is it? 回答1: The C and the D are numbers/types and H for high and L for low parts of the higher register. http://en.wikipedia.org/wiki/X86 Wikipedia explains it very well. More from the Wikipedia: AX/EAX/RAX: accumulator BX/EBX/RBX: base CX/ECX/RCX: counter DX/EDX/RDX: data/general 回答2:

Max name length of variable or method in Java

北战南征 提交于 2019-11-26 23:06:08
问题 Is there a max length for class/method/variable names in Java? the JLS doesn't seem to mention that. I know very long names are problematic anyway from code readability and maintainability perspective, but just out of curiosity is there a limitation (I guess class names might be limited by the file system maximal file name limitation). 回答1: If I'm not mistaken, the limit is not in the language itself but in the classfile format, which limits names to 64k, so for all practical intents and

What is the purpose of constraint naming

…衆ロ難τιáo~ 提交于 2019-11-26 22:06:43
What is the purpose of naming your constraints (unique, primary key, foreign key)? Say I have a table which is using natural keys as a primary key: CREATE TABLE Order ( LoginName VARCHAR(50) NOT NULL, ProductName VARCHAR(50) NOT NULL, NumberOrdered INT NOT NULL, OrderDateTime DATETIME NOT NULL, PRIMARY KEY(LoginName, OrderDateTime) ); What benefits (if any) does naming my PK bring? Eg. Replace: PRIMARY KEY(LoginName, OrderDateTime) With: CONSTRAINT Order_PK PRIMARY KEY(LoginName, OrderDateTime) Sorry if my data model is not the best, I'm new to this! Here's some pretty basic reasons. (1) If a

Swift's standard library and name collision

烂漫一生 提交于 2019-11-26 21:47:26
问题 I know that Swift doesn't use namespaces, but that names are defined within each module. First of all, I don't understand very well how this avoids name collisions -feel free to elaborate. Nevertheless, my main question is: Let's say I want a tree structure without using NSTreeNode, so I make my own class named "TreeNode". Now let's say that Apple decides to include a class to build trees in Swift's standard library, and, as expected, they name it "TreeNode". What happens then? My custom