Adrienne Tacke PRO
π΅π Software Engineer & Sr. Developer π₯ @ Cisco β’ Published Author β’ LinkedIn Learning Instructor β’ Twitch Streamer πΉ Most important: I spend way too much money on desserts and endless hours playing Borderlands
Β @AdrienneTacke
π Copenhagen Developers Festival
- Phil Karlton
Onyx
Tux
Domino
Oreo
Onyx
Adrienne
Adrienne
The way scientists name things
scientific nomenclature
Scientists prevent confusion by being specific.
specific
?
Say what strange White Oak is this...
It was a Rounded Oak, I believe.
The Rough Oak still stands, day after day!
And there stood before me, a White Oak.
Carl Linnaeus
Swedish Naturalist
developed unique naming system
Every organism in the world is assigned a unique binomial name.
binomial name
binomial name
Homo
sapiens
genus
species modifier
binomial name
Homo
sapiens
genus
species modifier
camelCase
kebab-case
PascalCase
snake_case
i
ht
long
TotalInventoryCountForEndOfDay
casing
length
auth
usr
camelCase
kebab-case
PascalCase
snake_case
i
ht
long
TotalInventoryCountForEndOfDay
casing
length
auth
usr
"Use meaningful, descriptive names..."
"Names should be nonambiguous."
"Try making identifiers self-documenting."
meaningful
descriptive
self-documenting
nonambiguous
meaningful
descriptive
self-documenting
nonambiguous
"meaningful"
"descriptive"
"self-documenting"
"nonambiguous"
meaningful
descriptive
self-documenting
nonambiguous
correct
highly debatable
"Β Β Β Β "
same words, different meaning
homophones
homographs
"same writing"
same spelling, different meaning
"same sound"
same pronunciation, different meaning
homophones
homographs
English
duck
"I took my pet duck to the Gucci store."
"Duck your head going while down the stairs!"
rock
"There was a great rockΒ band last night."
"Almost four tons of solid rock had to be removed."
homophones
homographs
English
duck
"I took my pet duck to the Gucci store."
"Duck your head going while down the stairs!"
rock
"There was a great rockΒ band last night."
"Almost four tons of solid rock had to be removed."
write
"Turn right at the next intersection."
"WriteΒ a book, they said."
hour
"You are with me for the hour."
"What do you mean 'our' cake?"
right
our
English
homophones
homographs
English
duck
"I took my pet duck to the Gucci store."
"Duck your head going while down the stairs!"
rock
"There was a great rockΒ band last night."
"Almost four tons of solid rock had to be removed."
write
"Turn right at the next intersection."
"WriteΒ a book, they said."
hour
"You are with me for the hour."
"What do you mean 'our' cake?"
right
our
English
same spelling, different meaning
same pronunciation, different meaning
skΓ₯l
(cheers!)
Danish
skΓ₯l
(bowl)
jul
(christmas)
hjul
(wheel)
tayo
(we)
Tagalog
tayo
(to stand)
basa
(to read)
basa
(wet)
different words, same meaning
count
tally
enumeration of numbers
summation
keep count
to mark
Names
Concepts
Words chosen as identifiers
Associated meanings and perceptions tied to a name
Florian Deissenboeck Β· Markus Pizka
Concise and consistent naming
Published in Software Quality Journal (2006)
Source: Deissenboeck, F., & Pizka, M. (2006). Concise and consistent naming. Software Quality Journal, 14, 261-282.
Source: Deissenboeck, F., & Pizka, M. (2006). Concise and consistent naming. Software Quality Journal, 14, 261-282.
"In computer programs, homonyms pose an obstacle for program comprehension since the developer has to take all elements of the set Cn into account when spotting an identifier named n."
Source: Deissenboeck, F., & Pizka, M. (2006). Concise and consistent naming. Software Quality Journal, 14, 261-282.
"Synonyms unnecessarily increase the domain of N and the relation R...raising the learning effort of the language used."
Source: Deissenboeck, F., & Pizka, M. (2006). Concise and consistent naming. Software Quality Journal, 14, 261-282.
"On encountering name n1, which is synonym to n2, the reader must take concepts c1 and c2 into account."
Source: Deissenboeck, F., & Pizka, M. (2006). Concise and consistent naming. Software Quality Journal, 14, 261-282.
Ideally, we get to this
Source: Feitelson, D. G., Mizrahi, A., Noy, N., Shabat, A. B., Eliyahu, O., & Sheffer, R. (2020). How developers choose names
Consistent
Concise
Correct
Concise
Correct
Consistent
Identifier needs to be unique enough to convey the concept.
Correct
Identifier needs to accurately convey the concept and minimize related concept space as much as possible.
Consistent
Concise
Identifier needs to be unique enough to convey the concept.
Consistent
Concise
Correct
Identifier needs to convey what is actually being assigned.
Identifier needs to accurately convey the concept and minimize related concept space as much as possible.
Identifier needs to be unique enough to convey the concept.
Booleans
Can only be one of two values: true or false
Booleans
Can only be one of two values: true or false
isSomething
doesSomething
hasSomething
Examples:
isUpgrade, isApproval, isProMember
Examples:
allowsWhitespace, willUpdate, didRestart
Examples:
hasMoreThanOneWarning, hasMultipleDiscounts, hasException
condition: return True if at least one user is active
isUsersActive
const {something} = users.some(user => user.isActive);
condition: return True if at least one user is active
isUsersActive
const isUsersActive = users.some(user => user.isActive);
isUsersActive
isUsersActive
condition: return True if at least one user is active
isAtLeastOneUserActive
isAtLeastOneUserActive
const isAtLeastOneUserActive = users.some(user => user.isActive);
isAtLeastOneUserActive
condition: return True if at least one user is active
isOneUserActive
isOneUserActive
const isOneUserActive = users.some(user => user.isActive);
isOneUserActive
condition: return True if at least one user is active
isSomeUserActive
isSomeUserActive
const isSomeUserActive = users.some(user => user.isActive);
isSomeUserActive
condition: return True if at least one user is active
isAnyUserActive
const isAnyUserActive = users.some(user => user.isActive);
π€©
Integers
Things understood to be numbers; counts/number of something
Integers
Things understood to be numbers; counts/number of something
{integer itself}
numberOfSomething
somethingCount
Examples:
age, year, MAXIMUM_ALLOWED_LOGIN_ATTEMPTS, tooltipDelayInMilliseconds
Examples:
numberOfRetries, numberOfDescendants, numberOfAccounts, numberOfDaysWithoutRain
Examples:
failureCount, retryCount, currentCakeInventoryCount
condition: return number of eligible discount items that are part of a customer's order.
numberOfEligibleItemsWithinTransaction
condition: return number of eligible discount items that are part of a customer's order.
numberOfEligibleItemsWithinTransaction
numberOfEligibleItemsInTransaction
condition: return number of eligible discount items that are part of a customer's order.
numberOfEligibleItemsWithinTransaction
numberOfEligibleItemsInTransaction
numberOfEligibleItems
condition: return number of eligible discount items that are part of a customer's order.
numberOfEligibleItemsWithinTransaction
numberOfEligibleItemsInTransaction
numberOfEligibleItems
numberOfEligibleDiscountItems
π€©
Floating-Point Numbers
Unrounded measures;
numbers that are not integers
Floating-Point Numbers
Unrounded measures; numbers that are not integers
{floating-point itself}
somethingAmount
Examples:
height, weight, priceInDanishKrone, angleInDegrees, highTemperatureInFahrenheit
Examples:
discountAmount, transferAmount, refundAmount
Strings
Labels; typically a sequence of characters
Strings
Labels; typically a sequence of characters
{entity itself}
somethingAsString
Examples:
fullGivenName, city, shortSpeakerBiography, playerSelectedClass, definition
Examples:
monthAsString, timeZoneAsString
Collections
Arrays, lists, or sets; groups of things
Collections
Arrays, lists, or sets; groups of things
{plural form of thing}
implementationOfThings
Examples:
robots, sentientRobots, discountedProducts, customers, newlyReleasedBooks
Examples:
unorderedListOfCustomers, queueOfFirstPriorityTasks, orderedSetOfTimeStamps
Maps
Accessing values by keys
Maps
Accessing values by keys
keyToValueMap
Examples:
bookIdToAuthorMap, customerToOrderTotalMap, productIdToSuppliersMap
Pairs & Tuples
Typically stored together; items of the same type
Pairs & Tuples
Typically stored together and items of the same type
firstPairAndSecondPair
Examples:
lengthAndWidth, setsAndRepitions, currentAndLifetimeXP, genusAndSpecies
firstSecondAndThirdThing
Examples:
heightWidthAndDepthInCentimeters, saturatedTransAndTotalFatInGrams, redGreenBlueAndAlpha
- Adrienne Braganza Tacke
Adrienne Braganza Tacke
Β @AdrienneTacke
Currently writing this!
π€π° Know a good pΓ’tisserie/bakery?
Please come find me and let's chat!
By Adrienne Tacke
First presented at Copenhagen Developers Festival (August 2023) As the famous Phil Karlton quote goes: "There are only two hard things in Computer Science: cache invalidation and naming things". This talk focuses on one of those things: naming! Why is naming so difficult? How do we craft concise, clear, and consistent variable names? What makes a variable name concise, clear, and consistent? In this talk, I'd like to discuss the importance of naming, walk through examples of variable names and improve them, and set some clear guidelines and tips on how to name things. By the end of this talk, you'll leave with the indispensable skill of effectively naming things!
π΅π Software Engineer & Sr. Developer π₯ @ Cisco β’ Published Author β’ LinkedIn Learning Instructor β’ Twitch Streamer πΉ Most important: I spend way too much money on desserts and endless hours playing Borderlands