-
Notifications
You must be signed in to change notification settings - Fork 0
Style Guide
Concise and Consistent Naming paper
- Consistent ( Identifier needs to be unique enough to convey the concept )
- Concise ( Identifier needs to accurately convey the concept and minimize related concept space as much as possible )
- Correct ( Identifier needs to convey what is actually being assigned. )
Great code is understood; rarely is it interpreted.
can only be one of two values: true or false
isSomething
Examples: isUpgrade, isApproval, isProMember
doesSomething
Examples: allowWhitespace, willUpdate, didRestart
hasSomething
Examples: hasMoreThanOneWarning, hasMultipleDiscounts, hasException
Condition: return True if at least one user is active
const {something} = users.some(user => user.isActive);
isUsersActive
isAtLeastOneUserActive
isOneUserActive
isSomeUserActive
isAnyUserActive
hasActiveUsers
Things understood to be numbers; counts/number of something.
{integer itself}
age, year, MAXIMUM_ALLOWED_LOGIN_ATTEMPTS, tooltipDisplayMilliseconds
numberOfSomething
numberOfRetries, numberofDescendants, numberOfAccounts, numberOfDaysWithoutRain
somethingCount
failureCount, retryCount, currentCakeInventoryCount
condition: return number of eligible discount items that are part of a customer's order.
numberOfEligibleItemsWithinTransaction
numberOfEligibleItemsInTransaction
numberOfEligibleItems
numberOfEligibleDiscountItems
Unordered measures, numbers that are not integers
{{floating-point itself}}
height, weight, priceInDanishKrone, angleInDegrees, highTemperatureInFarenheit
somethingAmount
discountAmount, transferAmount, refundAmount
Labels: typically a sequence of characters
{entity itself}
fullGivenName, city, shortSpeakerBiography, playerSelectedClass, definition
somethingAsString
monthAsString, timeZoneAsString
Arrays, Lists, or sets, groups of things
{plural form of thing}
robots, sentientRobots, discountedProducts, customers, newlyReleasedBooks
implementationOfThings
unOrderedListOfCustomers, queueOfFirstPriorityTasks, orderedSetOfTimeStamps
Accessing values by keys
keyToValueMap
bookIdToAuthorMap, customerTooOrderTotalMap, productIdToSupplierMap
Typically stored together and items of the same type
firstPairAndSecondPair
lengthAndWidth, setsAndRepititions, currentAndLifetimeXP, genusAndSpecies
firstSecondAndThirdThing
heightWidthAndDepthInCentimeters, saturatedTransAndTotalFatInGrams, redGreenBlueAndAlpha