Writing code you won't hate tomorrow

Rafael Dohms
Rafael DohmsLead Backend Engineer at Usabilla
Writing code 
that lasts. 
Rafael Dohms 
@rdohms 
photo: djandyw.com
Writing code 
you won’t hate tomorrow. 
Rafael Dohms 
@rdohms 
photo: djandyw.com
Let me 
introduce 
you to 
someone…
Writing code you won't hate tomorrow
Writing code you won't hate tomorrow
No Tests. 
shhh.. don’t tell Grumpy. 
Wrote his own framework. 
.. and used it. 
Used Singletons! 
.. and every other anti-pattern out there. 
500 line methods. 
… not even methods, they were functions
photo: Rob Allen (@akrabat)
Writing code you won't hate tomorrow
REWRITE 
ALL THE CODE!
photo: Glyn Lowe Photoworks 
Real Developers, 
SHIP STUFF.
Writing code you won't hate tomorrow
Writing code you won't hate tomorrow
Writing code you won't hate tomorrow
How do we find 
balance? 
photo: Kalexanderson
Code has an 
expiration date 
photo: CarbonNYC
Code is 
photo by: massdistraction 
perishable, it rots.
Code Evolves 
photo by: kevin dooley
Languages evolve. 
photo by: raneko
You evolve. 
photo by: Kaptain Kobold
Complexity 
kills 
Comprehension 
photo: osbornb
Bad Design 
photo: miskan
Bad specs
NIH 
photo by: John 'K' 
source: Urban dictionary
NIH 
| nɒt ɪnˈventɪd hɪə | 
Not Invented Here —The German art of humiliating any technology, 
agricultural product, or (medical) scientific work that has not been 
invented or produced in Germany, Switzerland, or Austria. 
photo by: John 'K' 
source: Urban dictionary
The Solution™ 
photo: Ian Sane
Improve code
make it easier to comprehend 
Improve code
make it easier to comprehend 
make it flexible 
Improve code
make it easier to comprehend 
make it flexible 
make it tested 
Improve code
make it easier to comprehend 
make it flexible 
make it tested 
Improve code 
make it easier to replace, refactor
make it easier to comprehend 
make it flexible 
make it tested 
Improve code 
make it easier to replace, refactor 
make it not exist
Testing 
photo by: jeffkrause
Good Design 
Concepts
SOLID 
Single Responsibility 
Open and Close 
Liskov substitution 
Interface Segregation 
Dependency Inversion 
photo by j_regan
photo by lofink 
STUPID 
Singleton 
Tight Coupling 
Untestability 
Premature Optimization 
Indescriptive Naming 
Duplication
photo by halloweenstock 
Design Patterns
Composer
PIE 
Proudly 
Invented 
Elsewhere
guzzle/guzzle 
HTTP client for RESTful API clients 
photo by j_regan
morrisonlevi/ardent 
A library of collections for PHP
Readability 
photo: Morgenland
paragraphs 
photo: Trossachs Photography
whitespace
Writing code you won't hate tomorrow
Cape Town São Paulo 
R&D Team for MIH/Naspers
Object 
Calisthenics 
photo by: boston_public_library
Calisthenics 
/ˌkaləsˈTHeniks/ 
Calisthenics are a form of dynamic exercise consisting of a variety of 
simple, often rhythmical, movements, generally using minimal 
equipment or apparatus. 
photo by: boston_public_library
Its about perception, 
not rules or standards photo by: david_a_l
#1 
Only one 
indentation level 
per method. 
photo by: justinliew
#2 
Do not 
use else 
photo by: justinliew
Writing code you won't hate tomorrow
Writing code you won't hate tomorrow
Writing code you won't hate tomorrow
#3 
Wrap primitive 
types, if they 
contain behavior 
photo by: justinliew
#4 
Only one 
-> per line 
photo by: justinliew
#5 
Do not 
abbreviate. 
photo by: justinliew
#6 
Keep your 
classes small. 
photo by: justinliew
#7 
Limit your 
instance variables 
to less then 5 
photo by: justinliew
#8 
Use first class 
collections 
photo by: justinliew
#9 
Use getters 
and setters. 
photo by: justinliew
#10 
Document 
your code. 
photo by: justinliew
Your turn.
Improve 
yourself!
Read lots of 
code!
Write simple 
code.
Try Object Calisthenics 
for a month.
Use someone 
else’s code.
Share bite size 
libraries.
Thank you. 
@rdohms 
https://joind.in/12734 
http://doh.ms 
http://slides.doh.ms 
please rate me!
http://l.doh.ms/oc-links 
Video recording 
Slides 
Books 
Resources on 
Object Calisthenics
1 of 70

