SlideShare a Scribd company logo
1 of 70
Download to read offline
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
Let me
introduce
you to
someoneā€¦
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)
REWRITE
ALL THE CODE!
image: hyperboleandahalf
Real Developers,
SHIP STUFF.
photo: Glyn Lowe Photoworks
How do we ļ¬nd
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) scientiļ¬c 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 ļ¬‚exible
Improve code
make it easier to comprehend
make it ļ¬‚exible
make it tested
Improve code
make it easier to comprehend
make it ļ¬‚exible
make it tested
make it easier to replace, refactor
Improve code
make it easier to comprehend
make it ļ¬‚exible
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 loļ¬nk
STUPID
Singletonā€Ø
Tight Couplingā€Ø
Untestabilityā€Ø
Premature Optimizationā€Ø
Indescriptive Namingā€Ø
Duplication
Design Patterns
photo by halloweenstock
Composer
PIE
Proudlyā€Ø
Inventedā€Ø
Elsewhere
guzzlehttp/guzzle
HTTP client for RESTful API clients
photo by j_regan
league/tactician
A ļ¬‚exible CommandBus implementation
Readability
photo: Morgenland
paragraphs
photo: Trossachs Photography
whitespace
R&D Team for MIH/Naspers
SĆ£o PauloCape 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
#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 ļ¬rst 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.
http://slides.doh.ms
http://doh.ms
@rdohms
we are hiring!
http://tech.sym.bid/jobs
http://l.doh.ms/oc-links
Video recording
Slides
Books
Resources on ā€Ø
Object Calisthenics

More Related Content

Viewers also liked

Types of Production and Manufacturing
Types of Production and ManufacturingTypes of Production and Manufacturing
Types of Production and Manufacturing
Casey Robertson
Ā 
How to build a Java Web App in the Cloud
How to build a Java Web App in the CloudHow to build a Java Web App in the Cloud
How to build a Java Web App in the Cloud
WSO2
Ā 

Viewers also liked (20)

Improve the Development Process with DevOps Practices by Fedorov Vadim
Improve the Development Process with DevOps Practices by Fedorov VadimImprove the Development Process with DevOps Practices by Fedorov Vadim
Improve the Development Process with DevOps Practices by Fedorov Vadim
Ā 
Creative Traction Methodology - For Early Stage Startups
Creative Traction Methodology - For Early Stage StartupsCreative Traction Methodology - For Early Stage Startups
Creative Traction Methodology - For Early Stage Startups
Ā 
Build Features, Not Apps
Build Features, Not AppsBuild Features, Not Apps
Build Features, Not Apps
Ā 
Government Approach to Apps
Government Approach to AppsGovernment Approach to Apps
Government Approach to Apps
Ā 
Types of Production and Manufacturing
Types of Production and ManufacturingTypes of Production and Manufacturing
Types of Production and Manufacturing
Ā 
jQuery Mobile Deep Dive
jQuery Mobile Deep DivejQuery Mobile Deep Dive
jQuery Mobile Deep Dive
Ā 
Avr lecture8
Avr lecture8Avr lecture8
Avr lecture8
Ā 
Dev Ops 101
Dev Ops 101Dev Ops 101
Dev Ops 101
Ā 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo design
Ā 
Appraiser : How Airbnb Generates Complex Models in Spark for Demand Prediction
Appraiser : How Airbnb Generates Complex Models in Spark for Demand PredictionAppraiser : How Airbnb Generates Complex Models in Spark for Demand Prediction
Appraiser : How Airbnb Generates Complex Models in Spark for Demand Prediction
Ā 
Top Reasons Why Java Rocks (report preview) - http:0t.ee/java-rocks
Top Reasons Why Java Rocks (report preview) - http:0t.ee/java-rocksTop Reasons Why Java Rocks (report preview) - http:0t.ee/java-rocks
Top Reasons Why Java Rocks (report preview) - http:0t.ee/java-rocks
Ā 
3į„Œį…”į†¼ į„…į…”į„Œį…³į„‡į…¦į„…į…µ į„‘į…”į„‹į…µį„‹į…Ŗ gpio
3į„Œį…”į†¼ į„…į…”į„Œį…³į„‡į…¦į„…į…µ į„‘į…”į„‹į…µį„‹į…Ŗ gpio3į„Œį…”į†¼ į„…į…”į„Œį…³į„‡į…¦į„…į…µ į„‘į…”į„‹į…µį„‹į…Ŗ gpio
3į„Œį…”į†¼ į„…į…”į„Œį…³į„‡į…¦į„…į…µ į„‘į…”į„‹į…µį„‹į…Ŗ gpio
Ā 
I want to be an efficient developper. Mix-IT version
I want to be an efficient developper. Mix-IT versionI want to be an efficient developper. Mix-IT version
I want to be an efficient developper. Mix-IT version
Ā 
How to build a Java Web App in the Cloud
How to build a Java Web App in the CloudHow to build a Java Web App in the Cloud
How to build a Java Web App in the Cloud
Ā 
Functional Programming in JavaScript
Functional Programming in JavaScriptFunctional Programming in JavaScript
Functional Programming in JavaScript
Ā 
Virtual Gets Real!
Virtual Gets Real! Virtual Gets Real!
Virtual Gets Real!
Ā 
How Change Happens
How Change HappensHow Change Happens
How Change Happens
Ā 
Programming != Writing Code
Programming != Writing CodeProgramming != Writing Code
Programming != Writing Code
Ā 
The Technological Singularity
The Technological SingularityThe Technological Singularity
The Technological Singularity
Ā 
Building a Successful Organization By Mastering Failure
Building a Successful Organization By Mastering FailureBuilding a Successful Organization By Mastering Failure
Building a Successful Organization By Mastering Failure
Ā 

