naming-conventions

Why is the root package in source code called “com”? [duplicate]

南楼画角 提交于 2019-12-03 05:50:20
This question already has an answer here: Java packages com and org 4 answers In most source codes, the root package/folder is named "com". Why is that so? It it just convention or does it stand for something? The convention is that a programmer in a given organization will start package names with their organization's domain name, as a unique identifier -- in reverse order. This prevents namespace clashes between code from different organizations (within the organization you're on your own). So if I work for a company called Supercompany, and their domain is supercompany.com, all of my

What is the preferred naming convention for Func<TResult> method parameters?

有些话、适合烂在心里 提交于 2019-12-03 05:47:52
I admit that this question is subjective but I am interested in the view of the community. I have a cache class that takes a cache loader function of type Func<TResult> , which it uses to retrieve a value from the database and store it in cache. public static class Cache { public TResult Get<TResult>(string cacheKey, Func<TResult> cacheLoader) { // Implementation } } My question is: How should I name the function parameter? Should I name it like an object, e.g. cacheLoader ? Should I name it like a method, e.g. loadResult ? Should I explicitly refer to it as a function, e.g. cacheLoadFunction

Why prefix C# interface names with an “I”

♀尐吖头ヾ 提交于 2019-12-03 05:40:19
问题 What is the rationale behind this naming convention? I don't see any benefit. The extra prefix just pollutes the API. My thinking is inline with Konrad's response to this related question; the chosen answer of which is mostly what I am asking for here. 回答1: Its the complete opposite, the naming convention clearly identifies an interface. For example if you have: public class Dog : IPet, IMammal { .... Just from reading it, I can safely assume that IPet and IMammal are probably interfaces. The

What does it mean when `Ex` is added to a function/method name?

江枫思渺然 提交于 2019-12-03 05:32:50
I don't work with the Windows API much, but I've seen it used there as well as occasionally in a codebase here at work. Yup, they wanted to improve (Extend) the API and keep a similar name so it was likely that the programmer would move to the new version. Notable is GetVersionEx() to get the Windows version, pretty painful for a while with a nasty chicken-and-egg problem. The record keeper is the National Language Support team who have several ExEx versions, like EnumCalendarInfoExEx. Unsurprising, culture moves even faster than software. No ExExEx as of yet. It's usually done as a way of

Database name convention: DATETIME column

最后都变了- 提交于 2019-12-03 05:31:55
问题 What is your naming convention for DATETIME columns (in my case, using MS SQL Server) For a column that stores when the row was created CreatedDatetime makes sense, or LastModifiedDatetime . But for a simple table, let's say one called Event, would you create columns called: EventID, // Primary key EventDatetime, // When the event is happening EventEnabled // Is the event is on or ID, // Primary key Datetime, // When the event is happening Enabled // Is the event is on If you'd use neither

What 1-2 letter object names conflict with existing R objects?

两盒软妹~` 提交于 2019-12-03 05:26:52
To make my code more readable, I like to avoid names of objects that already exist when creating new objects. Because of the package-based nature of R, and because functions are first-class objects, it can be easy to overwrite common functions that are not in base R (since a common package might use a short function name but without knowing what package to load there is no way to check for it). Objects such as the built-in logicals T and F also cause trouble. Some examples that come to mind are: One letter c t T/F J Two letters df A better solution might be to avoid using short names

MySQL naming conventions, should field name include the table name?

核能气质少年 提交于 2019-12-03 05:12:34
A friend told me that I should include the table name in the field name of the same table, and I'm wondering why? And should it be like this? Example: (Table) Users (Fields) user_id, username, password, last_login_time I see that the prefix 'user_' is meaningless since I know it's already for a user. But I'd like to hear from you too. note: I'm programming in php, mysql. I agree with you. The only place I am tempted to put the table name or a shortened form of it is on primary and foreign keys or if the "natural" name is a keyword. Users: id or user_id, username, password, last_login_time Post

Visibility Autobinding with naming convention

爱⌒轻易说出口 提交于 2019-12-03 05:09:57
I really like Caliburn and the naming convention binding and was surprised that the Visibility is not bound in the same way the "CanNAME" Convention is used to guard an Action. As far as I know is the BooleanToVisibilityConverter only used when Binding is explicitly used in Caliburn and not automatically like the guard method. So I was thinking to modify the source to bind automatically to "bool? ControlNameIsVisible()" (null equals collapse) or similar. I was wondering if that is the right approach and if soo if somebody has done the implementation already and could share it here. You could

Independent getter/setter methods, or combined?

本小妞迷上赌 提交于 2019-12-03 05:00:26
While working on a project, I've been making some changes and browsing around existing framework API docs for insight. While perusing the Kohana docs, I noticed that the getters/setters of any given class are typically combined: public function someProperty($value = null){ if(is_null($value){ return $this->_someProperty; } $this->_someProperty = $value; return $this; } Rather than: public function setSomeProperty($value){ $this->_someProperty = $value; return $this; } public function getSomeProperty(){ return $this->_someProperty; } Is there any value in doing this ( the former ), beyond

Naming of enums in Java: Singular or Plural?

我怕爱的太早我们不能终老 提交于 2019-12-03 04:50:24
问题 Is there an "official" recommendation of how to name Java enums? enum Protocol { HTTP, HTTPS, FTP } or enum Protocols { HTTP, HTTPS, FTP } I know in the .Net world the recommendation is to use singular except for enums that represent bit flags. Just curious if there is something similar in Java. A related question that seems to be .Net specific: Singular or plural for enumerations? 回答1: Enums in Java (and probably enums in general) should be singular. The thinking is that you're not selecting