naming

Is there a .NET function to validate a class name?

佐手、 提交于 2019-11-30 17:06:41
I am using CodeDom to generate dynamic code based on user values. One of those values controls what the name of the class I'm generating is. I know I could sterilize the name based on language rules about valid class names using regular expressions, but I'd like to know if there is a specific method built into the framework to validate and/or sterilize a class name. An easy way to determine if a string is a valid identifier for a class or variable is to call the static method System.CodeDom.Compiler.CodeGenerator.IsValidLanguageIndependentIdentifier(string value) Jason Diller Use the

Parameter naming: filename or fileName?

故事扮演 提交于 2019-11-30 13:06:16
问题 I try to be grammatically correct in my naming*. I've always used filename instead of fileName . The java convention also seems to use this, but FxCop prefers fileName . There's a discussion on WikiPedia about it. The more I read, the more I feel I'm right (which is quite usual! :) ). Does anyone have a definitive answer or is this merely something subjective? * I just hope there are no grammar errors in this post! 回答1: It is acceptable English to write "filename" or "file name". When you

giving a class instance the name of a variable

依然范特西╮ 提交于 2019-11-30 09:54:12
问题 How can i give a class instance the name of an existing variable. I am trying like this string hex = "BF43F"; Zeugh hex = new Zeugh(); but its wrong. I want to create an object BF43F with the properties of Zeugh class. 回答1: Sounds like you want a Dictionary<string, Zeugh> . For example: var d = new Dictionary<string, Zeugh>(); string hex = "BF43F"; d.Add(hex, new Zeugh()); (later) Zeugh it = d["BF43F"]; 回答2: You can't declare two variables with the same name in the same scope. If you later

What is SUT and where did it come from?

醉酒当歌 提交于 2019-11-30 07:44:58
问题 I see many people talking about the term SUT, but do not understand why they use that term. SUT is what you want to test? Where does this term come from and what does it mean? For example in this test, what is my SUT? [TestMethod] public void UsersAction_should_return_IndexAction() { const long id = 1; UsersViewModel viewModel = new UsersViewModel() { SelectedUsers = new long[] { 1, 2, 3, 4 } }; ActionResult result = _controller.Users(id, viewModel); result.AssertActionRedirect().ToAction(

function naming conflicts

非 Y 不嫁゛ 提交于 2019-11-30 04:56:31
问题 What are some good patterns for development with packages that define the same function? In my case, lubridate and data.table both define wday . 回答1: You can use :: , it helps to specify which package to use: lubridate::wday function (x, label = FALSE, abbr = TRUE) UseMethod("wday") <environment: namespace:lubridate> data.table::wday function (x) as.POSIXlt(x)$wday + 1L <environment: namespace:data.table> 回答2: Use the namespace mechanism for your packages. See the R Extensions manual. 来源:

Why are underscores better than hyphens for file names?

我怕爱的太早我们不能终老 提交于 2019-11-30 04:11:16
From Building Skills in Python : "A file name like exercise_1.py is better than the name execise-1.py. We can run both programs equally well from the command line, but the name with the hyphen limits our ability to write larger and more sophisticated programs." Why? Daniel G The issue here is that importing files with the hyphen-minus (the default keyboard key - ; U+002D ) in their name doesn't work since it represents minus signs in Python. So, if you had your own module you wanted to import, it shouldn't have a hyphen in its name: >>> import test-1 File "<stdin>", line 1 import test-1 ^

Is there a .NET function to validate a class name?

柔情痞子 提交于 2019-11-30 00:26:31
问题 I am using CodeDom to generate dynamic code based on user values. One of those values controls what the name of the class I'm generating is. I know I could sterilize the name based on language rules about valid class names using regular expressions, but I'd like to know if there is a specific method built into the framework to validate and/or sterilize a class name. 回答1: An easy way to determine if a string is a valid identifier for a class or variable is to call the static method System

C naming suggestion for Error Code enums

本小妞迷上赌 提交于 2019-11-29 23:21:41
I'm writing a simple parser to read the config file.The config.h interface have only three main functions they are in brief as follows, config_init(); config_dinit(); config_parse(); config_read_value(); My question is those functions will emit different type of errors , for a example, config_init() emit , FILE_NOT_FOUND,FILE_EOF_ERROR,FILE_OPEN_ERROR, ... config_dinit() emit , NOT_INIT_ERROR , config_parse() emit , PARSE_ERROR, OVERFLOW_ERROR, INVALID_CHARACTER_FOUND_ERROR,... config_read_value() emit, SECTION_NOT_FOUND,KEYWORD_NOT_FOUND,OVERFLOW_ERROR,NOT_INITIALIZED_ERROR,INVALID_STATE

Naming rules for Android resources

天大地大妈咪最大 提交于 2019-11-29 20:50:08
问题 where can I find the naming rules for Android resources? I found out thanks to compilation errors that I must use characters within [a-z0-9._], but I also have an error with an image named 401.png. When using it in my layout using @drawable/401 I get the following compilation error: invalid VariableDeclaratorId I can't find these rules in the doc, and I'd like to know all of them before naming my files. Thanks 回答1: The rules are the same as for Java identifiers since each resource must have a

giving a class instance the name of a variable

走远了吗. 提交于 2019-11-29 18:14:54
How can i give a class instance the name of an existing variable. I am trying like this string hex = "BF43F"; Zeugh hex = new Zeugh(); but its wrong. I want to create an object BF43F with the properties of Zeugh class. Sounds like you want a Dictionary<string, Zeugh> . For example: var d = new Dictionary<string, Zeugh>(); string hex = "BF43F"; d.Add(hex, new Zeugh()); (later) Zeugh it = d["BF43F"]; You can't declare two variables with the same name in the same scope. If you later access the variable hex , how should the compiler know if you mean the "BF43F" string or the Zeugh object? Or do