SlideShare ist ein Scribd-Unternehmen logo
1 von 60
@PeterHilton
http://hilton.org.uk/
Naming guidelines for
professional programmers
@felienne
www.felienne.com
15 years as 

the development
team’s only native
English speaker…
3@PeterHilton •
There are two problems
in computer science…
There’s only one joke,
and it isn’t funny.
Phillip Bowden
5@PeterHilton •
SUPERNAME
NAMINATOR
What does the
computer science
literature say 

about naming?
10@PeterHilton •
http://hilton.org.uk/presentations/naming-guidelines
Why I talk about naming guidelines
1. We rely on naming to understand code
2. Bad names cause bugs
3. Good naming is critical for maintainability
4. Naming things is famously hard
5. Guidelines help us get better at naming
12@PeterHilton •
Seeing is believing: the effect of brain images on judgments of
scientific reasoning. Cognition. 2008 Apr;107(1):343-52.
Syntax guidelines (12)
Use naming conventions
Follow the programming language’s conventions for names.
☹ appleCOUNT, apple_count
X@PeterHilton •
Replace numeric suffixes
Don’t add numbers to multiple identifiers with the same
base name.
If you already have an employee variable, then a name like
employee2 has as little meaning as another_employee.
☹ employee2
X@PeterHilton •
Use dictionary words
Only use correctly-spelled dictionary words and
abbreviations that appear in a dictionary.
Make exceptions for id and documented domain-specific
language/abbreviations.
☹ acc, pos, char, mod, auth, appCnt
15@PeterHilton •
Expand single-letter names
Don’t make exceptions to using dictionary words for single-
letter names.
Use searchable names.
☹ i, j, k, l, m, n, t, x, y, z
16@PeterHilton •
Articulate symbolic names
X@PeterHilton •
Name constant values
Name what the constant represents, rather than its constant
value.
Don’t construct numeric constant names from numbers’
names.
☹ 3.142591, ONE_HUNDRED
X@PeterHilton •
Only use one underscore at a time
X@PeterHilton •
Only use underscores between words
X@PeterHilton •
Limit name character length
Keep name length within a twenty character maximum.
☹ foreignDomesticAppleCount
X@PeterHilton •
Limit name word count
Keep name length within a four word maximum, and avoid
gratuitous context.
Limit names to the number of words that people can read at
a glance.
☹ newRedAppleSizeType, myAppSizeType
17@PeterHilton •
Qualify values with suffixes
Use a suffix to describe what kind of value constant and
variable values represent.
Suffixes such as minimum, count and average relate a
collection of values to a single derived value.
☹ minimumAppleCount
X@PeterHilton •
Make names unique
Don’t overwrite a name with a duplicate name in the same
scope.
Adopt a convention that prevents ambiguity in which name
the programmer intended to refer to.
X@PeterHilton •
Vocabulary guidelines (10)
Describe meaning
Use a descriptive name whose meaning describes a
recognisable concept, with enough context.
Avoid placeholder names that deliberately mean nothing
more than a_variable.
☹ foo, blah, flag, temp
19@PeterHilton •
Be precise
Identify a specific kind of information and its purpose.
Imprecise words might apply equally to multiple identifiers,
and therefore fail to distinguish them.
☹ data, object
X@PeterHilton •
Choose concrete words
Use words that have a single clear meaning.
Like imprecise words, abstract words might apply equally to
multiple identifiers.
☹ Manager suffix, get prefix, doIt
21@PeterHilton •
Use standard language
Avoid being cute or funny when it results in a name that
requires shared culture or more effort to understand.
Deliberately meaningless names require the reader to
understand some implicit context.
☹ whack instead of kill
X@PeterHilton •
Use a large vocabulary
Use a richer single word instead of multiple words that
describe a well-known concept.
Use the word that most accurately refers to the concept the
identifier refers to.
☹ CompanyPerson
😀 Employee, Director, Shareholder
22@PeterHilton •
Use problem domain terms
Use the correct term in the problem domain’s ubiquitous
language, and only one term for each concept, within each
bounded context.
Consistently use the correct domain language terms that
subject-matter experts use.
☹ Order instead of Shipment, in supply-chain
X@PeterHilton •
Make names differ by more than 1-2 letters
Don’t use a name that barely differs from an existing name.
Avoid words that you will probably mix up when reading the
code.
☹ appleCount vs appleCounts
X@PeterHilton •
Make names differ by more than word order
Don’t use a name that only differs from an existing name in
word order.
Don’t use two names that both combine the same set of
words.
☹ appleCount vs countApple
X@PeterHilton •
Make names differ in meaning
Don’t use names that have the same meaning as each other.
Avoid names that only differ by changing words for their
synonyms.
☹ input/inputValue, recordCount/numberOfRecords
X@PeterHilton •
Make names differ phonetically
Don’t use names that sound the same when spoken.
Aim to write code another programmer could write down
correctly if you read it out loud.
☹ wrap/rap
23@PeterHilton •
Data type guidelines (7)
Omit type information
Don’t use prefixes or suffixes that encode the data type.
Avoid Hungarian notation and its remnants.
☹ isValid, dateCreated, iAppleCount
25@PeterHilton •
Use singular names for values
Don’t pluralise names for single values.
☹ appleCounts
X@PeterHilton •
Use plural names for collections
Pluralise names for collection values, such as lists.
☹ remainingApple for a set of apples
X@PeterHilton •
Prefer collective nouns for collections
If a collection’s type has a collective noun, in the name’s
context, use it instead of a plural.
☹ appointments (replace with calendar), pickedApples
(replace with harvest).
26@PeterHilton •
Use opposites precisely
Consistently use opposites in standard pairs with naming
conventions.
add/remove, begin/end, destination/source, create/
destroy, first/last, insert/delete, get/release,
lock/unlock, minimum/maximum, increment/decrement,
next/previous, old/new, open/close, put/get, show/
hide
X@PeterHilton •
Use Boolean names that imply true or false
Use names like done or found that describe Boolean values.
Use conventional Boolean names, possibly from a code
conventions list.
☹ status for e.g. started
X@PeterHilton •
Use positive Boolean names
Don’t use negation in Boolean names.
Don’t use names that require a prefix like not that inverts
the variable’s truth value.
☹ notSuccessful
X@PeterHilton •
Class & method name
guidelines (11)
Class name guidelines
1. Use a noun-phrase name
2. Use a name that allows all possible states
3. Choose a name consistent with possible values
28@PeterHilton •
Method name guidelines
Use a verb-phrase name
Don’t use get, is or has prefixes for methods with side-
effects
Only use get, is and has prefixes for methods that only
peform field access
Only use get prefix for field accessors that return a value
Only use is and has prefixes for Boolean field accessors
29@PeterHilton •
Method name guidelines
Only use set prefix for field accessors that don’t return a
value
Only use validation verbs for methods that provide the
result
Only use transformation verbs for methods that return a
transformed value
30@PeterHilton •
Rejected guidelines (10)
Use long names for long scopes
‘When you give a variable a short name like i, the length
itself says something about the variable - namely that the
variable is a scratch value with a limited scope of operation.’
Steve McConnell - Code Complete, Microsoft Press (1993)
i.e. encode a variable’s scope in its name length, which
contradicts other guidelines and encourages bad naming
32@PeterHilton •
Use short identifier names
‘avoid an identifier name shorter than eight characters,
excluding: i, j, k, l, m, n, t, x, y or z’
Phillip Relf - Achieving Software Quality through Source Code
Readability (2004)
34@PeterHilton •
Use short identifier names
‘One-character variable names should be avoided except for
temporary “throwaway” variables. Common names for
temporary variables are i, j, k, m, and n for integers; c, d,
and e for characters.’
Sun Microsystems - Code Conventions for the Java™
Programming Language (20 April 1999)
36@PeterHilton •
Conclusion
Conclusion
1. There are lots of guidelines to use
2. There are also OOP and FP guidelines
3. Some are more obvious than others
4. Some are difficult to follow
X@PeterHilton •
Further research (reverse Q&A)
38@PeterHilton •
1. How much does naming really affect maintainability?
2. Which naming guidelines have the most positive impact?
3. Does better naming reduce the need for code comments?
4. Can we measure name quality or guideline effectiveness?
5. Could we do a cost-benefit analysis of naming guidelines?
6. Do pair and mob programming improve naming quality?
7. Which techniques improve programmers’ naming skills?
8. How might we improve tool support for naming?
@PeterHilton
http://hilton.org.uk/http://hilton.org.uk/presentations/

