Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
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…
No Tests.
Wrote his own framework.
500 line methods.
Used Singletons!
shhh.. don’t tell Grumpy.
.. and used it.
.. and eve...
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 (medi...
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 e...
Testing
photo by: jeffkrause
Good Design
Concepts
SOLID
Single Responsibility

Open and Close

Liskov substitution

Interface Segregation

Dependency Inversion
photo by j_r...
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
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 rhythmi...
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
$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 > $strSysMa...
#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
“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.
“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.
“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.
“Writing code that lasts” … or writing code you won’t hate tomorrow.
Upcoming SlideShare
Loading in …5
×

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

2,329 views

Published on

As developers we write code everyday, only to frown at it a week after that. Why do we have such a hard time with code written by others and ourselves, this raging desire to rewrite everything we see? Writing code that survives the test of time and self judgment is a matter of clarity and simplicity. Let's talk about growing, learning and improving our code with calisthenics, readability and good design.

Published in: Technology
  • Rafael, obrigado por compartilhar uma parte de seus conhecimentos conosco no PHPConference. Gostaria de saber se pode recomendar algum livro para aprender sobre SOLID em Pt-br hehe, pois meu inglês ainda não é bom.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

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

  1. 1. Writing code that lasts. Rafael Dohms
 @rdohms photo: djandyw.com #ocforphp
  2. 2. Writing code 
 you won’t hate tomorrow. Rafael Dohms
 @rdohms photo: djandyw.com #ocforphp
  3. 3. Rafael Dohms or @rdohms on twitter
  4. 4. Developer Herder at AmsterdamPHP
  5. 5. Lead Backend Developer at Symbid
  6. 6. Let me tell you about someone else…
  7. 7. 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
  8. 8. photo: Rob Allen (@akrabat)
  9. 9. REWRITE ALL THE CODE! image: hyperboleandahalf
  10. 10. Real Developers, SHIP STUFF. photo: Glyn Lowe Photoworks
  11. 11. How do we find balance? photo: Kalexanderson
  12. 12. Code has an expiration date photo: CarbonNYC
  13. 13. Code is perishable, it rots. photo by: massdistraction
  14. 14. Code Evolves photo by: kevin dooley
  15. 15. Languages evolve. photo by: raneko
  16. 16. You evolve. photo by: Kaptain Kobold
  17. 17. Complexity 
 kills Comprehension photo: osbornb
  18. 18. Bad Design photo: miskan
  19. 19. Bad specs
  20. 20. NIH source: Urban dictionary photo by: John 'K'
  21. 21. 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'
  22. 22. The Solution™ photo: Ian Sane
  23. 23. Improve code
  24. 24. Improve code make it easier to comprehend
  25. 25. Improve code make it easier to comprehend make it flexible
  26. 26. Improve code make it easier to comprehend make it flexible make it tested
  27. 27. Improve code make it easier to comprehend make it flexible make it tested make it easier to replace, refactor
  28. 28. Improve code make it easier to comprehend make it flexible make it tested make it easier to replace, refactor make it not exist
  29. 29. Testing photo by: jeffkrause
  30. 30. Good Design Concepts
  31. 31. SOLID Single Responsibility
 Open and Close
 Liskov substitution
 Interface Segregation
 Dependency Inversion photo by j_regan
  32. 32. photo by lofink STUPID Singleton
 Tight Coupling
 Untestability
 Premature Optimization
 Indescriptive Naming
 Duplication
  33. 33. Design Patterns photo by halloweenstock
  34. 34. Package Managers photo by cocoachuchu.etsy.com
  35. 35. PIE Proudly
 Invented
 Elsewhere
  36. 36. Readability photo: Morgenland
  37. 37. paragraphs photo: Trossachs Photography
  38. 38. whitespace
  39. 39. R&D Team for MIH/Naspers São Paulo Cape Town
  40. 40. Object Calisthenics photo by: boston_public_library
  41. 41. 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
  42. 42. Its about perception, not rules or standards photo by: david_a_l
  43. 43. #1 Only one indentation level per method. photo by: justinliew
  44. 44. #2 Do not 
 use else photo by: justinliew
  45. 45. #3 Wrap primitive types, if they contain behavior photo by: justinliew
  46. 46. $component->repaint(false);
  47. 47. $component->repaint( new Animate(false) );
  48. 48. #4 Only one 
 -> per line photo by: justinliew
  49. 49. #5 Do not abbreviate. photo by: justinliew
  50. 50. if($sx >= $sy) { if ($sx > $strSysMatImgW) { $ny = $strSysMatImgW * $sy / $sx; $nx = $strSysMatImgW; } if ($ny > $strSysMatImgH) { $nx = $strSysMatImgH * $sx / $sy; $ny = $strSysMatImgH; } }
  51. 51. #6 Keep your classes small. photo by: justinliew
  52. 52. #7 Limit your instance variables to less then 5 photo by: justinliew
  53. 53. #8 Use first class collections photo by: justinliew
  54. 54. #9 Don’t use getters and setters. photo by: justinliew
  55. 55. #10 Document your code. photo by: justinliew
  56. 56. Your turn.
  57. 57. Improve yourself!
  58. 58. Read lots of code!
  59. 59. Write simple code.
  60. 60. Try Object Calisthenics for a month.
  61. 61. Use someone else’s code.
  62. 62. Share bite size libraries.
  63. 63. Thank you. http://slides.doh.ms http://doh.ms @rdohms we are hiring! http://careers.symbid.com
  64. 64. http://l.doh.ms/oc-material Video recording Slides Books Resources on 
 Object Calisthenics

×