DEV Community

Heru Hartanto
Heru Hartanto

Posted on • Edited on

1

Clean your variable 🧼

Use meaningful names

Yes I know that you already know but honestly put meaningful name to a variable is not easy, just to remember that naming variable should be descriptive and usually javascript variable name write in camelCase and for Boolean variable name usually answer question such as isActive or hasParams

// ❌ Don't 

const x= "Jean Doe";
const bar= 23;
const active= true;

// âś… Do

const fullName= "Jean Doe";
const Age= 23;
const isActive=true;
Enter fullscreen mode Exit fullscreen mode

No hardcode values

Hardcode is hard to maintain, instead of put constant values directly, you can put it inside a meaningful and searchable constants, by the way usually constant
write with SCREEEEEEEAM_SNAKE_CASE


function setConfig(hasKey=''){
    ...
};

// ❌ Don't 

setConfig('KLKJFI123123KJHF');


// âś… Do

const HASH_KEY ='KLKJFI123123KJHF';
setConfig(HASH_KEY);


Enter fullscreen mode Exit fullscreen mode

Avoid unnecessary

Don't add redundant context to variable that already describe itself, your code is already long enough

// ❌ Don't 

const user:{
    userId:'12345',
    userPassword:'12345qwe',
    userFirstName:'John',
    userLastName:'Doe'
}

user.userPassword

// âś… Do

const user:{
    Id:'12345',
    Password:'12345qwe',
    FirstName:'John',
    LastName:'Doe'
}

user.Password
Enter fullscreen mode Exit fullscreen mode

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more