SlideShare a Scribd company logo
1 of 60
Download to read offline
CODING FOR HUMANS
Paola Ducolin |WiMLDS Paris | 14 Mai 2020
ABOUT MYSELF
• 🙋 Paola Ducolin 🇮🇹
• 💻 Staff Engineer @ Dashlane
• 👩💻 Ladies of Code Paris co-organizer
• 🏳🌈 Paris QueerJS organizer
• 👵 10+ years in software development
• 🤦 8+ years with legacy code
2
ABOUT QUEERJS
3
4
17:00 CEST, MAY 16TH @ TWITCH.TV/QUEERJS
5
CODING FOR HUMANS
6
DESIGNING FOR HUMANS
7
8
9
65kg
10
11
WHAT ABOUT CODE?
Coding for humans | @PolaDuco WiMLDS Paris | 14 mai 2020 12
Coding for humans | @PolaDuco WiMLDS Paris | 14 mai 2020 13
bit.ly/QueerInTechPhotos
LEGACY CODE IMPACT ON MY FEELINGS
14
Coding life
Reading Writing
Source: Robert C. Martin
15
16
All code becomes legacy code
17
eventually
18
1. WRITING READABLE CODE
2. WRITING HUMAN DOCUMENTATION
19
Coding life
Reading Writing
Source: Robert C. Martin
20
HUMAN CODE
21
Use semantically
meaning names
EXAMPLES - NAMING
22
https://bit.ly/coding-for-humans
class Rectangle {
constructor(w, h) {
this.w = w;
this.h = h;
}
calcA() {
return this.w * this.h;
}
}
EXAMPLES - NAMING
23
https://bit.ly/coding-for-humans
class Rectangle {
constructor(width, height) {
this.width = width;
this.height = height;
}
calculateArea() {
return this.width * this.height;
}
}
EXAMPLES – NAMING 2
24
https://bit.ly/coding-for-humans
const LETTERS = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
const CHARS = LETTERS + "1234567890!@#$%^&*()_-+=[]{}|/?><.,;:";
EXAMPLES – NAMING 2
25
https://bit.ly/coding-for-humans
const LETTERS = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
const LETTERS_DIGITS_SYMBOLS =
LETTERS + "1234567890!@#$%^&*()_-+=[]{}|/?><.,;:";
HUMAN CODE
26
Use semantically
meaning names
Prevent reading inner
code
EXAMPLES – INNER CODE
27
https://bit.ly/coding-for-humans
var rectangle = new Rectangle(3, 5);
rectangle.increaseSize(0.3);
class Rectangle {
constructor(width, height) {
this.width = width;
this.height = height;
}
increaseSize(percentage) {
this.width *= percentage;
this.height *= percentage;
}
}
EXAMPLES – INNER CODE
28
https://bit.ly/coding-for-humans
var rectangle = new Rectangle(3, 5);
rectangle.scaleWidthAndHeightByFactor(0.3);
class Rectangle {
constructor(width, height) {
this.width = width;
this.height = height;
}
scaleWidthAndHeightByFactor(percentage) {
this.width *= percentage;
this.height *= percentage;
}
}
EXAMPLES – INNER CODE
29
// This is a comment
HUMAN CODE
30
Use semantically
meaning names
Prevent reading inner
code
Do one thing
Minimize function
length
EXAMPLES – MINIMIZE LENGTH
31
https://bit.ly/coding-for-humans
function Adjust(rectangle) {
rectangle.Size = Size.S;
rectangle.HasError = false;
rectangle.IsSquare = false;
if (rectangle.Width >= 10000)
rectangle.Size = Size.L;
if (rectangle.Height <= 100)
rectangle.HasError = true;
if (rectangle.Width ===
rectangle.Height) rectangle.IsSquare =
true;
if (rectangle.Width >= 20000)
rectangle.Size = Size.XL;
if (rectangle.Height <= 200)
rectangle.Size = Size.M;
if (rectangle.Width <= 300)
rectangle.HasError = true;
}
EXAMPLES – MINIMIZE LENGTH
32
https://bit.ly/coding-for-humans
import fc from "fast-check";
function test() {
fc.assert(
fc.property(fc.integer(0, 30000),
fc.integer(0, 30000), (width, height) => {
let rectangle = {
TotalPurchases: totalPurchases,
RecentOrders: recentOrders,
LovesJavaScript: lovesJavaScript,
KnowsCobol: knowsCobol,
};
let rectangle_expected =
JSON.parse(JSON.stringify(rectangle));
Adjust(rectangle_expected);
Adjust_new(rectangle);
expect(rectangle.Size).toBe(rectangle_expe
cted.Size);
expect(rectangle.HasError).toBe(rectangle_
expected.HasError);
expect(rectangle.IsSquare).toBe(rectangle_
expected.IsSquare);
})
);
}
EXAMPLES – MINIMIZE LENGTH
33
https://bit.ly/coding-for-humans
function Adjust(rectangle) {
rectangle.Size = Size.S;
rectangle.HasError = false;
rectangle.IsSquare = false;
if (rectangle.Width >= 10000)
rectangle.Size = Size.L;
if (rectangle.Height <= 100)
rectangle.HasError = true;
if (rectangle.Width ===
rectangle.Height) rectangle.IsSquare =
true;
if (rectangle.Width >= 20000)
rectangle.Size = Size.XL;
if (rectangle.Height <= 200)
rectangle.Size = Size.M;
if (rectangle.Width <= 300)
rectangle.HasError = true;
}
EXAMPLES – MINIMIZE LENGTH
34
https://bit.ly/coding-for-humans
function AdjustSize(rectangle) {
if (rectangle.Height <= 200) rectangle.Size = Size.M;
else if (rectangle.Width >= 20000) rectangle.Size = Size.XL;
else if (rectangle.Width >= 10000) rectangle.Size = Size.L;
else rectangle.Size = Size.S;
}
EXAMPLES – MINIMIZE LENGTH
35
https://bit.ly/coding-for-humans
function Adjust(rectangle) {
rectangle.Size = Size.S;
rectangle.HasError = false;
rectangle.IsSquare = false;
if (rectangle.Width >= 10000)
rectangle.Size = Size.L;
if (rectangle.Height <= 100)
rectangle.HasError = true;
if (rectangle.Width ===
rectangle.Height) rectangle.IsSquare =
true;
if (rectangle.Width >= 20000)
rectangle.Size = Size.XL;
if (rectangle.Height <= 200)
rectangle.Size = Size.M;
if (rectangle.Width <= 300)
rectangle.HasError = true;
}
EXAMPLES – MINIMIZE LENGTH
36
https://bit.ly/coding-for-humans
function AdjustHasError(rectangle) {
if (rectangle.Height <= 100 || rectangle.Width <= 300)
rectangle.HasError = true;
else rectangle.HasError = false;
}
EXAMPLES – MINIMIZE LENGTH
37
https://bit.ly/coding-for-humans
function AdjustIsSquare(rectangle) {
if (rectangle.Width === rectangle.Height)
rectangle.IsSquare = true;
else rectangle.IsSquare = false;
}
EXAMPLES – MINIMIZE LENGTH
38
https://bit.ly/coding-for-humans
function Adjust_new(rectangle) {
AdjustSize(rectangle);
AdjustHasError(rectangle);
AdjustIsSquare(rectangle);
}
HUMAN CODE
39
Use semantically
meaning names
Prevent reading
inner code
Do one thing
Minimize
function length
Top-down
narrative
EXAMPLES – TOP DOWN NARRATIVE
40
https://bit.ly/coding-for-humans
class Rectangle {
// helper functions BEGIN
#scaleWidthByFactor(scalingFactor) {
this.width *= scalingFactor;
}
#scaleHeightByFactor(scalingFactor) {
this.height *= scalingFactor;
}
// helper functions END
// frequently used functions BEGIN
ScaleWidthAndHeightByFactor(scalingFactor) {
this.#scaleWidthByFactor(scalingFactor);
this.#scaleHeightByFactor(scalingFactor);
}
// frequently used functions END
}
EXAMPLES – TOP DOWN NARRATIVE
41
https://bit.ly/coding-for-humans
class Rectangle {
// scaling functions BEGIN
ScaleWidthAndHeightByFactor(scalingFactor) {
this.#scaleWidthByFactor(scalingFactor);
this.#scaleHeightByFactor(scalingFactor);
}
#scaleWidthByFactor(scalingFactor) {
this.width *= scalingFactor;
}
#scaleHeightByFactor(scalingFactor) {
this.height *= scalingFactor;
}
// scaling functions END
}
HUMAN CODE
42
Use semantically
meaning names
Prevent reading
inner code
Do one thing
Minimize
function length
Top-down
narrative
Review with the
team
Use refactoring
tools
43
USE EMPATHY WHILE READING CODE
44
https://bit.ly/romeu-moura
1. WRITING READABLE CODE
2. WRITING HUMAN DOCUMENTATION
45
bit.ly/carolstran-human-docs
HUMANISING YOUR DOCUMENTATION - CAROLYN STRANSKY
46
HUMAN DOCUMENTATION
• Use inclusive and clear language
47
bit.ly/alex-js
ENSURE INCLUSIVE AND CLEAR LANGUAGE
48
bit.ly/write-good
ENSURE INCLUSIVE AND CLEAR LANGUAGE
49
Wow! Congratulations to Greg Gutfeld, a one time Trump Hater who has come all the
way home. His Ratings easily beat no talent Stephen Colbert, nice guy Jimmy
Fallon, and wacko “last placer” Jimmy Kimmel. Greg built his show from scratch,
and did a great job in doing so.
Well run States should not be bailing out poorly run States, using CoronaVirus as
the excuse! The elimination of Sanctuary Cities, Payroll Taxes, and perhaps
Capital Gains Taxes, must be put on the table. Also lawsuit indemnification &
business deductions for restaurants & ent.
Most of the money raised by the RINO losers of the so-called “Lincoln Project”,
goes into their own pockets. With what I’ve done on Judges, Taxes, Regulations,
Healthcare, the Military, Vets (Choice!) & protecting our great 2A, they should
love Trump. Problem is, I BEAT THEM ALL!
=============
he way home. His Ratings easily beat no talent Stephen Colbert, nice guy Jimmy F
^^^^^^
"easily" can weaken meaning on line 1 at column 104
-------------
hould not be bailing out poorly run States, using CoronaVirus as the excuse! The
^^^^^^
"poorly" can weaken meaning on line 3 at column 42
-------------
apital GainsTaxes, must be put on the table.Also lawsuit indemnification & bus
^^^^^^
"be put" may be passive voice on line 3 at column 184
ENSURE INCLUSIVE AND CLEAR LANGUAGE
50
bit.ly/hemingwayapp
HUMAN DOCUMENTATION
• Use inclusive and clear language
• Ensure visibility
51
Roads for Success Navigating Docs – Kyle Gillbit.ly/roads-docs
THINK TWICE ABOUT NAVIGATION
52
THINK TWICE ABOUT NAVIGATION
53
54
bit.ly/dashlane-ds
55
bit.ly/dashlane-ds
THINK TWICE ABOUT NAVIGATION
56
bit.ly/dashlane-ds
HUMAN DOCUMENTATION
• Use inclusive and clear language
• Ensure visibility
• Update it
57
UPDATE IT
58
bit.ly/dashlane-ds
UPDATE IT
59
https://bit.ly/template-pr
60
THANK YOU