Recommended

“Writing code that lasts” … or writing code you won’t hate tomorrow. by
“Writing code that lasts” … or writing code you won’t hate tomorrow.“Writing code that lasts” … or writing code you won’t hate tomorrow.
“Writing code that lasts” … or writing code you won’t hate tomorrow.Rafael Dohms
3.4K views70 slides
Writing code that lasts - JAB14 by
Writing code that lasts - JAB14Writing code that lasts - JAB14
Writing code that lasts - JAB14Rafael Dohms
24.8K views69 slides
“Writing code that lasts” … or writing code you won’t hate tomorrow. by
“Writing code that lasts” … or writing code you won’t hate tomorrow.“Writing code that lasts” … or writing code you won’t hate tomorrow.
“Writing code that lasts” … or writing code you won’t hate tomorrow.Rafael Dohms
2.8K views74 slides
“Writing code that lasts” … or writing code you won’t hate tomorrow. by
“Writing code that lasts” … or writing code you won’t hate tomorrow.“Writing code that lasts” … or writing code you won’t hate tomorrow.
“Writing code that lasts” … or writing code you won’t hate tomorrow.Rafael Dohms
2.5K views77 slides
“Writing code that lasts” … or writing code you won’t hate tomorrow. - #PHPSRB16 by
“Writing code that lasts” … or writing code you won’t hate tomorrow. - #PHPSRB16“Writing code that lasts” … or writing code you won’t hate tomorrow. - #PHPSRB16
“Writing code that lasts” … or writing code you won’t hate tomorrow. - #PHPSRB16Rafael Dohms
1.4K views75 slides
Writing Code That Lasts - #Magento2Seminar, Utrecht by
Writing Code That Lasts - #Magento2Seminar, UtrechtWriting Code That Lasts - #Magento2Seminar, Utrecht
Writing Code That Lasts - #Magento2Seminar, UtrechtRafael Dohms
976 views62 slides

More Related Content

More from Rafael Dohms

Application Metrics - IPC2023 by
Application Metrics - IPC2023Application Metrics - IPC2023
Application Metrics - IPC2023Rafael Dohms
7 views87 slides
How'd we get here? A guide to Architectural Decision Records by
How'd we get here? A guide to Architectural Decision RecordsHow'd we get here? A guide to Architectural Decision Records
How'd we get here? A guide to Architectural Decision RecordsRafael Dohms
306 views42 slides
Architectural Decision Records - PHPConfBR by
Architectural Decision Records - PHPConfBRArchitectural Decision Records - PHPConfBR
Architectural Decision Records - PHPConfBRRafael Dohms
299 views42 slides
Application Metrics (with Prometheus examples) by
Application Metrics (with Prometheus examples)Application Metrics (with Prometheus examples)
Application Metrics (with Prometheus examples)Rafael Dohms
998 views89 slides
Application metrics - Confoo 2019 by
Application metrics - Confoo 2019Application metrics - Confoo 2019
Application metrics - Confoo 2019Rafael Dohms
747 views90 slides
Writing code you won’t hate tomorrow - PHPCE18 by
Writing code you won’t hate tomorrow - PHPCE18Writing code you won’t hate tomorrow - PHPCE18
Writing code you won’t hate tomorrow - PHPCE18Rafael Dohms
1.2K views86 slides

