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
šš¼ Hallo Developer Week '24
- Phil Karlton
Onyx
Tux
Domino
Oreo
Onyx
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 get some Lebkuchen."
"DuckĀ your head while going 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 get some Lebkuchen."
"DuckĀ your head while going 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 get some Lebkuchen."
"Duck your head while going 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
Lied
(song)
Deutsch
Lid
(eyelid)
blau
(drunk)
Blau
(blue)
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);
š¤©
condition: return True if email format is valid
bool isEmailFormatValid = isEmailFormatValid();
if (isEmailFormatValid) {
Ā // Send spam
}
condition: return True if email format is valid
isEmailFormatValid
emailFormatIsValid
condition: return True if email format is valid
emailFormatIsValid
bool Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā = isEmailFormatValid();
if (emailFormatIsValid) {
Ā // Send spam
}
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
a = 111.111.111.111;
š¤¬
a = 111.111.111.111;
addr = 111.111.111.111;
a = 111.111.111.111;
addr = 111.111.111.111;
address = 111.111.111.111; Ā
// This holds the server's IP address
a = 111.111.111.111;
addr = 111.111.111.111;
address = 111.111.111.111; Ā
serverIpAddress = 111.111.111.111;
š¤©
// This holds the server's IP address
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, setsAndRepetitions, currentAndLifetimeXP, genusAndSpecies
firstSecondAndThirdThing
Examples:
heightWidthAndDepthInCentimeters, saturatedTransAndTotalFatInGrams
- Adrienne Braganza Tacke
Ā @AdrienneTacke
Know where I can get the best Drei im Weckla?
Find me and let me know š¤¤
By Adrienne Tacke
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