More Related Content

Similar to “Coding For Humans” by Paola Ducolin, Staff Engineer @ Dashlane

Learn Python 3 for absolute beginners
Learn Python 3 for absolute beginnersLearn Python 3 for absolute beginners
Learn Python 3 for absolute beginnersKingsleyAmankwa
 
Python in 30 minutes!
Python in 30 minutes!Python in 30 minutes!
Python in 30 minutes!Fariz Darari
 
Being Expressive in Code
Being Expressive in CodeBeing Expressive in Code
Being Expressive in CodeEamonn Boyle
 
Machine Learning on Code - SF meetup
Machine Learning on Code - SF meetupMachine Learning on Code - SF meetup
Machine Learning on Code - SF meetupsource{d}
 
A 64-bit horse that can count
A 64-bit horse that can countA 64-bit horse that can count
A 64-bit horse that can countAndrey Karpov
 
The article is a report about testing of portability of Loki library with 64-...
The article is a report about testing of portability of Loki library with 64-...The article is a report about testing of portability of Loki library with 64-...
The article is a report about testing of portability of Loki library with 64-...PVS-Studio
 
FITC '14 Toronto - Technology, a means to an end
FITC '14 Toronto - Technology, a means to an endFITC '14 Toronto - Technology, a means to an end
FITC '14 Toronto - Technology, a means to an endThibault Imbert
 