Weitere ähnliche Inhalte

Was ist angesagt?

Python Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | EdurekaPython Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | EdurekaEdureka!
 
The Art of Clean code
The Art of Clean codeThe Art of Clean code
The Art of Clean codeVictor Rentea
 
Robot Framework :: Demo login application
Robot Framework :: Demo login applicationRobot Framework :: Demo login application
Robot Framework :: Demo login applicationSomkiat Puisungnoen
 
Developer Experience at Zalando - Handelsblatt Strategisches IT-Management 2019
Developer Experience at Zalando - Handelsblatt Strategisches IT-Management 2019Developer Experience at Zalando - Handelsblatt Strategisches IT-Management 2019
Developer Experience at Zalando - Handelsblatt Strategisches IT-Management 2019Henning Jacobs
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to PythonNowell Strite
 
Coding Best Practices
Coding Best PracticesCoding Best Practices
Coding Best Practicesmh_azad
 
Python standard library & list of important libraries
Python standard library & list of important librariesPython standard library & list of important libraries
Python standard library & list of important librariesgrinu
 
Naming Standards, Clean Code
Naming Standards, Clean CodeNaming Standards, Clean Code
Naming Standards, Clean CodeCleanestCode
 
Clean Code I - Best Practices
Clean Code I - Best PracticesClean Code I - Best Practices
Clean Code I - Best PracticesTheo Jungeblut
 
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | EdurekaPython Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | EdurekaEdureka!
 
