We are building a small web application in Rails that will allow clients to interact via an HTTP POST API; a typical client being another app such as an HTML form or mobile app.
We are at the point of deciding on the API field names i.e. the POST paramater names. We are wondering if there is a particular naming convention we should go with? E.g. snake_case, camelCase etc.
Some examples:
OPTION 1
employee.address.line_1=value
OPTION 2
employee_address_line_1=value
OPTION 3
employeeAddressLine1=value
We understand that all three options are technically permissible in HTTP POST, but are there any technical pitfalls we could avoid by using one over the other? For example, should we avoid using dots “.” in the field names due to the ubiquitous use of ‘dot notation’ within programming languages?
Any advice would be greatly appreciated.
It ultimately comes down to what you and your developers are most comfortable with. I personally use camelCase for all my variables, HTTP_POST or programming. I would stick with camelCase or snake_case, camelCase though is most popular.
Dot Notation is one of the worst forms for a naming convention, and you stated why. If you happen to use any language on the form that uses dot notation for functions or other object related tasks you can run into problems. EX: javascript – not a good example but most functions are dot notated.