Technology: A Means to an End with Thibault Imbert
Technology: A Means to an End with Thibault ImbertTechnology: A Means to an End with Thibault Imbert
Technology: A Means to an End with Thibault ImbertFITC
 
Making your hackathon matter api con-uk
Making your hackathon matter   api con-ukMaking your hackathon matter   api con-uk
Making your hackathon matter api con-ukCristiano Betta
 
What The Heck Is Hacking?
What The Heck Is Hacking? What The Heck Is Hacking?
What The Heck Is Hacking? Lars Zimmermann
 
Flink Forward San Francisco 2019: Flink Powered Customer Experience: Scaling ...
Flink Forward San Francisco 2019: Flink Powered Customer Experience: Scaling ...Flink Forward San Francisco 2019: Flink Powered Customer Experience: Scaling ...
Flink Forward San Francisco 2019: Flink Powered Customer Experience: Scaling ...Flink Forward
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerAndrey Karpov
 
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8tdc-globalcode
 
Zn task - defcon russia 20
Zn task  - defcon russia 20Zn task  - defcon russia 20
Zn task - defcon russia 20DefconRussia
 
Quantum programming in a nutshell Radu Vunvulea ITCamp 2018
Quantum programming in a nutshell Radu Vunvulea  ITCamp 2018Quantum programming in a nutshell Radu Vunvulea  ITCamp 2018
Quantum programming in a nutshell Radu Vunvulea ITCamp 2018Radu Vunvulea
 
What if everything is awesome? Codemotion Madrid 2014
What if everything is awesome? Codemotion Madrid 2014What if everything is awesome? Codemotion Madrid 2014
What if everything is awesome? Codemotion Madrid 2014Christian Heilmann
 
Smell your Code! @ Free Dimension
Smell your Code! @ Free DimensionSmell your Code! @ Free Dimension
Smell your Code! @ Free DimensionYaser Sulaiman
 
Tech night ldn - chatbot
Tech night ldn - chatbotTech night ldn - chatbot
Tech night ldn - chatbotMarco Visintin
 

Similar to “Coding For Humans” by Paola Ducolin, Staff Engineer @ Dashlane (20)

Learn Python 3 for absolute beginners
Learn Python 3 for absolute beginnersLearn Python 3 for absolute beginners
Learn Python 3 for absolute beginners
 
Python in 30 minutes!
Python in 30 minutes!Python in 30 minutes!
Python in 30 minutes!
 
Being Expressive in Code
Being Expressive in CodeBeing Expressive in Code
Being Expressive in Code
 
Machine Learning on Code - SF meetup
Machine Learning on Code - SF meetupMachine Learning on Code - SF meetup
Machine Learning on Code - SF meetup
 
A 64-bit horse that can count
A 64-bit horse that can countA 64-bit horse that can count
A 64-bit horse that can count
 
The article is a report about testing of portability of Loki library with 64-...
The article is a report about testing of portability of Loki library with 64-...The article is a report about testing of portability of Loki library with 64-...
The article is a report about testing of portability of Loki library with 64-...
 
FITC '14 Toronto - Technology, a means to an end
FITC '14 Toronto - Technology, a means to an endFITC '14 Toronto - Technology, a means to an end
FITC '14 Toronto - Technology, a means to an end
 
Technology: A Means to an End with Thibault Imbert
Technology: A Means to an End with Thibault ImbertTechnology: A Means to an End with Thibault Imbert
Technology: A Means to an End with Thibault Imbert
 
