SlideShare a Scribd company logo
linkedin/borislit github.com/borislit@borislitborisl@wix.com
Name in Vain
Improving design one word at a time
Hi.
I am Boris Litvinsky
Frontend Developer @ WIX Bookings
Lithuania
Ukraine
Vilnius
Kiev
Dnipro
Wix Engineering Locations
Israel
Tel-Aviv
Be’er Sheva
Readable
Code
01
Readable by Computer
is Easy
Readable by Humans
is Difficult
It’s much more like
studying 17th century
French poetry -
WTF did this guy mean?
“
“
“
David Heinemeier Hansson
You can name
your kid anything
you want.
There are no laws.
There should be
couple of laws
- Louis CK
“
“
Naming
Matters
02
Naming Matters
▪ Discussing Names = Discussing the Product
▪ May signify a problem in a design
▪ Shortens the learning curve
▪ “The Six Month Rule”
http://blog.marcomonteiro.net/post/the-six-months-rule
The reason that they think
the old code is a mess is
because of a fundamental
law of programming:
It’s harder to read code
than to write it.
“
“
“
David Heinemeier HanssonJoel Spolsky
Anatomy of
Bad Names
03
Vague, Meaningless Names
▪ Your “Managers”, Your “Services”, Your “Handler”
▪ Your “object”, Your “data”
Don't express
their role in
the system
Eventually
become a
bag of
methods
Usually cause
SRP violation
=
Increase size
& coupling
Don't express
their role in
the system
Eventually
become a
bag of
methods
Abbreviations are Ambitious
▪ char - is it a “character” or “characteristic” ?
▪ mod - is it “modify” or “modulo”?
Compels you
to read the
code
You can’t use
them in a
conversation
Compels you
to read the
code
Too Many Words
▪ dontTryToWriteWholeSentencesWithYourDamnFunctionName
▪ How is “company_person” better than “employee” ?
http://wiki.c2.com/?MeaningfulName
http://hilton.org.uk/blog/naming-smells
Difficult to
remember
Difficult to
spot differences
Difficult to
remember
oneHorribleDescriptiveLongNameVersion
vs
oneHorribleDestructiveLongSameVersion
You probably
don’t know
what it is
You probably
don’t know
what it is
× ✓car.startEngine() car.start()
Excess Nouns in Function Names
Nouns are
implementation
details, that the
caller knows
about
▪ Perfectly fine if the noun is one of the parameters, e.g.,
car.startPowerProvider(powerProvider)
▪ Getters are horrible
Too Much Context
×
✓
class PendingPaymentRecord() {}
class PaymentRecord() {}
Prevents
reuse of
objects/meth
ods in other
valid cases
We Resolve to Basic Instincts
Lack of Domain Knowledge
Domain - A subject the software is being developed for.
But...
▪ How can you build software without understanding the problem it’s solving?
▪ How can you apply new requirements to software that doesn't reflect the domain?
▪ How can you name something you don’t understand?
Consumer Vocabulary
Domain Model
A simplified representation of
domain knowledge.
* Created by software expert & domain expert
Defines a
Ubiquitous
Language -
vocabulary used
by everybody,
everywhere
Names should reference the
Ubiquitous Language
Clean code reads like
well-written prose
“ “
“
David Heinemeier HanssonRobert C. Martin
Well Written Prose
“Prose is a form of
language that exhibits a
grammatical structure and
a natural flow of speech” -
Wikipedia
https://en.wikipedia.org/wiki/Prose
https://www.citerus.se/specification-pattern-as-a-re
factoring-tool
//Example 1
if(car.speed() > 2 * SPEED_LIMIT) {
speaker.generateAlert('Police reported ahead');
}
//Example 2
const candidateCarSpecification = colorRed
.and(inApprovedCity.or(convertible));
if (candidateCarSpecification.isSatisfiedBy(car)) {
//...
}
Classes Nouns
● Should describe the role it fulfils in the system
● Should allow the class to be easily located and evaluated
Methods
▪ Help us identify additional responsibilities, e.g., DoesThisAndThat()
https://www.youtube.com/watch?v=4cVZvoFGJTU&t=239s
RuleEvaluator
+evaluate(string)
-parseAdjunctTerm()
-parseFactorTerm()
-parseAdjunct()
-hasMoreTokens()
-getNextToken()
RuleEvaluator
+evaluate(string)
-parseAdjunctTerm()
-parseFactorTerm()
-parseAdjunct()
RuleTokenizer
+hasMoreTokens()
+getNextToken()
Methods
▪ Help us identify additional responsibilities
▪ Those without side-effects should read as noun e.g player.balance()
▪ Those with side-effects should read as verbs e.g player.start()
▪ Can include prepositions (Of, To, For) to help describe relationships to
parameters e.g payAmountOf(...) or moveTo(...)
▪ Describe everything it does - no surprises!
Interfaces Adjectives
▪ There’s no “I” in Interface
▪ Describes a capability
▪ Deliverable, Shippable, Printable
Booleans Auxiliary / Helping Verbs
▪ is, should, can, has
▪ if( piece.isOn(square) ) {...}
if( player.hasBalanceOf(amount) ) {...}
if( player.canPurchase(property) ) {...}
6 Things to Remember
★
Renaming
is part of
refactoring!
★
Use the
consumer’s
vocabulary
★
Make sure you
can read what
you write
★
Be open for
feedback
★
Communicate
names/renames
to other people.
Be consistent
Don’t give up!
Struggle for every word.
Thank You
linkedin/borislit github.com/borislit@borislitborisl@wix.com
Q&A
linkedin/borislit github.com/borislit@borislitborisl@wix.com

