DEV Community

Cover image for CoDe SmElL 159 - mIxEd_cASe
Maxi Contieri
Maxi Contieri

Posted on • Originally published at maximilianocontieri.com

CoDe SmElL 159 - mIxEd_cASe

Serious development is done by many different people. We have to start agreeing.

TL;DR: Don't mix different case conversions

Problems

  • Readability

  • Maintainability

Solutions

  1. Choose a case standard

  2. Hold on to it

Context

When different people make software together they might have personal or cultural differences.

Some prefer camelCase🐫, others snake_case🐍, MACRO_CASE🗣️, and many others.

Code should be straightforward and readable.

Sample Code

Wrong

{
    "id": 2,
    "userId": 666, 
    "accountNumber": "12345-12345-12345",
    "UPDATED_AT": "2022-01-07T02:23:41.305Z",
    "created_at": "2019-01-07T02:23:41.305Z",
    "deleted at": "2022-01-07T02:23:41.305Z"
}
Enter fullscreen mode Exit fullscreen mode

Right

{
    "id": 2,
    "userId": 666, 
    "accountNumber": "12345-12345-12345",
    "updatedAt": "2022-01-07T02:23:41.305Z",
    "createdAt": "2019-01-07T02:23:41.305Z",
    "deletedAt": "2022-01-07T02:23:41.305Z"
  // This doesn't mean THIS standard is the right one
}