More from Rafael Dohms(20)

Application Metrics - IPC2023 by Rafael Dohms
Application Metrics - IPC2023Application Metrics - IPC2023
Application Metrics - IPC2023
Rafael Dohms7 views
How'd we get here? A guide to Architectural Decision Records by Rafael Dohms
How'd we get here? A guide to Architectural Decision RecordsHow'd we get here? A guide to Architectural Decision Records
How'd we get here? A guide to Architectural Decision Records
Rafael Dohms306 views
Architectural Decision Records - PHPConfBR by Rafael Dohms
Architectural Decision Records - PHPConfBRArchitectural Decision Records - PHPConfBR
Architectural Decision Records - PHPConfBR
Rafael Dohms299 views
Application Metrics (with Prometheus examples) by Rafael Dohms
Application Metrics (with Prometheus examples)Application Metrics (with Prometheus examples)
Application Metrics (with Prometheus examples)
Rafael Dohms998 views
Application metrics - Confoo 2019 by Rafael Dohms
Application metrics - Confoo 2019Application metrics - Confoo 2019
Application metrics - Confoo 2019
Rafael Dohms747 views
Writing code you won’t hate tomorrow - PHPCE18 by Rafael Dohms
Writing code you won’t hate tomorrow - PHPCE18Writing code you won’t hate tomorrow - PHPCE18
Writing code you won’t hate tomorrow - PHPCE18
Rafael Dohms1.2K views
Application Metrics (with Prometheus examples) #PHPDD18 by Rafael Dohms
Application Metrics (with Prometheus examples) #PHPDD18Application Metrics (with Prometheus examples) #PHPDD18
Application Metrics (with Prometheus examples) #PHPDD18
Rafael Dohms757 views
Application metrics with Prometheus - DPC18 by Rafael Dohms
Application metrics with Prometheus - DPC18Application metrics with Prometheus - DPC18
Application metrics with Prometheus - DPC18
Rafael Dohms1.3K views
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf by Rafael Dohms
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
Rafael Dohms3.9K views
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo... by Rafael Dohms
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
Rafael Dohms1.4K views
Composer The Right Way - 010PHP by Rafael Dohms
Composer The Right Way - 010PHPComposer The Right Way - 010PHP
Composer The Right Way - 010PHP
Rafael Dohms3.5K views
Composer the Right Way - PHPSRB16 by Rafael Dohms
Composer the Right Way - PHPSRB16Composer the Right Way - PHPSRB16
Composer the Right Way - PHPSRB16
Rafael Dohms3.9K views
Composer the Right Way - MM16NL by Rafael Dohms
Composer the Right Way - MM16NLComposer the Right Way - MM16NL
Composer the Right Way - MM16NL
Rafael Dohms1.1K views
Composer The Right Way - PHPUGMRN by Rafael Dohms
Composer The Right Way - PHPUGMRNComposer The Right Way - PHPUGMRN
Composer The Right Way - PHPUGMRN
Rafael Dohms1.4K views
Composer the Right Way - PHPBNL16 by Rafael Dohms
Composer the Right Way - PHPBNL16Composer the Right Way - PHPBNL16
Composer the Right Way - PHPBNL16
Rafael Dohms2.6K views
A Journey into your Lizard Brain - PHP Conference Brasil 2015 by Rafael Dohms
A Journey into your Lizard Brain - PHP Conference Brasil 2015A Journey into your Lizard Brain - PHP Conference Brasil 2015
A Journey into your Lizard Brain - PHP Conference Brasil 2015
Rafael Dohms2.2K views
Journey into your Lizard Brain - PHPJHB15 by Rafael Dohms
Journey into your Lizard Brain - PHPJHB15Journey into your Lizard Brain - PHPJHB15
Journey into your Lizard Brain - PHPJHB15
Rafael Dohms12.7K views
Composer The Right Way #PHPjhb15 by Rafael Dohms
Composer The Right Way #PHPjhb15Composer The Right Way #PHPjhb15
Composer The Right Way #PHPjhb15
Rafael Dohms1.4K views
Composer the right way - DPC15 by Rafael Dohms
Composer the right way - DPC15Composer the right way - DPC15
Composer the right way - DPC15
Rafael Dohms1.5K views
A journey into your Lizard Brain by Rafael Dohms
A journey into your Lizard BrainA journey into your Lizard Brain
A journey into your Lizard Brain
Rafael Dohms1.5K views

