question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Naming convention: snake_case vs. camelCase

See original GitHub issue

This is a bit of a pedantic (breaking) issue that I found while writing up the OpenAPI spec: due to the naming convention of Postgres (snake_case), most of the fields in the API are also snake_case. It’d be more idiomatic to use camelCase.

There are also other minor issues that I found (mostly to do with types, e.g. string should be number), so we can do all that plus the OpenAPI stuff in one go. Probably not gonna eliminate all of such issues, but we can at least kaizen our way there.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
kiwicopplecommented, Jul 14, 2020

yeah it’s already used in prod so it will definitely break. The camel -> snake conversions will be safer because we aren’t using query params, but we are using response keys/objects.

at this point it’s probably less effort to be 100% camel

Probably not with the changes to production but regardless, we should prioritize the effort going forward over the effort now. Writing less code is always my number 1 concern, more than blindly following a convention.

My gut is snake_case is going to save us a mountain of effort going forward, but I’ll leave the final decision to you

Side note, I used to always write snake-camel converters between my PG database and my API. When I started using postgREST I stopped doing that and it actually made things conceptually simpler - camel = code, snake = database. Also reduced my LOC. This convention isn’t unheard of either, but not really necessary here.

2reactions
soedirgocommented, Dec 7, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Camel case vs. snake case: What's the difference?
Camel case and snake case stand at opposite ends of the variable naming convention spectrum. When multiple words are used to form a...
Read more >
Camel Case vs. Snake Case vs. Pascal Case - Khalil Stemmler
While a team can decide upon naming conventions for any project, each programming language has standard naming conventions for different tokens.
Read more >
Snake Case VS Camel Case VS Pascal Case VS Kebab Case
Specifically, there are certain naming conventions available across all programming languages, also known as: snake case; kebab case; camel case ...
Read more >
Naming Variables: When to use camelCase vs snake_case vs ...
Camel Case. camelCase is for variables, function names, arguments and other generic uses. ; Snake Case. snake_case is similar to camelCase ...
Read more >
Snake Case or Camel Case? a Guide to Programming ...
In general, snake case is considered easier to read because the underscores make it clear where one word ends and the next begins....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found