Google test training
Google test trainingGoogle test training
Google test trainingThierry Gayet
 
7 Stages of Scaling Web Applications
7 Stages of Scaling Web Applications7 Stages of Scaling Web Applications
7 Stages of Scaling Web ApplicationsDavid Mitzenmacher
 
What is Python? | Edureka
What is Python? | EdurekaWhat is Python? | Edureka
What is Python? | EdurekaEdureka!
 
DOMinando JavaScript
DOMinando JavaScriptDOMinando JavaScript
DOMinando JavaScriptThiago Poiani
 
Robot Framework Dos And Don'ts
Robot Framework Dos And Don'tsRobot Framework Dos And Don'ts
Robot Framework Dos And Don'tsPekka Klärck
 
Create a fantasy cricket game in python.ppt
Create a fantasy cricket game in python.pptCreate a fantasy cricket game in python.ppt
Create a fantasy cricket game in python.pptRr
 
Kotlin for Android Development
Kotlin for Android DevelopmentKotlin for Android Development
Kotlin for Android DevelopmentSpeck&Tech
 

Was ist angesagt? (20)

Python Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | EdurekaPython Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | Edureka
 
The Art of Clean code
The Art of Clean codeThe Art of Clean code
The Art of Clean code
 
Robot Framework :: Demo login application
Robot Framework :: Demo login applicationRobot Framework :: Demo login application
Robot Framework :: Demo login application
 
Developer Experience at Zalando - Handelsblatt Strategisches IT-Management 2019
Developer Experience at Zalando - Handelsblatt Strategisches IT-Management 2019Developer Experience at Zalando - Handelsblatt Strategisches IT-Management 2019
Developer Experience at Zalando - Handelsblatt Strategisches IT-Management 2019
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Coding Best Practices
Coding Best PracticesCoding Best Practices
Coding Best Practices
 
Python standard library & list of important libraries
Python standard library & list of important librariesPython standard library & list of important libraries
Python standard library & list of important libraries
 
Dart programming language
Dart programming languageDart programming language
Dart programming language
 
Naming Standards, Clean Code
Naming Standards, Clean CodeNaming Standards, Clean Code
Naming Standards, Clean Code
 
Clean Code I - Best Practices
Clean Code I - Best PracticesClean Code I - Best Practices
Clean Code I - Best Practices
 
TypeScript VS JavaScript.pptx
TypeScript VS JavaScript.pptxTypeScript VS JavaScript.pptx
TypeScript VS JavaScript.pptx
 
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | EdurekaPython Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
 
Google test training
Google test trainingGoogle test training
Google test training
 
7 Stages of Scaling Web Applications
7 Stages of Scaling Web Applications7 Stages of Scaling Web Applications
7 Stages of Scaling Web Applications
 
What is Python? | Edureka
What is Python? | EdurekaWhat is Python? | Edureka
What is Python? | Edureka
 
DOMinando JavaScript
DOMinando JavaScriptDOMinando JavaScript
DOMinando JavaScript
 
Robot Framework Dos And Don'ts
Robot Framework Dos And Don'tsRobot Framework Dos And Don'ts
Robot Framework Dos And Don'ts
 
