How to work with coding styles clashe within a single project across different languages? [closed]

StackOverflow https://stackoverflow.com/questions/22565138

Pregunta

In Python underscores are used for variables:

some_long_var, my_name, first_name, etc.

In JavaScript camelcase is preferred:

someLongVar, myName, firstName, etc.

All is fine and dandy until the two technologies start interacting:

JS Ajax Call:

$.get('url', {foo_bar: fooBar, bar_baz: barBaz}).done(function (data) {
    console.log(data.computed_result);
};

Python view:

def url():
    foo_bar = request.GET.get('foo_bar')
    bar_baz = request.GET.get('bar_baz')
    return jsonify(computed_result=foo_bar + bar_baz)

Do I use the Python or the JS style within the data JSON object sent to the server?

What about the JSON response?

¿Fue útil?

Solución

Pick one and be consistent. I write Python a lot, therefore I would choose the Python style, which is concerned with readability for non-native-English speakers. However, reasonable people could disagree. Build concensus on your team, and take what you can best agree to be the best course of action.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top