“Writing Code That Lasts” … Or Writing Code You Won’t Hate Tomorrow

If you like this presentation – show it...

Slide 0

photo: djandyw.com Writing code that lasts. #ocforphp Rafael Dohms

Slide 1

photo: djandyw.com Writing code 
 you won’t hate tomorrow. #ocforphp Rafael Dohms

Slide 2

Let me introduce you to someone…

Slide 3

Slide 4

Slide 5

No Tests. shhh.. don’t tell Grumpy. Wrote his own framework. .. and used it. Used Singletons! .. and every other anti-pattern out there. 500 line methods. … not even methods, they were functions

Slide 6

photo: Rob Allen (@akrabat)

Slide 7

Slide 8

REWRITE ALL THE CODE! image: hyperboleandahalf

Slide 9

photo: Glyn Lowe Photoworks Real Developers, SHIP STUFF.

Slide 10

Slide 11

Slide 12

Slide 13

photo: Kalexanderson How do we find balance?

Slide 14

photo: CarbonNYC Code has an expiration date

Slide 15

photo by: massdistraction Code is perishable, it rots.

Slide 16

photo by: kevin dooley Code Evolves

Slide 17

Languages evolve. photo by: raneko

Slide 18

photo by: Kaptain Kobold You evolve.

Slide 19

photo: osbornb Complexity 
 kills Comprehension

Slide 20

photo: miskan Bad Design

Slide 21

Bad specs

Slide 22

photo by: John 'K' NIH source: Urban dictionary

Slide 23

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

Slide 24

photo: Ian Sane The Solution™

Slide 25

Improve code

Slide 26

make it easier to comprehend Improve code

Slide 27

make it flexible make it easier to comprehend Improve code

Slide 28

make it flexible make it tested make it easier to comprehend Improve code

Slide 29

make it flexible make it tested make it easier to comprehend Improve code make it easier to replace, refactor

Slide 30

make it flexible make it tested make it easier to comprehend Improve code make it not exist make it easier to replace, refactor

Slide 31

Testing photo by: jeffkrause

Slide 32

Good Design Concepts

Slide 33

photo by j_regan SOLID Single Responsibility
 Open and Close
 Liskov substitution
 Interface Segregation
 Dependency Inversion

Slide 34

photo by lofink STUPID Singleton
 Tight Coupling
 Premature Optimization
 Indescriptive Naming

Slide 35

photo by halloweenstock Design Patterns

Slide 36


Slide 37

PIE Proudly

Slide 38

photo by j_regan guzzlehttp/guzzle HTTP client for RESTful API clients

Slide 39

league/tactician A flexible CommandBus implementation

Slide 40

Readability photo: Morgenland

Slide 41

photo: Trossachs Photography paragraphs

Slide 42


Slide 43

Slide 44

Cape Town São Paulo R&D Team for MIH/Naspers

Slide 45

Object Calisthenics photo by: boston_public_library

Slide 46

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.

Slide 47

Its about perception, not rules or standards photo by: david_a_l

Slide 48

photo by: justinliew #1 Only one indentation level per method.

Slide 49

photo by: justinliew #2 Do not 
 use else

Slide 50

Slide 51

Slide 52

Slide 53

photo by: justinliew #3 Wrap primitive types, if they contain behavior

Slide 54

photo by: justinliew #4 Only one 
 -> per line

Slide 55

photo by: justinliew #5 Do not abbreviate.

Slide 56

photo by: justinliew #6 Keep your classes small.

Slide 57

photo by: justinliew #7 Limit your instance variables to less then 5

Slide 58

photo by: justinliew #8 Use first class collections

Slide 59

photo by: justinliew #9 Use getters and setters.

Slide 60

photo by: justinliew #10 Document your code.

Slide 61

Your turn.

Slide 62

Improve yourself!

Slide 63

Read lots of code!

Slide 64

Write simple code.

Slide 65

Try Object Calisthenics for a month.

Slide 66

Use someone else’s code.

Slide 67

Share bite size libraries.

Slide 68

http://tech.sym.bid/jobs we are hiring! Thank you. @rdohms http://doh.ms http://slides.doh.ms

Slide 69

Video recording Resources on 
 Object Calisthenics Books Slides http://l.doh.ms/oc-material

Slide 70