Python tutorial
Python tutorialPython tutorial
Python tutorial
 
Create a fantasy cricket game in python.ppt
Create a fantasy cricket game in python.pptCreate a fantasy cricket game in python.ppt
Create a fantasy cricket game in python.ppt
 
Kotlin for Android Development
Kotlin for Android DevelopmentKotlin for Android Development
Kotlin for Android Development
 

Ähnlich wie Naming guidelines for professional programmers

Keep It Simple - presentation at ASTC October 2018
Keep It Simple - presentation at ASTC October 2018Keep It Simple - presentation at ASTC October 2018
Keep It Simple - presentation at ASTC October 2018Kirsty Taylor, CLPM
 
How to name things: the hardest problem in programming
How to name things: the hardest problem in programmingHow to name things: the hardest problem in programming
How to name things: the hardest problem in programmingPeter Hilton
 
Ewrt 1 a class 5
Ewrt 1 a class 5Ewrt 1 a class 5
Ewrt 1 a class 5kimpalmore
 
IELTS advanced grammar tips : Academic and General exam
IELTS advanced grammar tips : Academic and General examIELTS advanced grammar tips : Academic and General exam
IELTS advanced grammar tips : Academic and General examThe Free School
 
Week 1 Quoting, Paraphrasing & Summarizing
Week 1 Quoting, Paraphrasing & SummarizingWeek 1 Quoting, Paraphrasing & Summarizing
Week 1 Quoting, Paraphrasing & SummarizingDr. Russell Rodrigo
 
you are essentially making an argument about the discourse differenc.docx
you are essentially making an argument about the discourse differenc.docxyou are essentially making an argument about the discourse differenc.docx
you are essentially making an argument about the discourse differenc.docxavaforman16457
 
Review of Research Papers.pptx
Review of Research Papers.pptxReview of Research Papers.pptx
Review of Research Papers.pptxSubramanian Mani
 
explicit-200208035426.pptx
explicit-200208035426.pptxexplicit-200208035426.pptx
explicit-200208035426.pptxNioAbaoCasyao
 
Outline AssignmentPersuasive BeliefTopicChoose a topic that is.docx
Outline AssignmentPersuasive BeliefTopicChoose a topic that is.docxOutline AssignmentPersuasive BeliefTopicChoose a topic that is.docx
Outline AssignmentPersuasive BeliefTopicChoose a topic that is.docxjohnbbruce72945
 
· Please select ONE of the following questions and write a 200-wor.docx
· Please select ONE of the following questions and write a 200-wor.docx· Please select ONE of the following questions and write a 200-wor.docx
· Please select ONE of the following questions and write a 200-wor.docxalinainglis
 
Technical Writing Guide
Technical Writing GuideTechnical Writing Guide
Technical Writing GuideAmany ibrahim
 
Keep It Simple and Straightforward
Keep It Simple and StraightforwardKeep It Simple and Straightforward
Keep It Simple and StraightforwardKirsty Taylor, CLPM
 
Paraphrasing techniques
Paraphrasing techniquesParaphrasing techniques
Paraphrasing techniquesmd ziauddin
 
Quoting paraphrasing summarising synthesising dw
Quoting paraphrasing summarising synthesising dwQuoting paraphrasing summarising synthesising dw
Quoting paraphrasing summarising synthesising dwChuangDorinWang
 
TOEFL Reading Strategies.pptx
TOEFL Reading Strategies.pptxTOEFL Reading Strategies.pptx
TOEFL Reading Strategies.pptxIrisGarcia97928
 

Ähnlich wie Naming guidelines for professional programmers (20)

Keep It Simple - presentation at ASTC October 2018
Keep It Simple - presentation at ASTC October 2018Keep It Simple - presentation at ASTC October 2018
Keep It Simple - presentation at ASTC October 2018
 
P.s.q.pptx
P.s.q.pptxP.s.q.pptx
P.s.q.pptx
 
How to name things: the hardest problem in programming
How to name things: the hardest problem in programmingHow to name things: the hardest problem in programming
How to name things: the hardest problem in programming
 
Ewrt 1 a class 5
Ewrt 1 a class 5Ewrt 1 a class 5
Ewrt 1 a class 5
 
IELTS advanced grammar tips : Academic and General exam
IELTS advanced grammar tips : Academic and General examIELTS advanced grammar tips : Academic and General exam
IELTS advanced grammar tips : Academic and General exam
 
