naming-conventions

What are the naming guidelines for ASP.NET controls?

我们两清 提交于 2019-12-17 17:34:31
问题 We are in the process of nutting out the design guidelines we would like to use in our development team and got into a discussion today around how ASP.NET controls should be named. I am talking about our good friends Label, TextBox, Button etc. We came up with the following three possibilities that we voted on: (Example is a TextBox to enter/display a FirstName) Add the control type as a postfix to your controls ID: [FirstName _ TextBox] or [FirstName _ tbx] Add the control type as a prefix

When is “Try” supposed to be used in C# method names?

夙愿已清 提交于 2019-12-17 17:25:26
问题 We were discussing with our coworkers on what it means if the method name starts with "Try". There were the following opinions: Use "Try" when the method can return a null value. Use "Try" when the method will not throw an exception. What is the official definition? What does "Try" say in the method name? Is there some official guideline about this? 回答1: This is known as the TryParse pattern and has been documented by Microsoft. The official Exceptions and Performance MSDN page says: Consider

MATLAB: How can I use a variables value in another variables name?

独自空忆成欢 提交于 2019-12-17 16:53:11
问题 I am wondering if this is possible. My code looks like this: indexStop = find(firstinSeq(x,4) ~= ... littledataPassed(y:length(littledataPassed),4), 1, 'first'); for z= 0:(n-1) indexProcess = find((littledataPassed(y:y+indexStop-1,6) == 1 & ... littledataPassed(y:y+indexStop-1,2) == firstinSeq(x,2) & ... littledataPassed(y:y+indexStop-1,5) == z), 1, 'first'); if isempty(indexProcess) msgLength[n](countmsgLength[n],:)= [firstinSeq(x,:) [0 0 0 0 0 0]]; else msgLength[n](countmsgLength[n],:)=

Javascript and CSS, using dashes

流过昼夜 提交于 2019-12-17 15:58:08
问题 I'm starting to learn some javascript and understand that dashes are not permitted when naming identifiers. However, in CSS it's common to use a dash for IDs and classes. Does using a dash in CSS interfere with javascript interaction somehow? For instance if I were to use getElementByID("css-dash-name"). I've tried a few examples using getElementByID with dashes as a name for a div ID and it worked, but I'm not sure if that's the case in all other context. 回答1: Having dashes and underscores

Objective C - Why do constants start with k

我的梦境 提交于 2019-12-17 15:43:14
问题 Why do constants in all examples I've seen always start with k? And should I #define constants in header or .m file? I'm new to Objective C, and I don't know C. Is there some tutorial somewhere that explains these sorts of things without assuming knowledge of C? 回答1: Starting constants with a "k" is a legacy of the pre-Mac OS X days. In fact, I think the practice might even come from way back in the day, when the Mac OS was written mostly in Pascal, and the predominant development language

Valid JavaBeans names for boolean getter methods

[亡魂溺海] 提交于 2019-12-17 15:32:17
问题 I know most variable names will work with "is", such as isBlue() , but is "has" also a valid prefix, like hasProperty() ? 回答1: According to the JavaBeans specification section 8.3.2: Boolean properties In addition, for boolean properties, we allow a getter method to match the pattern: public boolean is<PropertyName>(); This " isPropertyName " method may be provided instead of a " get<PropertyName> " method, or it may be provided in addition to a " get<PropertyName> " method. In either case,

Should I include stddef.h or cstddef for size_t

风格不统一 提交于 2019-12-17 10:58:55
问题 When I want to use size_t in C++, should I include <stddef.h> or <cstddef> ? I have heard several people saying that <cstddef> was a bad idea, and it should be deprecated. Why is that? 回答1: I prefer #include <stddef.h> . Some of the names in the C headers are allowed to be macros, but the set differs from the C rules. In C, EXIT_FAILURE , isdigit() , getc() a.o. are macros. Do you know which ones are macros in C++? Secondly, only a couple standard C headers are required to have the <cfoo>

How do I Parameterize a null string with DBNull.Value clearly and quickly

江枫思渺然 提交于 2019-12-17 10:47:29
问题 I got tired of writing the following code: /* Commenting out irrelevant parts public string MiddleName; public void Save(){ SqlCommand = new SqlCommand(); // blah blah...boring INSERT statement with params etc go here. */ if(MiddleName==null){ myCmd.Parameters.Add("@MiddleName", DBNull.Value); } else{ myCmd.Parameters.Add("@MiddleName", MiddleName); } /* // more boring code to save to DB. }*/ So, I wrote this: public static object DBNullValueorStringIfNotNull(string value) { object o; if

Naming conventions for java methods that return boolean(No question mark)

余生长醉 提交于 2019-12-17 10:33:19
问题 I like using question mark at the end of method/function names in other languages. Java doesn't let me do this. As a workaround how else can I name boolean returning methods in Java? Using an is , has , should , can in the front of a method sound okay for some cases. Is there a better way to name such methods? For e.g. createFreshSnapshot? 回答1: The convention is to ask a question in the name. Here are a few examples that can be found in the JDK: isEmpty() hasChildren() That way, the names are

What is a good naming convention for vars, methods, etc in C++? [closed]

只愿长相守 提交于 2019-12-17 10:14:09
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I come from a the Objective-C and Cocoa world where there are lots of conventions and many people will say it makes your code