Making your hackathon matter api con-uk
Making your hackathon matter   api con-ukMaking your hackathon matter   api con-uk
Making your hackathon matter api con-uk
 
What The Heck Is Hacking?
What The Heck Is Hacking? What The Heck Is Hacking?
What The Heck Is Hacking?
 
Novidades do c# 7 e 8
Novidades do c# 7 e 8Novidades do c# 7 e 8
Novidades do c# 7 e 8
 
Flink Forward San Francisco 2019: Flink Powered Customer Experience: Scaling ...
Flink Forward San Francisco 2019: Flink Powered Customer Experience: Scaling ...Flink Forward San Francisco 2019: Flink Powered Customer Experience: Scaling ...
Flink Forward San Francisco 2019: Flink Powered Customer Experience: Scaling ...
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical Reviewer
 
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
TDC2018SP | Trilha .Net - Novidades do C# 7 e 8
 
Zn task - defcon russia 20
Zn task  - defcon russia 20Zn task  - defcon russia 20
Zn task - defcon russia 20
 
Quantum programming in a nutshell Radu Vunvulea ITCamp 2018
Quantum programming in a nutshell Radu Vunvulea  ITCamp 2018Quantum programming in a nutshell Radu Vunvulea  ITCamp 2018
Quantum programming in a nutshell Radu Vunvulea ITCamp 2018
 
What if everything is awesome? Codemotion Madrid 2014
What if everything is awesome? Codemotion Madrid 2014What if everything is awesome? Codemotion Madrid 2014
What if everything is awesome? Codemotion Madrid 2014
 
2-Functions.pdf
2-Functions.pdf2-Functions.pdf
2-Functions.pdf
 
Smell your Code! @ Free Dimension
Smell your Code! @ Free DimensionSmell your Code! @ Free Dimension
Smell your Code! @ Free Dimension
 
Tech night ldn - chatbot
Tech night ldn - chatbotTech night ldn - chatbot
Tech night ldn - chatbot
 

More from Paris Women in Machine Learning and Data Science

More from Paris Women in Machine Learning and Data Science (20)

Managing international tech teams, by Natasha Dimban
Managing international tech teams, by Natasha DimbanManaging international tech teams, by Natasha Dimban
Managing international tech teams, by Natasha Dimban
 
Optimizing GenAI apps, by N. El Mawass and Maria Knorps
Optimizing GenAI apps, by N. El Mawass and Maria KnorpsOptimizing GenAI apps, by N. El Mawass and Maria Knorps
Optimizing GenAI apps, by N. El Mawass and Maria Knorps
 
Perspectives, by M. Pannegeon
Perspectives, by M. PannegeonPerspectives, by M. Pannegeon
Perspectives, by M. Pannegeon
 
Evaluation strategies for dealing with partially labelled or unlabelled data
Evaluation strategies for dealing with partially labelled or unlabelled dataEvaluation strategies for dealing with partially labelled or unlabelled data
Evaluation strategies for dealing with partially labelled or unlabelled data
 
Combinatorial Optimisation with Policy Adaptation using latent Space Search, ...
Combinatorial Optimisation with Policy Adaptation using latent Space Search, ...Combinatorial Optimisation with Policy Adaptation using latent Space Search, ...
Combinatorial Optimisation with Policy Adaptation using latent Space Search, ...
 
An age-old question, by Caroline Jean-Pierre
An age-old question, by Caroline Jean-PierreAn age-old question, by Caroline Jean-Pierre
An age-old question, by Caroline Jean-Pierre
 
How to supervise a thesis in NLP in the ChatGPT era? By Laure Soulier
How to supervise a thesis in NLP in the ChatGPT era? By Laure SoulierHow to supervise a thesis in NLP in the ChatGPT era? By Laure Soulier
How to supervise a thesis in NLP in the ChatGPT era? By Laure Soulier
 
Global Ambitions Local Realities, by Anna Abreu
Global Ambitions Local Realities, by Anna AbreuGlobal Ambitions Local Realities, by Anna Abreu
Global Ambitions Local Realities, by Anna Abreu
 
Plug-and-Play methods for inverse problems in imagine, by Julie Delon
Plug-and-Play methods for inverse problems in imagine, by Julie DelonPlug-and-Play methods for inverse problems in imagine, by Julie Delon
Plug-and-Play methods for inverse problems in imagine, by Julie Delon
 
Sales Forecasting as a Data Product by Francesca Iannuzzi
Sales Forecasting as a Data Product by Francesca IannuzziSales Forecasting as a Data Product by Francesca Iannuzzi
Sales Forecasting as a Data Product by Francesca Iannuzzi
 
Identifying and mitigating bias in machine learning, by Ruta Binkyte
Identifying and mitigating bias in machine learning, by Ruta BinkyteIdentifying and mitigating bias in machine learning, by Ruta Binkyte
Identifying and mitigating bias in machine learning, by Ruta Binkyte
 
Nature Language Processing for proteins by Amélie Héliou, Software Engineer @...
Nature Language Processing for proteins by Amélie Héliou, Software Engineer @...Nature Language Processing for proteins by Amélie Héliou, Software Engineer @...
Nature Language Processing for proteins by Amélie Héliou, Software Engineer @...
 
Sandrine Henry presents the BechdelAI project
Sandrine Henry presents the BechdelAI projectSandrine Henry presents the BechdelAI project
Sandrine Henry presents the BechdelAI project
 
