Skip to content

Latest commit

 

History

History
 
 

snake-case-v-camelcase-for-a-rest-api

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Architecture Decision Record: snake_case v. camelCase for a REST API?

Decision: snake_case naming convention will be used for REST API endpoints

Status: Accepted

Context

In naming conventions for REST APIs, there are two popular formats: snake_case and camelCase. The snake_case format is where each word in the name is separated by underscores, whereas camelCase is where the first word of the name is in lower case, and the subsequent words have their first letter capitalized. This decision will determine which naming convention should be used for a REST API.

Decision Drivers

  • Consistency with existing naming conventions in the project

  • Readability and clarity for anyone who may be working on the API

  • Alignment with industry best practices for REST API naming conventions

  • Ease of implementation and maintenance

Decision

The snake_case naming convention will be used for REST API endpoints. This choice is driven by the following factors:

  1. Consistency: The project already uses snake_case naming convention for all endpoints, and it would be beneficial to maintain this convention to ensure consistency across the entire project.

  2. Readability and clarity: The snake_case convention is more readable and easier to understand. The underscores provide a clear separation between words, making it easier to parse and understand the meaning of the name.

  3. Alignment with industry best practices: The snake_case convention is widely used in the industry and is considered to be a best practice for REST APIs, making it a good choice for the project.

  4. Ease of implementation and maintenance: Keeping with the existing naming convention is easier to implement and maintain as all existing code and documentation would need to be updated if a new convention was chosen.

Consequences

There are potential consequences of this decision.

  • If any new team members joining the project are unfamiliar with snake_case naming convention, it could lead to confusion and mistakes in development. However, since snake_case is a widely-used convention, such a risk is minimal.

  • If other tools or frameworks are used in the project that are heavily based on camelCase convention, it may require extra effort to convert between naming conventions. However, it is not a significant concern since the project has standardized on the snake_case convention.

Overall, the decision to use snake_case naming convention for REST API endpoints results in a consistent, readable, and industry-standard approach while being easy to implement and maintain.

Credit: this page is generated by ChatGPT, then edited for clarity and format.