Rules Hub

Coding Rules Library

← Back to all rules
fullstack ruleStack: general
clean-codenaming-conventionsreadabilitymaintainability

Avoid generic variable names like 'data'

Variable names must describe the specific domain concept they hold. Generic terms like 'data', 'info', or 'items' fail to convey intent and make code harder to understand.

PR: Feat/FCK-2144 - Move ranking history to the top on mobile #325Created: Dec 7, 2025

Bad example

Old codets
1const data = await fetchUserOrders();
2const hasData = data.orders.length > 0;
3
4if (hasData) {
5 process(data);
6}

Explanation (EN)

The names 'data' and 'hasData' are semantically empty because everything in software is data. They force the reader to check the assignment source to understand what strictly domain-specific information is being handled.

Objašnjenje (HR)

Imena 'data' i 'hasData' su semantički prazna jer je sve u softveru podatak. Ona prisiljavaju čitatelja da provjeri izvorni kod dodjele kako bi razumio o kojim se točno informacijama iz domene radi.

Good example

New codets
1const userOrders = await fetchUserOrders();
2const hasOrders = userOrders.orders.length > 0;
3
4if (hasOrders) {
5 process(userOrders);
6}

Explanation (EN)

The variables are named after the specific business entities they contain ('userOrders', 'hasOrders'). This makes the code self-documenting and the logic obvious without tracing definitions.

Objašnjenje (HR)

Varijable su imenovane prema specifičnim poslovnim entitetima koje sadrže ('userOrders', 'hasOrders'). To čini kod samo-dokumentirajućim, a logiku očitom bez potrebe za praćenjem definicija.