Anastasiia Tryputen_War in Ukraine or how extraordinary courage reshapes geop...
Anastasiia Tryputen_War in Ukraine or how extraordinary courage reshapes geop...Anastasiia Tryputen_War in Ukraine or how extraordinary courage reshapes geop...
Anastasiia Tryputen_War in Ukraine or how extraordinary courage reshapes geop...
 
Khrystyna Grynko WiMLDS - From marketing to Tech.pdf
Khrystyna Grynko WiMLDS - From marketing to Tech.pdfKhrystyna Grynko WiMLDS - From marketing to Tech.pdf
Khrystyna Grynko WiMLDS - From marketing to Tech.pdf
 
Iana Iatsun_ML in production_20Dec2022.pdf
Iana Iatsun_ML in production_20Dec2022.pdfIana Iatsun_ML in production_20Dec2022.pdf
Iana Iatsun_ML in production_20Dec2022.pdf
 
41 WiMLDS Kyiv Paris Poznan.pdf
41 WiMLDS Kyiv Paris Poznan.pdf41 WiMLDS Kyiv Paris Poznan.pdf
41 WiMLDS Kyiv Paris Poznan.pdf
 
Emergency plan to secure winter: what are the measures set up by RTE?
Emergency plan to secure winter: what are the measures set up by RTE?Emergency plan to secure winter: what are the measures set up by RTE?
Emergency plan to secure winter: what are the measures set up by RTE?
 
New edge prediction and anomaly-detection in large computer networks
New edge prediction and anomaly-detection in large computer networksNew edge prediction and anomaly-detection in large computer networks
New edge prediction and anomaly-detection in large computer networks
 
transformers_multimodal_ehr.pdf
transformers_multimodal_ehr.pdftransformers_multimodal_ehr.pdf
transformers_multimodal_ehr.pdf
 

Recently uploaded

Guardians and Glitches: Navigating the Duality of Gen AI in AppSec
Guardians and Glitches: Navigating the Duality of Gen AI in AppSecGuardians and Glitches: Navigating the Duality of Gen AI in AppSec
Guardians and Glitches: Navigating the Duality of Gen AI in AppSecTrupti Shiralkar, CISSP
 
ingles nivel 3 ucv 2024 - modulo 3 _ppt2
ingles nivel 3 ucv 2024 - modulo 3 _ppt2ingles nivel 3 ucv 2024 - modulo 3 _ppt2
ingles nivel 3 ucv 2024 - modulo 3 _ppt2nhuayllav
 
EPE3163_Hydro power stations_Unit2_Lect2.pptx
EPE3163_Hydro power stations_Unit2_Lect2.pptxEPE3163_Hydro power stations_Unit2_Lect2.pptx
EPE3163_Hydro power stations_Unit2_Lect2.pptxJoseeMusabyimana
 
Test of Significance of Large Samples for Mean = µ.pptx
Test of Significance of Large Samples for Mean = µ.pptxTest of Significance of Large Samples for Mean = µ.pptx
Test of Significance of Large Samples for Mean = µ.pptxHome
 
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....santhyamuthu1
 
Nodal seismic construction requirements.pptx
Nodal seismic construction requirements.pptxNodal seismic construction requirements.pptx
Nodal seismic construction requirements.pptxwendy cai
 
Modelling Guide for Timber Structures - FPInnovations
Modelling Guide for Timber Structures - FPInnovationsModelling Guide for Timber Structures - FPInnovations
Modelling Guide for Timber Structures - FPInnovationsYusuf Yıldız
 
Clutches and brkesSelect any 3 position random motion out of real world and d...
Clutches and brkesSelect any 3 position random motion out of real world and d...Clutches and brkesSelect any 3 position random motion out of real world and d...
Clutches and brkesSelect any 3 position random motion out of real world and d...sahb78428
 
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...amrabdallah9
 
Dev.bg DevOps March 2024 Monitoring & Logging
Dev.bg DevOps March 2024 Monitoring & LoggingDev.bg DevOps March 2024 Monitoring & Logging
Dev.bg DevOps March 2024 Monitoring & LoggingMarian Marinov
 
IT3401-WEB ESSENTIALS PRESENTATIONS.pptx
IT3401-WEB ESSENTIALS PRESENTATIONS.pptxIT3401-WEB ESSENTIALS PRESENTATIONS.pptx
IT3401-WEB ESSENTIALS PRESENTATIONS.pptxSAJITHABANUS
 
Popular-NO1 Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialis...
Popular-NO1 Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialis...Popular-NO1 Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialis...
Popular-NO1 Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialis...Amil baba
 
Lifting Plan | Lifting Plan for Different Process Equipment | Gaurav Singh Ra...
Lifting Plan | Lifting Plan for Different Process Equipment | Gaurav Singh Ra...Lifting Plan | Lifting Plan for Different Process Equipment | Gaurav Singh Ra...
Lifting Plan | Lifting Plan for Different Process Equipment | Gaurav Singh Ra...Gaurav Singh Rajput
 
Technology Features of Apollo HDD Machine, Its Technical Specification with C...
Technology Features of Apollo HDD Machine, Its Technical Specification with C...Technology Features of Apollo HDD Machine, Its Technical Specification with C...
Technology Features of Apollo HDD Machine, Its Technical Specification with C...Apollo Techno Industries Pvt Ltd
 