More Related Content

Viewers also liked

Forced marriage
Forced marriageForced marriage
Forced marriage
Nabeel Raza
 
DNA Labs
DNA LabsDNA Labs
2.5 Bhk Flats in Pune
2.5 Bhk Flats in Pune2.5 Bhk Flats in Pune
2.5 Bhk Flats in Pune
PiyeshChauhan
 
Circuito electrico 11 2
Circuito electrico 11 2Circuito electrico 11 2
Circuito electrico 11 2
sluciia06
 
The art of writing proper paragraphs
The art of writing proper paragraphsThe art of writing proper paragraphs
The art of writing proper paragraphs
Marc Draijer
 
Informe presupuesto de produccion
Informe presupuesto de produccionInforme presupuesto de produccion
Informe presupuesto de produccion
igdyth
 

Viewers also liked (7)

Forced marriage
Forced marriageForced marriage
Forced marriage
 
DNA Labs
DNA LabsDNA Labs
DNA Labs
 
2.5 Bhk Flats in Pune
2.5 Bhk Flats in Pune2.5 Bhk Flats in Pune
2.5 Bhk Flats in Pune
 
Circuito electrico 11 2
Circuito electrico 11 2Circuito electrico 11 2
Circuito electrico 11 2
 
The art of writing proper paragraphs
The art of writing proper paragraphsThe art of writing proper paragraphs
The art of writing proper paragraphs
 
Informe presupuesto de produccion
Informe presupuesto de produccionInforme presupuesto de produccion
Informe presupuesto de produccion
 
Untitled-228
Untitled-228Untitled-228
Untitled-228
 

Similar to Name in Vain: Improving design one word at a time

Does Your Code Speak Business
Does Your Code Speak BusinessDoes Your Code Speak Business
Does Your Code Speak Business
Maxime Sanglan-Charlier
 
Os Alrubaie Ruby
Os Alrubaie RubyOs Alrubaie Ruby
Os Alrubaie Ruby
oscon2007
 
WordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPressWordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPress
mtoppa
 
Aula 4 - atividades.pdf
Aula 4 - atividades.pdfAula 4 - atividades.pdf
Aula 4 - atividades.pdf
Cintia Santos
 
PRONOUN REFERENCE INF CERTO.pdf
PRONOUN REFERENCE INF CERTO.pdfPRONOUN REFERENCE INF CERTO.pdf
PRONOUN REFERENCE INF CERTO.pdf
Cintia Santos
 
Simplicitylesscode
SimplicitylesscodeSimplicitylesscode
Simplicitylesscode
James Governor
 
Resisting The Feature Creature
Resisting The Feature CreatureResisting The Feature Creature
Resisting The Feature Creature
Christian Heilmann
 
Finding balance of DDD while your application grows
Finding balance of DDD while your application growsFinding balance of DDD while your application grows
Finding balance of DDD while your application grows
Carolina Karklis
 
