naming-conventions

Ruby variable name with double underscores

久未见 提交于 2019-11-30 13:46:54
Sometimes I see variable names with double underscore in the beginning and the end. For example: Article.__elasticsearch__ Is there some naming convention related to double underscores in Ruby variable names? An initial underscore or double underscore basically indicates "special/avoid overwrite" --meaning it's meant to reduce the likelihood that someone else might define a method/attribute of the same name. The most common occurrence is __send__ . From Ruby Forum The author of the ElasticSearch gem made the wrong call IMO. At the end of the thread, Avdi Grimm, who is well-known in the Ruby

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

Sun's Java Package Naming Convention: sun vs. com.sun

一世执手 提交于 2019-11-30 13:02:32
In JRE, Sun's internal packages are prefixed with 2 top-level domains (sun and com). For example, com.sun.security.jgss sun.security.jgss It seems pretty random to me which prefix they choose. I am curious what rules Sun uses for this. The "com.sun" convention is the more preferable format because it follows the "naming conventions" that have been established for naming Java packages. http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html You're supposed to use your unique company or personal website URL as the first few words in the package to guarantee uniqueness in the namespace.

How is the `*var-name*` naming-convention used in clojure?

倖福魔咒の 提交于 2019-11-30 12:59:47
问题 As a non-lisper coming to clojure how should I best understand the naming convention where vars get a name like *var-name* ? This appears to be a lisp convention indicating a global variable. But in clojure such vars appear in namespaces as far as I can tell. I would really appreciate a brief explanation of what I should expect when an author has used such vars in their code, ideally with a example of how and why such a var would be used and changed in a clojure library. 回答1: It's a

Best practice for CSS class naming for use with jQuery selectors

风格不统一 提交于 2019-11-30 12:49:22
问题 While building a Javascript-heavy web application, what is the best practice for naming CSS classes to keep the Javascript code and CSS stylesheets clean and the UI structure flexible? Option 1: Name every single element uniquely . For example, // HTML <div id="list"> <button class="list-delete" /> <div class="list-items"> <div class="item"> <button class="item-delete" /> <h1 class="item-name">Item 1</h1> </div> </div> </div> // CSS .list-delete { color: black; } .item-delete { color: blue; }

Association between naming classes and naming their files in python (convention?)

寵の児 提交于 2019-11-30 12:25:00
问题 In python (and some other languages) I have learned, that the name of a class should be written in small letters except for the first letter, which should be a capital letter. Example: class FooBar: ... A class should go in a file, named the same as the class. In this example it would be a file foobar.py . If I want to import the class foo somewhere I have to do this: from foobar import FooBar This convention confuses me a little. My intuition tells me, that if the filename indicates a class,

Convention over configuration in ASP.NET MVC

空扰寡人 提交于 2019-11-30 11:48:04
I am relatively new to ASP.NET MVC, and am very impressed with the clarity of the platform so far. However, there is one aspect that I find uncomfortable. At first, I accepted the fact that when I say return View(); I am calling a helper method that returns an ActionResult, and makes some assumptions about which view to present, route values, etc. But lately I have been writing code that looks more like this: return View("Index", new { id = myID }) because it is immediately clear to me what's happening by reading that single line of code. Lately I have been struggling with the fact that I can

What is correct Java naming convention for id?

北战南征 提交于 2019-11-30 11:17:34
If I have user id variable, what is correct java naming convention for it? userId or userID I think I read somewhere that the best guideline is to always capitalize only the first letter of an acronym (i.e., if you have a user TTL where TTL is some random acronym in your project, then it's best to write userTtl). This makes sense, since it solves some problems. For example, say you want a user id counter. Readability of userIDCounter is worse than userIdCounter. For a longer acronym, it gets even worse. This is a tough decision, even Sun isn't so sure what to do. Look at classes in JRE, java

Why is System.arraycopy not camelCased?

我们两清 提交于 2019-11-30 11:12:20
Java's standard libraries seem to use camelCase for method names. Native functions like nanoTime() are no exceptions. If so, why is System.arraycopy not camelCased? Is there something special about System.arraycopy ? It's been in Java for before v1.0 was released - so my guess is that it predates the naming conventions, and it was missed in a sweep of the API when the naming conventions were decided. (In other news, NullPointerException should be called NullReferenceException .) 来源: https://stackoverflow.com/questions/8421103/why-is-system-arraycopy-not-camelcased

CA1500 vs. SA1309 - Which one wins?

本小妞迷上赌 提交于 2019-11-30 11:08:24
I'll prefix by saying that I understand that both Code Analysis and StyleCop are meant as guidelines, and many people chose to ignore these anyway. But having said that, I'd like to see what the general consensus is with regard to these two rules. Rule CA1500 says don't make parameter names and private field names the same. Rule SA1309 , on the other hand, says don't prefix members with underscore or "m_". This leaves us with little options for distinguishing private backing fields from their corresponding parameters. Take these examples. SA1309 complains: class SomeClass { int _someField;