What is the common best practice for query parameter naming convention. Camel case/ snake case/ pascal case/ kebab case? How should it look like in the URL ?
Related
I see that there's a pattern to how some things are named:
AActor
UObject
UPrimitiveComponent
...and I see that the pattern is defined here, but is there anything I should infer beyond the inheritance chain ? Is this the Unreal take on Hungarian Notation ? Or are the prefixes just for ease of identifying objects.
I just dived into the world of using dispatch_queue a little bit more intensively and was wondering if there are some naming conventions that should be used just for GCD objects, so that the code of the classes is then more easily divided into GCD and other Code.
Or could it be that it is a bad idea to have separate naming conventions for GCD?
I'd suggest to simply stick to the usual Cocoa and CoreFoundation naming conventions. Extend them as needed.
Edit after comments:
First of all, you shouldn't start variables with an underscore as this is reserved for Apple. Instead, I recommend to postfix with underscore, like someVariable_ or prefix with something else (for example, a colleague of mine uses i_ for instance variables and g_ for globals).
Whether you want to add some kind of polish notation (like prefixing with q_ for queues) is entirely up to you, it's a matter of taste. I think it's more important that you can recognize what a variable is used for, like imageProcessingQueue_ instead of just queue_.
The problem is that this is entirely subjective and cannot be answered in an "this is the ultimate truth" way. Common sense and forethought are important and laziness (abbreviated names or very generic terms like simply queue_) should be avoided.
If I am naming a new class in an OOP language, which is a better convention:
XMLWriter
Most common
XMLwriter
Easier to distinguish
XmlWriter
No longer an acronym
XML_Writer
Removes the point of camel case
Pedantic yes, but I'm curious who uses what and why.
Java conventions seem lately to favor treating well-known acronyms like words, so: "XmlWriter"...
http://www.ibm.com/developerworks/library/ws-tip-namingconv.html
Java Naming Convention with Acronyms <-dupe question?
http://geosoft.no/development/javastyle.html
But nobody seems to be very consistent. Take JavaScript's XMLHttpRequest for example. What a trainwreck!
I'm pretty sure all the different naming convention people will want to string me up for saying this. But in my opinion the naming convention you should use should be the one that is easiest to read. Names are only used by humans, so therefore they should be whatever is easiest to read/understand. So for things like XMLWriter, I would probably put it as XmlWriter since that seems a little easier to read. For things that are very very common (i.e. XML) I think treating it as a word works best. If you have some acronym that is specific to your domain, then I might capitalize it so that people who don't use it all the time would understand that it's an acronym. Basically make it easier to understand the names real intention even if it makes it slightly harder to read. I think using common sense and best judgment is better than trying to stick to a absolute set of rules in naming. Although the naming should try it's best to follow a reasonable set of naming conventions.
I would say you should always prefer the most readable one (as zipper said) and atleast start the class name with capital letter as somewhere i read that its a Java standard convention and I also feel that starting with a capital letter always makes you sure that its a Java class.
I am wondering what is actually the preferred way of naming variables: some_variable or somevariable.
Looking at some libraries, I have seen both. What is more, some wide-spread style conventions like Google C++ Style Guide allow both.
What do you prefer and why? Is there a rule or good practice which tells when to use which? And does the same applies to argument names in functions/methods?
And is mixing those two conventions a good idea? If yes, when should the first naming conventions be used, and when the second one?
Use what's most readable and least confusing.
You should follow whatever naming convention makes sense to you.
For me, I always use camelCase for variables and PascalCase for public methods and properties.
The C++ standard libraries use both conventions for function and class names, though the _ convention is apparently gaining popularity (it's used in most recent additions, since the STL got standardized). Stick with your project guidelines, or make up your own, but apply them consistently.
My personal style is to use some_function for functions, somevar for variables, PascalCase for class names. I don't have a copy of The C++ Programming Language by Stroustrup around, but I believe this is his style as well.
This question already has answers here:
Closed 12 years ago.
Possible Duplicates:
Anyone else find naming classes and methods one of the most difficult part in programming?
What’s the best approach to naming classes?
Finding appropriate abstraction names can sometime be time-consuming, especially if your mother tongue is not english. I was wondering if there exists somewhere some sort of online glossary/dictionary describing program-related concepts. We all know about Design Patterns from GoF but I'm looking for a much more complete lexicon, including relationships between concepts.
Thanks
You know that there are conventions for naming artifacts in a program?
For example, Java has come up with a pretty strong and reliable way of naming classes, methods and attributes.
Wikipedia has this to say about naming convention (not too helpful, but still interesting) http://en.wikipedia.org/wiki/Naming_convention_(programming)
Here is a page from Central Washington University (with Java, but still helpful for other programming languages) : http://www.cwu.edu/~gellenbe/javastyle/naming.html
Other article here : http://drupal.star.bnl.gov/STAR/comp/sofi/soft-n-libs/standards/NamingAdvice
But basically, naming a method usually start with a action, then a noun, etc.
For example:
$obj.addObservers(...); // action, noun
$obj.setPrice(); // action, noun
$obj.getModelFromDb(); // action, noun, preposition, noun
$obj.setActive(...); // action, noun
$obj.isActive(); // yes (true) or no (false) statement
$obj.canEdit(); // yes (true) or no (false) statement
$obj.setCanEdit(); // action, attribute
// etc.
Avoid using negative method naming, ex: $obj.cannotConnect(); which will simply confuse everyone. (This is also true when prompting, ex: "You are about to delete this file, do you want to abort?" ... choosing 'no' thinking you are going to delete a file and it was a mistake will do the opposite...)
Back to method naming;
your method names should be as short as possible, but avoid using acronyms, unless the method name is too long (this is a judgement call here);
methods should be self explanatory and self documented;
avoid using prefixes, unless you are working with non-OOP languages (pretty rare these days). Your prefix should be your class, or namespace, etc.
each method should have only one function (one purpose) if you method does more than one thing, consider splitting that method into many, and call each of them inside a method (like doActionBatch(), where 'ActionBatch' is the name of the actual action to perform; Ex: doHttpConnect()
etc.
A tip I may suggest is to read programs written by the community; they usual adopt best practices in naming conventions and you will get more familiar with "how methods are named"
The main thing is, be consitent with your naming conventions.
I'm a .NET developer, so I found it best to follow the design guidelines used by the .NET Framework.
http://msdn.microsoft.com/en-us/library/ms229042.aspx