-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How should we name numeric properties? #60
Comments
I tend to use |
This might depend on the language we use. I understand why you want |
|
|
I would probably vote for visibleLength, or visibleItemsCount, the others seems can also mean array of items |
The only way to make these names 100% unambiguous is by naming it like: |
I feel like in a strongly typed language we shouldn't need the variable name to have a type. |
Type information is not always (quickly) available when reading code. Like in online environments when reviewing the work. So in my opinion, everything we can do to reduce ambiguity in naming will drastically improve the readability and understandability of the code. Finding the right balance is always tricky though :)
When reading that, to me it looks like a getter function that returns all the items that are currently in view.
Indicating purpose doesn't mean you have to include the "type" in the name.
None of them have the "type" in the name (array, number, boolean), but are still super clear. |
I'd say |
Let's assume there is a carousel and you can specify the amount of items that is visible at once. What would be a good name for that property?
numVisibleItems
?visibleItemCount
?visibleLength
? Something else?It would be good if we have a standardized way for this so it is immediately clear what the purpose of a property like that is.
The text was updated successfully, but these errors were encountered: