SlideShare une entreprise Scribd logo
1  sur  70
Télécharger pour lire hors ligne
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 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
Composer
PIE
Proudly

Invented

Elsewhere
guzzlehttp/guzzle
HTTP client for RESTful API clients
photo by j_regan
league/tactician
A flexible 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 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.
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

Contenu connexe

En vedette

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
 

En vedette (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
 

Similaire à Writing Code That Lasts - Joomla!Dagen 2015

Similaire à 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
 

Plus de Rafael Dohms

Plus de 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
 

Dernier

+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
Health
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 
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
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 

Dernier (20)

+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptx
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
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
 
Air Compressor reciprocating single stage
Air Compressor reciprocating single stageAir Compressor reciprocating single stage
Air Compressor reciprocating single stage
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.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
 
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
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 

Writing Code That Lasts - Joomla!Dagen 2015