Web Design & Development - Session 1
Web Design & Development - Session 1Web Design & Development - Session 1
Web Design & Development - Session 1
Shahrzad Peyman
 
So…What Do I Make? (Dan Mall)
So…What Do I Make? (Dan Mall)So…What Do I Make? (Dan Mall)
So…What Do I Make? (Dan Mall)
Future Insights
 
Need to reboot your content creation strategy? Start with "No"
Need to reboot your content creation strategy? Start with "No"Need to reboot your content creation strategy? Start with "No"
Need to reboot your content creation strategy? Start with "No"
Keith Boyd
 
NET !!! A must have tool under your belt
NET !!! A must have tool under your beltNET !!! A must have tool under your belt
NET !!! A must have tool under your belt
Hansamali Gamage
 
Tc dojo presentation writing mobile documentation
Tc dojo presentation   writing mobile documentationTc dojo presentation   writing mobile documentation
Tc dojo presentation writing mobile documentation
Neil Perlin
 
The Guide to becoming a full stack developer in 2018
The Guide to becoming a full stack developer in 2018The Guide to becoming a full stack developer in 2018
The Guide to becoming a full stack developer in 2018
Amit Ashwini
 
Web-Development Powerpoint Presentation.
Web-Development Powerpoint Presentation.Web-Development Powerpoint Presentation.
Web-Development Powerpoint Presentation.
JohnLagman3
 
Tech 802: Web Design Part 2
Tech 802: Web Design Part 2Tech 802: Web Design Part 2
Tech 802: Web Design Part 2
somisguided
 
Up to speed in domain driven design
Up to speed in domain driven designUp to speed in domain driven design
Up to speed in domain driven design
Rick van der Arend
 
Technical debt a catch all phrase--
Technical debt   a catch all phrase--Technical debt   a catch all phrase--
Technical debt a catch all phrase--
Leena N
 
uuserinterfacewebdevelopmentnewoneppt.pptx
uuserinterfacewebdevelopmentnewoneppt.pptxuuserinterfacewebdevelopmentnewoneppt.pptx
uuserinterfacewebdevelopmentnewoneppt.pptx
SHAIKIRFAN715544
 
webdevelopmentppt-210923044639 (1) (1).pptx
webdevelopmentppt-210923044639 (1) (1).pptxwebdevelopmentppt-210923044639 (1) (1).pptx
webdevelopmentppt-210923044639 (1) (1).pptx
sitesite4
 

Similar to Name in Vain: Improving design one word at a time (20)

Does Your Code Speak Business
Does Your Code Speak BusinessDoes Your Code Speak Business
Does Your Code Speak Business
 
Os Alrubaie Ruby
Os Alrubaie RubyOs Alrubaie Ruby
Os Alrubaie Ruby
 
WordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPressWordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPress
 
Aula 4 - atividades.pdf
Aula 4 - atividades.pdfAula 4 - atividades.pdf
Aula 4 - atividades.pdf
 
PRONOUN REFERENCE INF CERTO.pdf
PRONOUN REFERENCE INF CERTO.pdfPRONOUN REFERENCE INF CERTO.pdf
PRONOUN REFERENCE INF CERTO.pdf
 
Simplicitylesscode
SimplicitylesscodeSimplicitylesscode
Simplicitylesscode
 
Resisting The Feature Creature
Resisting The Feature CreatureResisting The Feature Creature
Resisting The Feature Creature
 
Finding balance of DDD while your application grows
Finding balance of DDD while your application growsFinding balance of DDD while your application grows
Finding balance of DDD while your application grows
 
Web Design & Development - Session 1
Web Design & Development - Session 1Web Design & Development - Session 1
Web Design & Development - Session 1
 
So…What Do I Make? (Dan Mall)
So…What Do I Make? (Dan Mall)So…What Do I Make? (Dan Mall)
So…What Do I Make? (Dan Mall)
 
Need to reboot your content creation strategy? Start with "No"
Need to reboot your content creation strategy? Start with "No"Need to reboot your content creation strategy? Start with "No"
Need to reboot your content creation strategy? Start with "No"
 
NET !!! A must have tool under your belt
NET !!! A must have tool under your beltNET !!! A must have tool under your belt
NET !!! A must have tool under your belt
 
Tc dojo presentation writing mobile documentation
Tc dojo presentation   writing mobile documentationTc dojo presentation   writing mobile documentation
Tc dojo presentation writing mobile documentation
 
