conventions

Javabean convention - method naming for property gId

五迷三道 提交于 2019-11-28 05:34:05
问题 If I have a property 'gId' in my Java class what should the accessor method be named as? getGId is what I assume. If there were a property gURL I think it would be getGURL , which kind of looks ugly (not referring to the alternative spelling of girl though). If the property was just url the method name getUrl is good on the eye and yeah I would not name the property as URL in the first place which would make the accessor ugly again - getURL I remember reading from the Javabean Specification

What's the convention for java package names without a domain association?

无人久伴 提交于 2019-11-28 04:30:13
I can't find a Q/A on SO that answers my exact question, so I figure I'd post it and see what comes back. As far as the naming convention goes for Java packages, I understand that it's supposed to be the reverse domain name: com.whatever.stuff and I get the rules about no mixed case, hyphens, keywords, etc. I've also read section 7.7 (Unique-Package-Names) of the Java Language Specification. As far as I can tell, the rules from Java are to use the reverse domain to insure uniqueness... and if you don't have one, go get one: You form a unique package name by first having (or belonging to an

What is the advantage of the 'src/main/java'' convention?

こ雲淡風輕ζ 提交于 2019-11-28 04:18:41
I've noticed that a lot of projects have the following structure: Project-A bin lib src main java RootLevelPackageClass.java I currently use the following convention (as my projects are 100% java): Project-A bin lib src RootLevelPackageClass.java I'm not currently using Maven but am wondering if this is a Maven convention or not or if there is another reason. Can someone explain why the first version is so popular these days and if I should adopt this new convention or not? Chris Boris Pavlović Main benefit is in having the test directory as subdirectory of src with the same directory

When to use ellipsis after menu items

假装没事ソ 提交于 2019-11-28 03:54:21
In pretty much all applications that have a menu bar, some of the items have an ellipsis (...) after them, and some don't. Is there a well known convention on when to put that ellipsis there and when not to? When do you do it? Do you do it? I have looked at various windows applications, and this is what I have come to: Ellipsis Menu items which opens a form that require user input to do something (Replace, Go to, Font) No ellipsis Menu items which just does something (Cut, Paste, Exit, Save) Menu items which opens a form that does not require user input (About, Check for Updates) But then

Lisp commenting convention

梦想的初衷 提交于 2019-11-28 03:46:12
What is the Lisp convention about how many semicolons to use for different kinds of comments (and what the level of indentation for various numbers of semicolons should be)? Also, is there any convention about when to use semicolon comments and when to use #|multiline comments|# (assuming they exist and exist on multiple implementations)? In Common Lisp: ;;;; At the top of source files ;;; Comments at the beginning of the line (defun test (a &optional b) ;; Commends indented along with code (do-something a) ; Comments indented at column 40, or the last (do-something-else b)) ; column + 1 space

What is the benefit of nesting functions (in general/in Swift)

二次信任 提交于 2019-11-27 22:33:31
I'm just learning some Swift and I've come across the section that talks about nesting functions: Functions can be nested. Nested functions have access to variables that were declared in the outer function. You can use nested functions to organize the code in a function that is long or complex. From here So if the purported benefit is to "organize the code", why not just have the nested function independently, outside of the outer function? That, to me, seems more organized. The only benefit I can discern is that you "have access to variables that were declared in the outer function", but this

Code line wrapping - how to handle long lines

十年热恋 提交于 2019-11-27 19:39:21
I'm facing a particular line that is 153 characters long. Now, I tend to break things after 120 characters (of course, this is heavily dependent on where I am and the local conventions.) But to be honest, everywhere I break the line just makes it look bad. So I'm looking for some ideas on what I should do for it. Here's the line: private static final Map<Class<? extends Persistent>, PersistentHelper> class2helper = new HashMap<Class<? extends Persistent>, PersistentHelper>(); I'm open to both ideas about how/where to break the line (and why), as well as ways to shorten the line itself. We're

Function commenting conventions in R

让人想犯罪 __ 提交于 2019-11-27 13:54:09
问题 I'm fairly new to R, and I have been defining some of my own functions in script files. I'm intending for others to re-use them later, and I can't find any guides on R function commenting conventions. Is there any way for me to make help("my_function_name") show some help? If not, do I just document the function in the script file, so that someone has to print out (or open the source of) a script to see the comments? Thanks, Hamy 回答1: The canonical way to document your functions and make them

Java: Infinite Loop Convention [closed]

a 夏天 提交于 2019-11-27 13:52:46
What is the convention for an infinite loop in Java? Should I write while(true) or for(;;) ? I personally would use while(true) because I use while loops less often. There is no difference in bytecode between while(true) and for(;;) but I prefer while(true) since it is less confusing (especially for someone new to Java). You can check it with this code example void test1(){ for (;;){ System.out.println("hello"); } } void test2(){ while(true){ System.out.println("world"); } } When you use command javap -c ClassWithThoseMethods you will get void test1(); Code: 0: getstatic #15 // Field java/lang

Best practices for writing a programming language parser

不问归期 提交于 2019-11-27 13:34:14
问题 Are there any best practices that I should follow while writing a parser? 回答1: The received wisdom is to use parser generators + grammars and it seems like good advice, because you are using a rigorous tool and presumably reducing effort and potential for bugs in doing so. To use a parser generator the grammar has to be context free. If you are designing the languauge to be parsed then you can control this. If you are not sure then it could cost you a lot of effort if you start down the