How to Write a Good Scientific Paper.pdf
How to Write a Good Scientific Paper.pdfHow to Write a Good Scientific Paper.pdf
How to Write a Good Scientific Paper.pdfRedhwan Qasem Shaddad
 
Lecture 1: Basics of trigonometry (surveying)
Lecture 1: Basics of trigonometry (surveying)Lecture 1: Basics of trigonometry (surveying)
Lecture 1: Basics of trigonometry (surveying)Bahzad5
 
Mohs Scale of Hardness, Hardness Scale.pptx
Mohs Scale of Hardness, Hardness Scale.pptxMohs Scale of Hardness, Hardness Scale.pptx
Mohs Scale of Hardness, Hardness Scale.pptxKISHAN KUMAR
 
A Seminar on Electric Vehicle Software Simulation
A Seminar on Electric Vehicle Software SimulationA Seminar on Electric Vehicle Software Simulation
A Seminar on Electric Vehicle Software SimulationMohsinKhanA
 

Recently uploaded (20)

Guardians and Glitches: Navigating the Duality of Gen AI in AppSec
Guardians and Glitches: Navigating the Duality of Gen AI in AppSecGuardians and Glitches: Navigating the Duality of Gen AI in AppSec
Guardians and Glitches: Navigating the Duality of Gen AI in AppSec
 
ingles nivel 3 ucv 2024 - modulo 3 _ppt2
ingles nivel 3 ucv 2024 - modulo 3 _ppt2ingles nivel 3 ucv 2024 - modulo 3 _ppt2
ingles nivel 3 ucv 2024 - modulo 3 _ppt2
 
EPE3163_Hydro power stations_Unit2_Lect2.pptx
EPE3163_Hydro power stations_Unit2_Lect2.pptxEPE3163_Hydro power stations_Unit2_Lect2.pptx
EPE3163_Hydro power stations_Unit2_Lect2.pptx
 
Test of Significance of Large Samples for Mean = µ.pptx
Test of Significance of Large Samples for Mean = µ.pptxTest of Significance of Large Samples for Mean = µ.pptx
Test of Significance of Large Samples for Mean = µ.pptx
 
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
 
Nodal seismic construction requirements.pptx
Nodal seismic construction requirements.pptxNodal seismic construction requirements.pptx
Nodal seismic construction requirements.pptx
 
Modelling Guide for Timber Structures - FPInnovations
Modelling Guide for Timber Structures - FPInnovationsModelling Guide for Timber Structures - FPInnovations
Modelling Guide for Timber Structures - FPInnovations
 
Clutches and brkesSelect any 3 position random motion out of real world and d...
Clutches and brkesSelect any 3 position random motion out of real world and d...Clutches and brkesSelect any 3 position random motion out of real world and d...
Clutches and brkesSelect any 3 position random motion out of real world and d...
 
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
 
Dev.bg DevOps March 2024 Monitoring & Logging
Dev.bg DevOps March 2024 Monitoring & LoggingDev.bg DevOps March 2024 Monitoring & Logging
Dev.bg DevOps March 2024 Monitoring & Logging
 
IT3401-WEB ESSENTIALS PRESENTATIONS.pptx
IT3401-WEB ESSENTIALS PRESENTATIONS.pptxIT3401-WEB ESSENTIALS PRESENTATIONS.pptx
IT3401-WEB ESSENTIALS PRESENTATIONS.pptx
 
Lecture 2 .pptx
Lecture 2                            .pptxLecture 2                            .pptx
Lecture 2 .pptx
 
Popular-NO1 Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialis...
Popular-NO1 Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialis...Popular-NO1 Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialis...
Popular-NO1 Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialis...
 
Lifting Plan | Lifting Plan for Different Process Equipment | Gaurav Singh Ra...
Lifting Plan | Lifting Plan for Different Process Equipment | Gaurav Singh Ra...Lifting Plan | Lifting Plan for Different Process Equipment | Gaurav Singh Ra...
Lifting Plan | Lifting Plan for Different Process Equipment | Gaurav Singh Ra...
 
Technology Features of Apollo HDD Machine, Its Technical Specification with C...
Technology Features of Apollo HDD Machine, Its Technical Specification with C...Technology Features of Apollo HDD Machine, Its Technical Specification with C...
Technology Features of Apollo HDD Machine, Its Technical Specification with C...
 
How to Write a Good Scientific Paper.pdf
How to Write a Good Scientific Paper.pdfHow to Write a Good Scientific Paper.pdf
How to Write a Good Scientific Paper.pdf
 
Lecture 1: Basics of trigonometry (surveying)
Lecture 1: Basics of trigonometry (surveying)Lecture 1: Basics of trigonometry (surveying)
Lecture 1: Basics of trigonometry (surveying)
 
Mohs Scale of Hardness, Hardness Scale.pptx
Mohs Scale of Hardness, Hardness Scale.pptxMohs Scale of Hardness, Hardness Scale.pptx
Mohs Scale of Hardness, Hardness Scale.pptx
 
Lecture 4 .pdf
Lecture 4                              .pdfLecture 4                              .pdf
Lecture 4 .pdf
 
A Seminar on Electric Vehicle Software Simulation
A Seminar on Electric Vehicle Software SimulationA Seminar on Electric Vehicle Software Simulation
A Seminar on Electric Vehicle Software Simulation
 

“Coding For Humans” by Paola Ducolin, Staff Engineer @ Dashlane

  • 1. CODING FOR HUMANS Paola Ducolin |WiMLDS Paris | 14 Mai 2020
  • 2. ABOUT MYSELF • 🙋 Paola Ducolin 🇮🇹 • 💻 Staff Engineer @ Dashlane • 👩💻 Ladies of Code Paris co-organizer • 🏳🌈 Paris QueerJS organizer • 👵 10+ years in software development • 🤦 8+ years with legacy code 2
  • 4. 4
  • 5. 17:00 CEST, MAY 16TH @ TWITCH.TV/QUEERJS 5
  • 8. 8
  • 10. 10
  • 11. 11
  • 12. WHAT ABOUT CODE? Coding for humans | @PolaDuco WiMLDS Paris | 14 mai 2020 12
  • 13. Coding for humans | @PolaDuco WiMLDS Paris | 14 mai 2020 13 bit.ly/QueerInTechPhotos
  • 14. LEGACY CODE IMPACT ON MY FEELINGS 14
  • 15. Coding life Reading Writing Source: Robert C. Martin 15
  • 16. 16
  • 17. All code becomes legacy code 17 eventually
  • 18. 18
  • 19. 1. WRITING READABLE CODE 2. WRITING HUMAN DOCUMENTATION 19
  • 20. Coding life Reading Writing Source: Robert C. Martin 20
  • 22. EXAMPLES - NAMING 22 https://bit.ly/coding-for-humans class Rectangle { constructor(w, h) { this.w = w; this.h = h; } calcA() { return this.w * this.h; } }
  • 23. EXAMPLES - NAMING 23 https://bit.ly/coding-for-humans class Rectangle { constructor(width, height) { this.width = width; this.height = height; } calculateArea() { return this.width * this.height; } }
  • 24. EXAMPLES – NAMING 2 24 https://bit.ly/coding-for-humans const LETTERS = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"; const CHARS = LETTERS + "1234567890!@#$%^&*()_-+=[]{}|/?><.,;:";
  • 25. EXAMPLES – NAMING 2 25 https://bit.ly/coding-for-humans const LETTERS = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"; const LETTERS_DIGITS_SYMBOLS = LETTERS + "1234567890!@#$%^&*()_-+=[]{}|/?><.,;:";
  • 26. HUMAN CODE 26 Use semantically meaning names Prevent reading inner code
  • 27. EXAMPLES – INNER CODE 27 https://bit.ly/coding-for-humans var rectangle = new Rectangle(3, 5); rectangle.increaseSize(0.3); class Rectangle { constructor(width, height) { this.width = width; this.height = height; } increaseSize(percentage) { this.width *= percentage; this.height *= percentage; } }
  • 28. EXAMPLES – INNER CODE 28 https://bit.ly/coding-for-humans var rectangle = new Rectangle(3, 5); rectangle.scaleWidthAndHeightByFactor(0.3); class Rectangle { constructor(width, height) { this.width = width; this.height = height; } scaleWidthAndHeightByFactor(percentage) { this.width *= percentage; this.height *= percentage; } }
  • 29. EXAMPLES – INNER CODE 29 // This is a comment
  • 30. HUMAN CODE 30 Use semantically meaning names Prevent reading inner code Do one thing Minimize function length
  • 31. EXAMPLES – MINIMIZE LENGTH 31 https://bit.ly/coding-for-humans function Adjust(rectangle) { rectangle.Size = Size.S; rectangle.HasError = false; rectangle.IsSquare = false; if (rectangle.Width >= 10000) rectangle.Size = Size.L; if (rectangle.Height <= 100) rectangle.HasError = true; if (rectangle.Width === rectangle.Height) rectangle.IsSquare = true; if (rectangle.Width >= 20000) rectangle.Size = Size.XL; if (rectangle.Height <= 200) rectangle.Size = Size.M; if (rectangle.Width <= 300) rectangle.HasError = true; }
  • 32. EXAMPLES – MINIMIZE LENGTH 32 https://bit.ly/coding-for-humans import fc from "fast-check"; function test() { fc.assert( fc.property(fc.integer(0, 30000), fc.integer(0, 30000), (width, height) => { let rectangle = { TotalPurchases: totalPurchases, RecentOrders: recentOrders, LovesJavaScript: lovesJavaScript, KnowsCobol: knowsCobol, }; let rectangle_expected = JSON.parse(JSON.stringify(rectangle)); Adjust(rectangle_expected); Adjust_new(rectangle); expect(rectangle.Size).toBe(rectangle_expe cted.Size); expect(rectangle.HasError).toBe(rectangle_ expected.HasError); expect(rectangle.IsSquare).toBe(rectangle_ expected.IsSquare); }) ); }
  • 33. EXAMPLES – MINIMIZE LENGTH 33 https://bit.ly/coding-for-humans function Adjust(rectangle) { rectangle.Size = Size.S; rectangle.HasError = false; rectangle.IsSquare = false; if (rectangle.Width >= 10000) rectangle.Size = Size.L; if (rectangle.Height <= 100) rectangle.HasError = true; if (rectangle.Width === rectangle.Height) rectangle.IsSquare = true; if (rectangle.Width >= 20000) rectangle.Size = Size.XL; if (rectangle.Height <= 200) rectangle.Size = Size.M; if (rectangle.Width <= 300) rectangle.HasError = true; }
  • 34. EXAMPLES – MINIMIZE LENGTH 34 https://bit.ly/coding-for-humans function AdjustSize(rectangle) { if (rectangle.Height <= 200) rectangle.Size = Size.M; else if (rectangle.Width >= 20000) rectangle.Size = Size.XL; else if (rectangle.Width >= 10000) rectangle.Size = Size.L; else rectangle.Size = Size.S; }
  • 35. EXAMPLES – MINIMIZE LENGTH 35 https://bit.ly/coding-for-humans function Adjust(rectangle) { rectangle.Size = Size.S; rectangle.HasError = false; rectangle.IsSquare = false; if (rectangle.Width >= 10000) rectangle.Size = Size.L; if (rectangle.Height <= 100) rectangle.HasError = true; if (rectangle.Width === rectangle.Height) rectangle.IsSquare = true; if (rectangle.Width >= 20000) rectangle.Size = Size.XL; if (rectangle.Height <= 200) rectangle.Size = Size.M; if (rectangle.Width <= 300) rectangle.HasError = true; }
  • 36. EXAMPLES – MINIMIZE LENGTH 36 https://bit.ly/coding-for-humans function AdjustHasError(rectangle) { if (rectangle.Height <= 100 || rectangle.Width <= 300) rectangle.HasError = true; else rectangle.HasError = false; }
  • 37. EXAMPLES – MINIMIZE LENGTH 37 https://bit.ly/coding-for-humans function AdjustIsSquare(rectangle) { if (rectangle.Width === rectangle.Height) rectangle.IsSquare = true; else rectangle.IsSquare = false; }
  • 38. EXAMPLES – MINIMIZE LENGTH 38 https://bit.ly/coding-for-humans function Adjust_new(rectangle) { AdjustSize(rectangle); AdjustHasError(rectangle); AdjustIsSquare(rectangle); }
  • 39. HUMAN CODE 39 Use semantically meaning names Prevent reading inner code Do one thing Minimize function length Top-down narrative
  • 40. EXAMPLES – TOP DOWN NARRATIVE 40 https://bit.ly/coding-for-humans class Rectangle { // helper functions BEGIN #scaleWidthByFactor(scalingFactor) { this.width *= scalingFactor; } #scaleHeightByFactor(scalingFactor) { this.height *= scalingFactor; } // helper functions END // frequently used functions BEGIN ScaleWidthAndHeightByFactor(scalingFactor) { this.#scaleWidthByFactor(scalingFactor); this.#scaleHeightByFactor(scalingFactor); } // frequently used functions END }
  • 41. EXAMPLES – TOP DOWN NARRATIVE 41 https://bit.ly/coding-for-humans class Rectangle { // scaling functions BEGIN ScaleWidthAndHeightByFactor(scalingFactor) { this.#scaleWidthByFactor(scalingFactor); this.#scaleHeightByFactor(scalingFactor); } #scaleWidthByFactor(scalingFactor) { this.width *= scalingFactor; } #scaleHeightByFactor(scalingFactor) { this.height *= scalingFactor; } // scaling functions END }
  • 42. HUMAN CODE 42 Use semantically meaning names Prevent reading inner code Do one thing Minimize function length Top-down narrative Review with the team Use refactoring tools
  • 43. 43
  • 44. USE EMPATHY WHILE READING CODE 44 https://bit.ly/romeu-moura
  • 45. 1. WRITING READABLE CODE 2. WRITING HUMAN DOCUMENTATION 45
  • 47. HUMAN DOCUMENTATION • Use inclusive and clear language 47
  • 49. bit.ly/write-good ENSURE INCLUSIVE AND CLEAR LANGUAGE 49 Wow! Congratulations to Greg Gutfeld, a one time Trump Hater who has come all the way home. His Ratings easily beat no talent Stephen Colbert, nice guy Jimmy Fallon, and wacko “last placer” Jimmy Kimmel. Greg built his show from scratch, and did a great job in doing so. Well run States should not be bailing out poorly run States, using CoronaVirus as the excuse! The elimination of Sanctuary Cities, Payroll Taxes, and perhaps Capital Gains Taxes, must be put on the table. Also lawsuit indemnification & business deductions for restaurants & ent. Most of the money raised by the RINO losers of the so-called “Lincoln Project”, goes into their own pockets. With what I’ve done on Judges, Taxes, Regulations, Healthcare, the Military, Vets (Choice!) & protecting our great 2A, they should love Trump. Problem is, I BEAT THEM ALL! ============= he way home. His Ratings easily beat no talent Stephen Colbert, nice guy Jimmy F ^^^^^^ "easily" can weaken meaning on line 1 at column 104 ------------- hould not be bailing out poorly run States, using CoronaVirus as the excuse! The ^^^^^^ "poorly" can weaken meaning on line 3 at column 42 ------------- apital GainsTaxes, must be put on the table.Also lawsuit indemnification & bus ^^^^^^ "be put" may be passive voice on line 3 at column 184
  • 50. ENSURE INCLUSIVE AND CLEAR LANGUAGE 50 bit.ly/hemingwayapp
  • 51. HUMAN DOCUMENTATION • Use inclusive and clear language • Ensure visibility 51
  • 52. Roads for Success Navigating Docs – Kyle Gillbit.ly/roads-docs THINK TWICE ABOUT NAVIGATION 52
  • 53. THINK TWICE ABOUT NAVIGATION 53
  • 56. THINK TWICE ABOUT NAVIGATION 56 bit.ly/dashlane-ds
  • 57. HUMAN DOCUMENTATION • Use inclusive and clear language • Ensure visibility • Update it 57