Week 1 Quoting, Paraphrasing & Summarizing
Week 1 Quoting, Paraphrasing & SummarizingWeek 1 Quoting, Paraphrasing & Summarizing
Week 1 Quoting, Paraphrasing & Summarizing
 
you are essentially making an argument about the discourse differenc.docx
you are essentially making an argument about the discourse differenc.docxyou are essentially making an argument about the discourse differenc.docx
you are essentially making an argument about the discourse differenc.docx
 
Review of Research Papers.pptx
Review of Research Papers.pptxReview of Research Papers.pptx
Review of Research Papers.pptx
 
explicit-200208035426.pptx
explicit-200208035426.pptxexplicit-200208035426.pptx
explicit-200208035426.pptx
 
Outline AssignmentPersuasive BeliefTopicChoose a topic that is.docx
Outline AssignmentPersuasive BeliefTopicChoose a topic that is.docxOutline AssignmentPersuasive BeliefTopicChoose a topic that is.docx
Outline AssignmentPersuasive BeliefTopicChoose a topic that is.docx
 
· Please select ONE of the following questions and write a 200-wor.docx
· Please select ONE of the following questions and write a 200-wor.docx· Please select ONE of the following questions and write a 200-wor.docx
· Please select ONE of the following questions and write a 200-wor.docx
 
Technical Writing Guide
Technical Writing GuideTechnical Writing Guide
Technical Writing Guide
 
Keep It Simple and Straightforward
Keep It Simple and StraightforwardKeep It Simple and Straightforward
Keep It Simple and Straightforward
 
Examining reading
Examining readingExamining reading
Examining reading
 
Paraphrasing techniques
Paraphrasing techniquesParaphrasing techniques
Paraphrasing techniques
 
Item Writting.pptx
Item Writting.pptxItem Writting.pptx
Item Writting.pptx
 
null-1.pptx
null-1.pptxnull-1.pptx
null-1.pptx
 
Variables
VariablesVariables
Variables
 
Quoting paraphrasing summarising synthesising dw
Quoting paraphrasing summarising synthesising dwQuoting paraphrasing summarising synthesising dw
Quoting paraphrasing summarising synthesising dw
 
TOEFL Reading Strategies.pptx
TOEFL Reading Strategies.pptxTOEFL Reading Strategies.pptx
TOEFL Reading Strategies.pptx
 

Mehr von Peter Hilton

E-Prime: English for scientific writing
E-Prime: English for scientific writing E-Prime: English for scientific writing
E-Prime: English for scientific writing Peter Hilton
 
Process-oriented reactive service architecture
Process-oriented reactive service architectureProcess-oriented reactive service architecture
Process-oriented reactive service architecturePeter Hilton
 
HTTP demystified for web developers
HTTP demystified for web developersHTTP demystified for web developers
HTTP demystified for web developersPeter Hilton
 
Documentation avoidance for developers
Documentation avoidance for developersDocumentation avoidance for developers
Documentation avoidance for developersPeter Hilton
 
Meeting-avoidance for self-managing developers
Meeting-avoidance for self-managing developersMeeting-avoidance for self-managing developers
Meeting-avoidance for self-managing developersPeter Hilton
 
How to write good comments
How to write good commentsHow to write good comments
How to write good commentsPeter Hilton
 
Scaling business app development with Play and Scala
Scaling business app development with Play and ScalaScaling business app development with Play and Scala
Scaling business app development with Play and ScalaPeter Hilton
 
Play framework: lessons learned
Play framework: lessons learnedPlay framework: lessons learned
Play framework: lessons learnedPeter Hilton
 

Mehr von Peter Hilton (9)

Beautiful code
Beautiful codeBeautiful code
Beautiful code
 
E-Prime: English for scientific writing
E-Prime: English for scientific writing E-Prime: English for scientific writing
E-Prime: English for scientific writing
 
Process-oriented reactive service architecture
Process-oriented reactive service architectureProcess-oriented reactive service architecture
Process-oriented reactive service architecture
 
HTTP demystified for web developers
HTTP demystified for web developersHTTP demystified for web developers
HTTP demystified for web developers
 
Documentation avoidance for developers
Documentation avoidance for developersDocumentation avoidance for developers
Documentation avoidance for developers
 
Meeting-avoidance for self-managing developers
Meeting-avoidance for self-managing developersMeeting-avoidance for self-managing developers
Meeting-avoidance for self-managing developers
 