The Guide to becoming a full stack developer in 2018
The Guide to becoming a full stack developer in 2018The Guide to becoming a full stack developer in 2018
The Guide to becoming a full stack developer in 2018
 
Web-Development Powerpoint Presentation.
Web-Development Powerpoint Presentation.Web-Development Powerpoint Presentation.
Web-Development Powerpoint Presentation.
 
Tech 802: Web Design Part 2
Tech 802: Web Design Part 2Tech 802: Web Design Part 2
Tech 802: Web Design Part 2
 
Up to speed in domain driven design
Up to speed in domain driven designUp to speed in domain driven design
Up to speed in domain driven design
 
Technical debt a catch all phrase--
Technical debt   a catch all phrase--Technical debt   a catch all phrase--
Technical debt a catch all phrase--
 
uuserinterfacewebdevelopmentnewoneppt.pptx
uuserinterfacewebdevelopmentnewoneppt.pptxuuserinterfacewebdevelopmentnewoneppt.pptx
uuserinterfacewebdevelopmentnewoneppt.pptx
 
webdevelopmentppt-210923044639 (1) (1).pptx
webdevelopmentppt-210923044639 (1) (1).pptxwebdevelopmentppt-210923044639 (1) (1).pptx
webdevelopmentppt-210923044639 (1) (1).pptx
 

More from Boris Litvinsky

Road to Async Nirvana
Road to Async NirvanaRoad to Async Nirvana
Road to Async Nirvana
Boris Litvinsky
 
ReactiveConf - Not all indecision are bad
ReactiveConf - Not all indecision are badReactiveConf - Not all indecision are bad
ReactiveConf - Not all indecision are bad
Boris Litvinsky
 
Your IDE Deserves Better
Your IDE Deserves BetterYour IDE Deserves Better
Your IDE Deserves Better
Boris Litvinsky
 
The ultimate guide for Software Procrastination
The ultimate guide for Software ProcrastinationThe ultimate guide for Software Procrastination
The ultimate guide for Software Procrastination
Boris Litvinsky
 
CDD @ FED
CDD @ FEDCDD @ FED
CDD @ FED
Boris Litvinsky
 
Test Driven Culture
Test Driven CultureTest Driven Culture
Test Driven Culture
Boris Litvinsky
 
How to build 100m websites
How to build 100m websitesHow to build 100m websites
How to build 100m websites
Boris Litvinsky
 

More from Boris Litvinsky (7)

Road to Async Nirvana
Road to Async NirvanaRoad to Async Nirvana
Road to Async Nirvana
 
ReactiveConf - Not all indecision are bad
ReactiveConf - Not all indecision are badReactiveConf - Not all indecision are bad
ReactiveConf - Not all indecision are bad
 
Your IDE Deserves Better
Your IDE Deserves BetterYour IDE Deserves Better
Your IDE Deserves Better
 
The ultimate guide for Software Procrastination
The ultimate guide for Software ProcrastinationThe ultimate guide for Software Procrastination
The ultimate guide for Software Procrastination
 
CDD @ FED
CDD @ FEDCDD @ FED
CDD @ FED
 
Test Driven Culture
Test Driven CultureTest Driven Culture
Test Driven Culture
 
How to build 100m websites
How to build 100m websitesHow to build 100m websites
How to build 100m websites
 

Recently uploaded

Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
GohKiangHock
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Envertis Software Solutions
 

Recently uploaded (20)

Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
 

