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

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
ย 
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
ย 
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
ย 

Recently uploaded (20)

Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
ย 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
ย 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
ย 
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
ย 
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
ย 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
ย 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
ย 
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
ย 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
ย 
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
ย 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
ย 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
ย 
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...
ย 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
ย 
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
ย 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
ย 
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...
ย 
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
ย 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
ย 

Writing Code That Lasts - Joomla!Dagen 2015