How to write good comments
How to write good commentsHow to write good comments
How to write good comments
 
Scaling business app development with Play and Scala
Scaling business app development with Play and ScalaScaling business app development with Play and Scala
Scaling business app development with Play and Scala
 
Play framework: lessons learned
Play framework: lessons learnedPlay framework: lessons learned
Play framework: lessons learned
 

Kürzlich hochgeladen

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 

Kürzlich hochgeladen (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 

Naming guidelines for professional programmers

  • 2.
  • 3. 15 years as 
 the development team’s only native English speaker… 3@PeterHilton •
  • 4.
  • 5. There are two problems in computer science… There’s only one joke, and it isn’t funny. Phillip Bowden 5@PeterHilton •
  • 6.
  • 7.
  • 10. What does the computer science literature say 
 about naming? 10@PeterHilton •
  • 12. Why I talk about naming guidelines 1. We rely on naming to understand code 2. Bad names cause bugs 3. Good naming is critical for maintainability 4. Naming things is famously hard 5. Guidelines help us get better at naming 12@PeterHilton •
  • 13. Seeing is believing: the effect of brain images on judgments of scientific reasoning. Cognition. 2008 Apr;107(1):343-52.
  • 15. Use naming conventions Follow the programming language’s conventions for names. ☹ appleCOUNT, apple_count X@PeterHilton •
  • 16. Replace numeric suffixes Don’t add numbers to multiple identifiers with the same base name. If you already have an employee variable, then a name like employee2 has as little meaning as another_employee. ☹ employee2 X@PeterHilton •
  • 17. Use dictionary words Only use correctly-spelled dictionary words and abbreviations that appear in a dictionary. Make exceptions for id and documented domain-specific language/abbreviations. ☹ acc, pos, char, mod, auth, appCnt 15@PeterHilton •
  • 18. Expand single-letter names Don’t make exceptions to using dictionary words for single- letter names. Use searchable names. ☹ i, j, k, l, m, n, t, x, y, z 16@PeterHilton •
  • 20. Name constant values Name what the constant represents, rather than its constant value. Don’t construct numeric constant names from numbers’ names. ☹ 3.142591, ONE_HUNDRED X@PeterHilton •
  • 21. Only use one underscore at a time X@PeterHilton •
  • 22. Only use underscores between words X@PeterHilton •
  • 23. Limit name character length Keep name length within a twenty character maximum. ☹ foreignDomesticAppleCount X@PeterHilton •
  • 24. Limit name word count Keep name length within a four word maximum, and avoid gratuitous context. Limit names to the number of words that people can read at a glance. ☹ newRedAppleSizeType, myAppSizeType 17@PeterHilton •
  • 25. Qualify values with suffixes Use a suffix to describe what kind of value constant and variable values represent. Suffixes such as minimum, count and average relate a collection of values to a single derived value. ☹ minimumAppleCount X@PeterHilton •
  • 26. Make names unique Don’t overwrite a name with a duplicate name in the same scope. Adopt a convention that prevents ambiguity in which name the programmer intended to refer to. X@PeterHilton •
  • 28. Describe meaning Use a descriptive name whose meaning describes a recognisable concept, with enough context. Avoid placeholder names that deliberately mean nothing more than a_variable. ☹ foo, blah, flag, temp 19@PeterHilton •
  • 29.
  • 30. Be precise Identify a specific kind of information and its purpose. Imprecise words might apply equally to multiple identifiers, and therefore fail to distinguish them. ☹ data, object X@PeterHilton •
  • 31. Choose concrete words Use words that have a single clear meaning. Like imprecise words, abstract words might apply equally to multiple identifiers. ☹ Manager suffix, get prefix, doIt 21@PeterHilton •
  • 32. Use standard language Avoid being cute or funny when it results in a name that requires shared culture or more effort to understand. Deliberately meaningless names require the reader to understand some implicit context. ☹ whack instead of kill X@PeterHilton •
  • 33. Use a large vocabulary Use a richer single word instead of multiple words that describe a well-known concept. Use the word that most accurately refers to the concept the identifier refers to. ☹ CompanyPerson 😀 Employee, Director, Shareholder 22@PeterHilton •
  • 34. Use problem domain terms Use the correct term in the problem domain’s ubiquitous language, and only one term for each concept, within each bounded context. Consistently use the correct domain language terms that subject-matter experts use. ☹ Order instead of Shipment, in supply-chain X@PeterHilton •
  • 35. Make names differ by more than 1-2 letters Don’t use a name that barely differs from an existing name. Avoid words that you will probably mix up when reading the code. ☹ appleCount vs appleCounts X@PeterHilton •
  • 36. Make names differ by more than word order Don’t use a name that only differs from an existing name in word order. Don’t use two names that both combine the same set of words. ☹ appleCount vs countApple X@PeterHilton •
  • 37. Make names differ in meaning Don’t use names that have the same meaning as each other. Avoid names that only differ by changing words for their synonyms. ☹ input/inputValue, recordCount/numberOfRecords X@PeterHilton •
  • 38. Make names differ phonetically Don’t use names that sound the same when spoken. Aim to write code another programmer could write down correctly if you read it out loud. ☹ wrap/rap 23@PeterHilton •
  • 40. Omit type information Don’t use prefixes or suffixes that encode the data type. Avoid Hungarian notation and its remnants. ☹ isValid, dateCreated, iAppleCount 25@PeterHilton •
  • 41. Use singular names for values Don’t pluralise names for single values. ☹ appleCounts X@PeterHilton •
  • 42. Use plural names for collections Pluralise names for collection values, such as lists. ☹ remainingApple for a set of apples X@PeterHilton •
  • 43. Prefer collective nouns for collections If a collection’s type has a collective noun, in the name’s context, use it instead of a plural. ☹ appointments (replace with calendar), pickedApples (replace with harvest). 26@PeterHilton •
  • 44. Use opposites precisely Consistently use opposites in standard pairs with naming conventions. add/remove, begin/end, destination/source, create/ destroy, first/last, insert/delete, get/release, lock/unlock, minimum/maximum, increment/decrement, next/previous, old/new, open/close, put/get, show/ hide X@PeterHilton •
  • 45. Use Boolean names that imply true or false Use names like done or found that describe Boolean values. Use conventional Boolean names, possibly from a code conventions list. ☹ status for e.g. started X@PeterHilton •
  • 46. Use positive Boolean names Don’t use negation in Boolean names. Don’t use names that require a prefix like not that inverts the variable’s truth value. ☹ notSuccessful X@PeterHilton •
  • 47. Class & method name guidelines (11)
  • 48. Class name guidelines 1. Use a noun-phrase name 2. Use a name that allows all possible states 3. Choose a name consistent with possible values 28@PeterHilton •
  • 49. Method name guidelines Use a verb-phrase name Don’t use get, is or has prefixes for methods with side- effects Only use get, is and has prefixes for methods that only peform field access Only use get prefix for field accessors that return a value Only use is and has prefixes for Boolean field accessors 29@PeterHilton •
  • 50. Method name guidelines Only use set prefix for field accessors that don’t return a value Only use validation verbs for methods that provide the result Only use transformation verbs for methods that return a transformed value 30@PeterHilton •
  • 52. Use long names for long scopes ‘When you give a variable a short name like i, the length itself says something about the variable - namely that the variable is a scratch value with a limited scope of operation.’ Steve McConnell - Code Complete, Microsoft Press (1993) i.e. encode a variable’s scope in its name length, which contradicts other guidelines and encourages bad naming 32@PeterHilton •
  • 53.
  • 54. Use short identifier names ‘avoid an identifier name shorter than eight characters, excluding: i, j, k, l, m, n, t, x, y or z’ Phillip Relf - Achieving Software Quality through Source Code Readability (2004) 34@PeterHilton •
  • 55.
  • 56. Use short identifier names ‘One-character variable names should be avoided except for temporary “throwaway” variables. Common names for temporary variables are i, j, k, m, and n for integers; c, d, and e for characters.’ Sun Microsystems - Code Conventions for the Java™ Programming Language (20 April 1999) 36@PeterHilton •
  • 58. Conclusion 1. There are lots of guidelines to use 2. There are also OOP and FP guidelines 3. Some are more obvious than others 4. Some are difficult to follow X@PeterHilton •
  • 59. Further research (reverse Q&A) 38@PeterHilton • 1. How much does naming really affect maintainability? 2. Which naming guidelines have the most positive impact? 3. Does better naming reduce the need for code comments? 4. Can we measure name quality or guideline effectiveness? 5. Could we do a cost-benefit analysis of naming guidelines? 6. Do pair and mob programming improve naming quality? 7. Which techniques improve programmers’ naming skills? 8. How might we improve tool support for naming?