“Writing code that lasts” … or 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
#ocforphp
Writing code 

you won’t hate tomorrow.
Rafael Dohms

@rdohms
photo: djandyw.com
#ocforphp
Rafael Dohms
or @rdohms on twitter
Developer
Herder
at AmsterdamPHP
Lead Backend
Developer
at Symbid
Let me
tell you about
someone else…
“Writing code that lasts” … or writing code you won’t hate tomorrow.
“Writing code that lasts” … or writing code you won’t hate tomorrow.
No Tests.
Wrote his own framework.
500 line methods.
Used Singletons!
shhh.. don’t tell Grumpy.
.. and used it.
.. and every other anti-pattern out there.
… not even methods, they were functions
photo: Rob Allen (@akrabat)
“Writing code that lasts” … or writing code you won’t hate tomorrow.
REWRITE
ALL THE CODE!
image: hyperboleandahalf
Real Developers,
SHIP STUFF.
photo: Glyn Lowe Photoworks
“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.
How do we find
balance?
photo: Kalexanderson
Code has an
expiration date
photo: CarbonNYC
Code is
perishable, it rots.
photo by: massdistraction
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
source: Urban dictionary
photo by: John 'K'
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.
source: Urban dictionary
photo by: John 'K'
The Solution™
photo: Ian Sane
Improve code
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
make it easier to replace, refactor
Improve code
make it easier to comprehend
make it flexible
make it tested
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
Design Patterns
photo by halloweenstock
Package
Managers
photo by cocoachuchu.etsy.com
PIE
Proudly

Invented

Elsewhere
Readability
photo: Morgenland
paragraphs
photo: Trossachs Photography
whitespace
“Writing code that lasts” … or writing code you won’t hate tomorrow.
R&D Team for MIH/Naspers
São Paulo
Cape Town
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 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.
#3
Wrap primitive
types, if they
contain behavior
photo by: justinliew
$component->repaint(false);
$component->repaint( new Animate(false) );
#4
Only one 

-> per line
photo by: justinliew
#5
Do not
abbreviate.
photo by: justinliew
if($sx >= $sy) {
if ($sx > $strSysMatImgW) {
$ny = $strSysMatImgW * $sy / $sx;
$nx = $strSysMatImgW;
}
if ($ny > $strSysMatImgH) {
$nx = $strSysMatImgH * $sx / $sy;
$ny = $strSysMatImgH;
}
}
#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
Don’t 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.
http://slides.doh.ms
http://doh.ms
@rdohms
we are hiring!
http://careers.symbid.com
http://l.doh.ms/oc-material
Video recording
Slides
Books
Resources on 

Object Calisthenics
1 of 74

Recommended

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
3.4K views70 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 you won't hate tomorrow by
Writing code you won't hate tomorrowWriting code you won't hate tomorrow
Writing code you won't hate tomorrowRafael Dohms
47.2K views69 slides
Writing Code That Lasts - Joomla!Dagen 2015 by
Writing Code That Lasts - Joomla!Dagen 2015Writing Code That Lasts - Joomla!Dagen 2015
Writing Code That Lasts - Joomla!Dagen 2015Rafael Dohms
31.6K views70 slides

More Related Content

What's hot

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
Failure as Success Devops Roadtrip Seattle 2016 by
Failure as Success Devops Roadtrip Seattle 2016Failure as Success Devops Roadtrip Seattle 2016
Failure as Success Devops Roadtrip Seattle 2016VictorOps
2.2K views58 slides
Continuous Integration: Blueprint, Toolbox, Master Craft by
Continuous Integration: Blueprint, Toolbox, Master CraftContinuous Integration: Blueprint, Toolbox, Master Craft
Continuous Integration: Blueprint, Toolbox, Master CraftStephen Ritchie
7.6K views22 slides
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD) by
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)Dimitar Danailov
477 views51 slides
MSR2014 - An Empirical Study of Dormant Bugs by
MSR2014 - An Empirical Study of Dormant BugsMSR2014 - An Empirical Study of Dormant Bugs
MSR2014 - An Empirical Study of Dormant BugsConcordia University
533 views24 slides
How to use github to evaluate developers by
How to use github to evaluate developersHow to use github to evaluate developers
How to use github to evaluate developersTimo Rößner
1.7K views31 slides

What's hot(6)

Writing Code That Lasts - #Magento2Seminar, Utrecht by Rafael Dohms
Writing Code That Lasts - #Magento2Seminar, UtrechtWriting Code That Lasts - #Magento2Seminar, Utrecht
Writing Code That Lasts - #Magento2Seminar, Utrecht
Rafael Dohms976 views
Failure as Success Devops Roadtrip Seattle 2016 by VictorOps
Failure as Success Devops Roadtrip Seattle 2016Failure as Success Devops Roadtrip Seattle 2016
Failure as Success Devops Roadtrip Seattle 2016
VictorOps2.2K views
Continuous Integration: Blueprint, Toolbox, Master Craft by Stephen Ritchie
Continuous Integration: Blueprint, Toolbox, Master CraftContinuous Integration: Blueprint, Toolbox, Master Craft
Continuous Integration: Blueprint, Toolbox, Master Craft
Stephen Ritchie7.6K views
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD) by Dimitar Danailov
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
Dimitar Danailov477 views
How to use github to evaluate developers by Timo Rößner
How to use github to evaluate developersHow to use github to evaluate developers
How to use github to evaluate developers
Timo Rößner1.7K views

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

