E
E
Evgeny Kalibrov2018-04-17 10:26:55
JavaScript
Evgeny Kalibrov, 2018-04-17 10:26:55

What is the best way to name variables?

How to correctly name variables that end with the word List containing an array of objects. Should the first word (entity name || object class) be plural or singular? For example:
productsList, ordersList, usersList
or
productList, orderList, userList
?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anton Mashletov, 2018-04-17
@rework

Second: productList, orderList, userList
Or: products, orders, users
In general, this does not apply to programming - as far as I know, item list is correct in English, but list of items.

A
Alexander, 2018-04-17
@Tuborg

First of all, it should be clear to you and the programmer who will deal with it after you.
It makes sense to me that productsList will contain a list of products. Accordingly, the product is not one - the plural.
It is clear that it would be correct to say List of products, but such a variable is so-so :-)

A
Alexander Skusnov, 2018-04-18
@AlexSku

And I would suggest Hungarian notation: lstProducts.
Or (there are examples from Haskell) List can be abbreviated to one letter: productsL.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question