Similar to Writing Code That Lasts - Joomla!Dagen 2015

Similar to Writing Code That Lasts - Joomla!Dagen 2015 (9)

Writing code you won't hate tomorrow
Writing code you won't hate tomorrowWriting code you won't hate tomorrow
Writing code you won't hate tomorrow
Ā 
Writing code you won't hate tomorrow
Writing code you won't hate tomorrowWriting code you won't hate tomorrow
Writing code you won't hate tomorrow
Ā 
Dynamic Linking On GNU/Linux
Dynamic Linking On GNU/LinuxDynamic Linking On GNU/Linux
Dynamic Linking On GNU/Linux
Ā 
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
Ā 
Evolving DevOps in the Age of Cloud Native
Evolving DevOps in the Age of Cloud NativeEvolving DevOps in the Age of Cloud Native
Evolving DevOps in the Age of Cloud Native
Ā 
Graphql
GraphqlGraphql
Graphql
Ā 
REPL Driven Mobile Development with Clojure(script)
REPL Driven Mobile Development with Clojure(script)REPL Driven Mobile Development with Clojure(script)
REPL Driven Mobile Development with Clojure(script)
Ā 
BRV CTO Summit Deep Learning Talk
BRV CTO Summit Deep Learning TalkBRV CTO Summit Deep Learning Talk
BRV CTO Summit Deep Learning Talk
Ā 
SLO Driven Development
SLO Driven DevelopmentSLO Driven Development
SLO Driven Development
Ā 

More from Rafael Dohms

More from Rafael Dohms (20)

