简体   繁体   中英

Naming convention between python backend and javascript frontend

I have a frontend service written in javascript and a backend service written in python.

My question is what is the naming convention to be used when sending data between the services; specifically are payload keys to use camel case notation or be underscore delimited?

In either case one of the services ends up breaking naming convention and create an inconsistent appearance to code. I'm not sure if there is an established convention for this yet or a general consensus, but would appreciate any information, thoughts, and opinions on this.

Naming conventions are generally company/team-defined.

Douglas Crockford has some great naming conventions for JavaScript , which can be ensured by using JSLint or JSHint (or even ESLint ).

Python follows the PEP8 Style Guide , which widely differs from JavaScript's syntax.

Use the established naming conventions for the JavaScript code, and PEP 8 for the Python code. The actual passing of the data between JavaScript and Python should be handled by making an AJAX request that passes JSON data.

JSON has its own validator, which can be found at JSONLint .

Hope this helps! :)

Short answer: Any naming convention is as good as any but the most important part is having consistency. There was a good answer to a similar question here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM