SlideShare uma empresa Scribd logo
1 de 60
Baixar para ler 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

Mais conteúdo relacionado

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

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

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
 
Testing, Learning and Professionalism — 20171214
Testing, Learning and Professionalism — 20171214Testing, Learning and Professionalism — 20171214
Testing, Learning and Professionalism — 20171214
 

Mais de Paris Women in Machine Learning and Data Science

Mais de Paris Women in Machine Learning and Data Science (20)

Sequential and reinforcement learning for demand side management by Margaux B...
Sequential and reinforcement learning for demand side management by Margaux B...Sequential and reinforcement learning for demand side management by Margaux B...
Sequential and reinforcement learning for demand side management by Margaux B...
 
How and why AI should fight cybersexism, by Chloe Daudier
How and why AI should fight cybersexism, by Chloe DaudierHow and why AI should fight cybersexism, by Chloe Daudier
How and why AI should fight cybersexism, by Chloe Daudier
 
Anomaly detection and data imputation within time series
Anomaly detection and data imputation within time seriesAnomaly detection and data imputation within time series
Anomaly detection and data imputation within time series
 
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
 
Applying Churn Prediction Approaches to the Telecom Industry, by Joëlle Lautré
Applying Churn Prediction Approaches to the Telecom Industry, by Joëlle LautréApplying Churn Prediction Approaches to the Telecom Industry, by Joëlle Lautré
Applying Churn Prediction Approaches to the Telecom Industry, by Joëlle Lautré
 
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
 
“Turning your ML algorithms into full web apps in no time with Python" by Mar...
“Turning your ML algorithms into full web apps in no time with Python" by Mar...“Turning your ML algorithms into full web apps in no time with Python" by Mar...
“Turning your ML algorithms into full web apps in no time with Python" by Mar...
 
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
 

Último

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 

Último (20)

Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 

“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