The Individual Contributor Path - DPC2024
The Individual Contributor Path - DPC2024The Individual Contributor Path - DPC2024
The Individual Contributor Path - DPC2024
Ā 
Application Metrics - IPC2023
Application Metrics - IPC2023Application Metrics - IPC2023
Application Metrics - IPC2023
Ā 
How'd we get here? A guide to Architectural Decision Records
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
Ā 
Architectural Decision Records - PHPConfBR
Architectural Decision Records - PHPConfBRArchitectural Decision Records - PHPConfBR
Architectural Decision Records - PHPConfBR
Ā 
Application Metrics (with Prometheus examples)
Application Metrics (with Prometheus examples)Application Metrics (with Prometheus examples)
Application Metrics (with Prometheus examples)
Ā 
Application metrics - Confoo 2019
Application metrics - Confoo 2019Application metrics - Confoo 2019
Application metrics - Confoo 2019
Ā 
Writing code you wonā€™t hate tomorrow - PHPCE18
Writing code you wonā€™t hate tomorrow - PHPCE18Writing code you wonā€™t hate tomorrow - PHPCE18
Writing code you wonā€™t hate tomorrow - PHPCE18
Ā 
Application Metrics (with Prometheus examples) #PHPDD18
Application Metrics (with Prometheus examples) #PHPDD18Application Metrics (with Prometheus examples) #PHPDD18
Application Metrics (with Prometheus examples) #PHPDD18
Ā 
Application metrics with Prometheus - DPC18
Application metrics with Prometheus - DPC18Application metrics with Prometheus - DPC18
Application metrics with Prometheus - DPC18
Ā 
ā€œ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
ā€œ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. - 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...
ā€œWriting code that lastsā€ ā€¦ or writing code you wonā€™t hate tomorrow. - PHP Yo...
Ā 
Composer The Right Way - 010PHP
Composer The Right Way - 010PHPComposer The Right Way - 010PHP
Composer The Right Way - 010PHP
Ā 
Composer the Right Way - PHPSRB16
Composer the Right Way - PHPSRB16Composer the Right Way - PHPSRB16
Composer the Right Way - PHPSRB16
Ā 
Composer the Right Way - MM16NL
Composer the Right Way - MM16NLComposer the Right Way - MM16NL
Composer the Right Way - MM16NL
Ā 
Composer The Right Way - PHPUGMRN
Composer The Right Way - PHPUGMRNComposer The Right Way - PHPUGMRN
Composer The Right Way - PHPUGMRN
Ā 
Composer the Right Way - PHPBNL16
Composer the Right Way - PHPBNL16Composer the Right Way - PHPBNL16
Composer the Right Way - PHPBNL16
Ā 
A Journey into your Lizard Brain - PHP Conference Brasil 2015
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
Ā 
Journey into your Lizard Brain - PHPJHB15
Journey into your Lizard Brain - PHPJHB15Journey into your Lizard Brain - PHPJHB15
Journey into your Lizard Brain - PHPJHB15
Ā 
Composer The Right Way #PHPjhb15
Composer The Right Way #PHPjhb15Composer The Right Way #PHPjhb15
Composer The Right Way #PHPjhb15
Ā 
Composer the right way - DPC15
Composer the right way - DPC15Composer the right way - DPC15
Composer the right way - DPC15
Ā 

Recently uploaded

Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
KreezheaRecto
Ā 
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
Ā 
Top Rated Call Girls In chittoor šŸ“± {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor šŸ“± {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor šŸ“± {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor šŸ“± {7001035870} VIP Escorts chittoor
dharasingh5698
Ā 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
Ā 
Call Girls in Ramesh Nagar Delhi šŸ’Æ Call Us šŸ”9953056974 šŸ” Escort Service
Call Girls in Ramesh Nagar Delhi šŸ’Æ Call Us šŸ”9953056974 šŸ” Escort ServiceCall Girls in Ramesh Nagar Delhi šŸ’Æ Call Us šŸ”9953056974 šŸ” Escort Service
Call Girls in Ramesh Nagar Delhi šŸ’Æ Call Us šŸ”9953056974 šŸ” Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
Ā 
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
sivaprakash250
Ā 
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
Ā 

Recently uploaded (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 ...
Ā 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
Ā 
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
Ā 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdf
Ā 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
Ā 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
Ā 
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
Ā 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Ā 
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
Ā 
Top Rated Call Girls In chittoor šŸ“± {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor šŸ“± {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor šŸ“± {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor šŸ“± {7001035870} VIP Escorts chittoor
Ā 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Ā 
Top Rated Pune Call Girls Budhwar Peth āŸŸ 6297143586 āŸŸ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth āŸŸ 6297143586 āŸŸ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth āŸŸ 6297143586 āŸŸ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth āŸŸ 6297143586 āŸŸ Call Me For Genuine Se...
Ā 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
Ā 
Call Girls in Ramesh Nagar Delhi šŸ’Æ Call Us šŸ”9953056974 šŸ” Escort Service
Call Girls in Ramesh Nagar Delhi šŸ’Æ Call Us šŸ”9953056974 šŸ” Escort ServiceCall Girls in Ramesh Nagar Delhi šŸ’Æ Call Us šŸ”9953056974 šŸ” Escort Service
Call Girls in Ramesh Nagar Delhi šŸ’Æ Call Us šŸ”9953056974 šŸ” Escort Service
Ā 
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
Ā 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
Ā 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
Ā 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
Ā 
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
Ā 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Ā 

Writing Code That Lasts - Joomla!Dagen 2015