Recently uploaded

Update 42 models(Diode/General ) in SPICE PARK(DEC2023) by
Update 42 models(Diode/General ) in SPICE PARK(DEC2023)Update 42 models(Diode/General ) in SPICE PARK(DEC2023)
Update 42 models(Diode/General ) in SPICE PARK(DEC2023)Tsuyoshi Horigome
33 views16 slides
Investor Presentation by
Investor PresentationInvestor Presentation
Investor Presentationeser sevinç
25 views26 slides
fakenews_DBDA_Mar23.pptx by
fakenews_DBDA_Mar23.pptxfakenews_DBDA_Mar23.pptx
fakenews_DBDA_Mar23.pptxdeepmitra8
15 views34 slides
Codes and Conventions.pptx by
Codes and Conventions.pptxCodes and Conventions.pptx
Codes and Conventions.pptxIsabellaGraceAnkers
9 views5 slides
Pull down shoulder press final report docx (1).pdf by
Pull down shoulder press final report docx (1).pdfPull down shoulder press final report docx (1).pdf
Pull down shoulder press final report docx (1).pdfComsat Universal Islamabad Wah Campus
17 views25 slides

Recently uploaded(20)

Update 42 models(Diode/General ) in SPICE PARK(DEC2023) by Tsuyoshi Horigome
Update 42 models(Diode/General ) in SPICE PARK(DEC2023)Update 42 models(Diode/General ) in SPICE PARK(DEC2023)
Update 42 models(Diode/General ) in SPICE PARK(DEC2023)
fakenews_DBDA_Mar23.pptx by deepmitra8
fakenews_DBDA_Mar23.pptxfakenews_DBDA_Mar23.pptx
fakenews_DBDA_Mar23.pptx
deepmitra815 views
_MAKRIADI-FOTEINI_diploma thesis.pptx by fotinimakriadi
_MAKRIADI-FOTEINI_diploma thesis.pptx_MAKRIADI-FOTEINI_diploma thesis.pptx
_MAKRIADI-FOTEINI_diploma thesis.pptx
fotinimakriadi8 views
Introduction to CAD-CAM.pptx by suyogpatil49
Introduction to CAD-CAM.pptxIntroduction to CAD-CAM.pptx
Introduction to CAD-CAM.pptx
suyogpatil495 views
Control Systems Feedback.pdf by LGGaming5
Control Systems Feedback.pdfControl Systems Feedback.pdf
Control Systems Feedback.pdf
LGGaming56 views
SUMIT SQL PROJECT SUPERSTORE 1.pptx by Sumit Jadhav
SUMIT SQL PROJECT SUPERSTORE 1.pptxSUMIT SQL PROJECT SUPERSTORE 1.pptx
SUMIT SQL PROJECT SUPERSTORE 1.pptx
Sumit Jadhav 15 views
Generative AI Models & Their Applications by SN
Generative AI Models & Their ApplicationsGenerative AI Models & Their Applications
Generative AI Models & Their Applications
SN8 views
MSA Website Slideshow (16).pdf by msaucla
MSA Website Slideshow (16).pdfMSA Website Slideshow (16).pdf
MSA Website Slideshow (16).pdf
msaucla76 views
Instrumentation & Control Lab Manual.pdf by NTU Faisalabad
Instrumentation & Control Lab Manual.pdfInstrumentation & Control Lab Manual.pdf
Instrumentation & Control Lab Manual.pdf
NTU Faisalabad 6 views

Writing code you won't hate tomorrow