AI: mind, matter, meaning, metaphors, being, becoming, life values by
AI: mind, matter, meaning, metaphors, being, becoming, life valuesAI: mind, matter, meaning, metaphors, being, becoming, life values
AI: mind, matter, meaning, metaphors, being, becoming, life valuesTwain Liu 刘秋艳
34 views16 slides
"Ukrainian Mobile Banking Scaling in Practice. From 0 to 100 and beyond", Vad... by
"Ukrainian Mobile Banking Scaling in Practice. From 0 to 100 and beyond", Vad..."Ukrainian Mobile Banking Scaling in Practice. From 0 to 100 and beyond", Vad...
"Ukrainian Mobile Banking Scaling in Practice. From 0 to 100 and beyond", Vad...Fwdays
40 views30 slides
Java Platform Approach 1.0 - Picnic Meetup by
Java Platform Approach 1.0 - Picnic MeetupJava Platform Approach 1.0 - Picnic Meetup
Java Platform Approach 1.0 - Picnic MeetupRick Ossendrijver
25 views39 slides
Future of Learning - Khoong Chan Meng by
Future of Learning - Khoong Chan MengFuture of Learning - Khoong Chan Meng
Future of Learning - Khoong Chan MengNUS-ISS
31 views7 slides
Liqid: Composable CXL Preview by
Liqid: Composable CXL PreviewLiqid: Composable CXL Preview
Liqid: Composable CXL PreviewCXL Forum
121 views8 slides
CXL at OCP by
CXL at OCPCXL at OCP
CXL at OCPCXL Forum
208 views66 slides

Recently uploaded(20)

AI: mind, matter, meaning, metaphors, being, becoming, life values by Twain Liu 刘秋艳
AI: mind, matter, meaning, metaphors, being, becoming, life valuesAI: mind, matter, meaning, metaphors, being, becoming, life values
AI: mind, matter, meaning, metaphors, being, becoming, life values
"Ukrainian Mobile Banking Scaling in Practice. From 0 to 100 and beyond", Vad... by Fwdays
"Ukrainian Mobile Banking Scaling in Practice. From 0 to 100 and beyond", Vad..."Ukrainian Mobile Banking Scaling in Practice. From 0 to 100 and beyond", Vad...
"Ukrainian Mobile Banking Scaling in Practice. From 0 to 100 and beyond", Vad...
Fwdays40 views
Future of Learning - Khoong Chan Meng by NUS-ISS
Future of Learning - Khoong Chan MengFuture of Learning - Khoong Chan Meng
Future of Learning - Khoong Chan Meng
NUS-ISS31 views
Liqid: Composable CXL Preview by CXL Forum
Liqid: Composable CXL PreviewLiqid: Composable CXL Preview
Liqid: Composable CXL Preview
CXL Forum121 views
CXL at OCP by CXL Forum
CXL at OCPCXL at OCP
CXL at OCP
CXL Forum208 views
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV by Splunk
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
Splunk86 views
Five Things You SHOULD Know About Postman by Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman25 views
Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum... by NUS-ISS
Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum...Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum...
Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum...
NUS-ISS28 views
Future of Learning - Yap Aye Wee.pdf by NUS-ISS
Future of Learning - Yap Aye Wee.pdfFuture of Learning - Yap Aye Wee.pdf
Future of Learning - Yap Aye Wee.pdf
NUS-ISS38 views
Micron CXL product and architecture update by CXL Forum
Micron CXL product and architecture updateMicron CXL product and architecture update
Micron CXL product and architecture update
CXL Forum27 views
Empathic Computing: Delivering the Potential of the Metaverse by Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst449 views
MemVerge: Past Present and Future of CXL by CXL Forum
MemVerge: Past Present and Future of CXLMemVerge: Past Present and Future of CXL
MemVerge: Past Present and Future of CXL
CXL Forum110 views
AMD: 4th Generation EPYC CXL Demo by CXL Forum
AMD: 4th Generation EPYC CXL DemoAMD: 4th Generation EPYC CXL Demo
AMD: 4th Generation EPYC CXL Demo
CXL Forum126 views
"How we switched to Kanban and how it integrates with product planning", Vady... by Fwdays
"How we switched to Kanban and how it integrates with product planning", Vady..."How we switched to Kanban and how it integrates with product planning", Vady...
"How we switched to Kanban and how it integrates with product planning", Vady...
Fwdays61 views
"Thriving Culture in a Product Company — Practical Story", Volodymyr Tsukur by Fwdays
"Thriving Culture in a Product Company — Practical Story", Volodymyr Tsukur"Thriving Culture in a Product Company — Practical Story", Volodymyr Tsukur
"Thriving Culture in a Product Company — Practical Story", Volodymyr Tsukur
Fwdays40 views
Samsung: CMM-H Tiered Memory Solution with Built-in DRAM by CXL Forum
Samsung: CMM-H Tiered Memory Solution with Built-in DRAMSamsung: CMM-H Tiered Memory Solution with Built-in DRAM
Samsung: CMM-H Tiered Memory Solution with Built-in DRAM
CXL Forum105 views
[2023] Putting the R! in R&D.pdf by Eleanor McHugh
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf
Eleanor McHugh38 views
MemVerge: Memory Viewer Software by CXL Forum
MemVerge: Memory Viewer SoftwareMemVerge: Memory Viewer Software
MemVerge: Memory Viewer Software
CXL Forum118 views
TE Connectivity: Card Edge Interconnects by CXL Forum
TE Connectivity: Card Edge InterconnectsTE Connectivity: Card Edge Interconnects
TE Connectivity: Card Edge Interconnects
CXL Forum96 views

“Writing code that lasts” … or writing code you won’t hate tomorrow.