Name in Vain: Improving design one word at a time

  • 2. Hi. I am Boris Litvinsky Frontend Developer @ WIX Bookings Lithuania Ukraine Vilnius Kiev Dnipro Wix Engineering Locations Israel Tel-Aviv Be’er Sheva
  • 6. It’s much more like studying 17th century French poetry - WTF did this guy mean? “ “ “ David Heinemeier Hansson
  • 7. You can name your kid anything you want. There are no laws. There should be couple of laws - Louis CK “ “
  • 9. Naming Matters ▪ Discussing Names = Discussing the Product ▪ May signify a problem in a design ▪ Shortens the learning curve ▪ “The Six Month Rule” http://blog.marcomonteiro.net/post/the-six-months-rule
  • 10. The reason that they think the old code is a mess is because of a fundamental law of programming: It’s harder to read code than to write it. “ “ “ David Heinemeier HanssonJoel Spolsky
  • 12. Vague, Meaningless Names ▪ Your “Managers”, Your “Services”, Your “Handler” ▪ Your “object”, Your “data” Don't express their role in the system Eventually become a bag of methods Usually cause SRP violation = Increase size & coupling Don't express their role in the system Eventually become a bag of methods
  • 13. Abbreviations are Ambitious ▪ char - is it a “character” or “characteristic” ? ▪ mod - is it “modify” or “modulo”? Compels you to read the code You can’t use them in a conversation Compels you to read the code
  • 14. Too Many Words ▪ dontTryToWriteWholeSentencesWithYourDamnFunctionName ▪ How is “company_person” better than “employee” ? http://wiki.c2.com/?MeaningfulName http://hilton.org.uk/blog/naming-smells Difficult to remember Difficult to spot differences Difficult to remember oneHorribleDescriptiveLongNameVersion vs oneHorribleDestructiveLongSameVersion You probably don’t know what it is You probably don’t know what it is
  • 15. × ✓car.startEngine() car.start() Excess Nouns in Function Names Nouns are implementation details, that the caller knows about ▪ Perfectly fine if the noun is one of the parameters, e.g., car.startPowerProvider(powerProvider) ▪ Getters are horrible
  • 16. Too Much Context × ✓ class PendingPaymentRecord() {} class PaymentRecord() {} Prevents reuse of objects/meth ods in other valid cases
  • 17. We Resolve to Basic Instincts
  • 18. Lack of Domain Knowledge Domain - A subject the software is being developed for.
  • 19. But... ▪ How can you build software without understanding the problem it’s solving? ▪ How can you apply new requirements to software that doesn't reflect the domain? ▪ How can you name something you don’t understand?
  • 20.
  • 21. Consumer Vocabulary Domain Model A simplified representation of domain knowledge. * Created by software expert & domain expert Defines a Ubiquitous Language - vocabulary used by everybody, everywhere
  • 22. Names should reference the Ubiquitous Language
  • 23.
  • 24. Clean code reads like well-written prose “ “ “ David Heinemeier HanssonRobert C. Martin
  • 25. Well Written Prose “Prose is a form of language that exhibits a grammatical structure and a natural flow of speech” - Wikipedia https://en.wikipedia.org/wiki/Prose https://www.citerus.se/specification-pattern-as-a-re factoring-tool //Example 1 if(car.speed() > 2 * SPEED_LIMIT) { speaker.generateAlert('Police reported ahead'); } //Example 2 const candidateCarSpecification = colorRed .and(inApprovedCity.or(convertible)); if (candidateCarSpecification.isSatisfiedBy(car)) { //... }
  • 26. Classes Nouns ● Should describe the role it fulfils in the system ● Should allow the class to be easily located and evaluated
  • 27. Methods ▪ Help us identify additional responsibilities, e.g., DoesThisAndThat() https://www.youtube.com/watch?v=4cVZvoFGJTU&t=239s RuleEvaluator +evaluate(string) -parseAdjunctTerm() -parseFactorTerm() -parseAdjunct() -hasMoreTokens() -getNextToken() RuleEvaluator +evaluate(string) -parseAdjunctTerm() -parseFactorTerm() -parseAdjunct() RuleTokenizer +hasMoreTokens() +getNextToken()
  • 28. Methods ▪ Help us identify additional responsibilities ▪ Those without side-effects should read as noun e.g player.balance() ▪ Those with side-effects should read as verbs e.g player.start() ▪ Can include prepositions (Of, To, For) to help describe relationships to parameters e.g payAmountOf(...) or moveTo(...) ▪ Describe everything it does - no surprises!
  • 29. Interfaces Adjectives ▪ There’s no “I” in Interface ▪ Describes a capability ▪ Deliverable, Shippable, Printable
  • 30. Booleans Auxiliary / Helping Verbs ▪ is, should, can, has ▪ if( piece.isOn(square) ) {...} if( player.hasBalanceOf(amount) ) {...} if( player.canPurchase(property) ) {...}
  • 31. 6 Things to Remember ★ Renaming is part of refactoring! ★ Use the consumer’s vocabulary ★ Make sure you can read what you write ★ Be open for feedback ★ Communicate names/renames to other people. Be consistent Don’t give up! Struggle for every word.