writing code you won't hate tomorrow

69
Writing code that lasts. Rafael Dohms @rdohms photo: djandyw.com

Upload: rafael-dohms

Post on 15-Jan-2015

12.598 views

Category:

Engineering


1 download

DESCRIPTION

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.

TRANSCRIPT

Page 1: Writing code you won't hate tomorrow

Writing code that lasts.

Rafael Dohms@rdohms

photo: djandyw.com

Page 2: Writing code you won't hate tomorrow

Writing code you won’t hate tomorrow.

Rafael Dohms@rdohms

photo: djandyw.com

Page 3: Writing code you won't hate tomorrow

Let me introduce you to someone…

Page 4: Writing code you won't hate tomorrow
Page 5: Writing code you won't hate tomorrow
Page 6: Writing code you won't hate tomorrow

No Tests.

Wrote his own framework.

500 line methods.

Used Singletons!

Page 7: Writing code you won't hate tomorrow

photo: Rob Allen (@akrabat)

Page 8: Writing code you won't hate tomorrow
Page 9: Writing code you won't hate tomorrow

REWRITEALL THE CODE!

Page 10: Writing code you won't hate tomorrow

Real Developers, SHIP STUFF.

photo: Glyn Lowe Photoworks

Page 11: Writing code you won't hate tomorrow
Page 12: Writing code you won't hate tomorrow
Page 13: Writing code you won't hate tomorrow
Page 14: Writing code you won't hate tomorrow

How do we find balance?

photo: Kalexanderson

Page 15: Writing code you won't hate tomorrow

Code has an expiration date

photo: CarbonNYC

Page 16: Writing code you won't hate tomorrow

Code is perishable, it rots.

photo by: massdistraction

Page 17: Writing code you won't hate tomorrow

Code Evolves

photo by: kevin dooley

Page 18: Writing code you won't hate tomorrow

Languages evolve.photo by: raneko

Page 19: Writing code you won't hate tomorrow

You evolve.

photo by: Kaptain Kobold

Page 20: Writing code you won't hate tomorrow

Complexity kills Comprehension

photo: osbornb

Page 21: Writing code you won't hate tomorrow

Bad Design

photo: miskan

Page 22: Writing code you won't hate tomorrow

Bad specs

Page 23: Writing code you won't hate tomorrow

NIH

source: Urban dictionary

photo by: John 'K'

Page 24: Writing code you won't hate tomorrow

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'

Page 25: Writing code you won't hate tomorrow

The Solution™photo: Ian Sane

Page 26: Writing code you won't hate tomorrow

Improve code

Page 27: Writing code you won't hate tomorrow

Improve codemake it easier to comprehend

Page 28: Writing code you won't hate tomorrow

Improve codemake it easier to comprehend

make it flexible

Page 29: Writing code you won't hate tomorrow

Improve codemake it easier to comprehend

make it flexible

make it tested

Page 30: Writing code you won't hate tomorrow

Improve codemake it easier to comprehend

make it flexible

make it tested

make it easier to replace, refactor

Page 31: Writing code you won't hate tomorrow

Improve codemake it easier to comprehend

make it flexible

make it tested

make it easier to replace, refactor

make it not exist

Page 32: Writing code you won't hate tomorrow

Good Design Concepts

Page 33: Writing code you won't hate tomorrow

SOLID

Single ResponsibilityOpen and Close

Liskov substitutionInterface SegregationDependency Inversion

photo by j_regan

Page 34: Writing code you won't hate tomorrow

photo by lofink

STUPIDSingleton

Tight CouplingUntestability

Premature OptimizationIndescriptive Naming

Duplication

Page 35: Writing code you won't hate tomorrow

Design Patterns

photo by halloweenstock

Page 36: Writing code you won't hate tomorrow

Composer

Page 37: Writing code you won't hate tomorrow

PIEProudly

InventedElsewhere

Page 38: Writing code you won't hate tomorrow

guzzle/guzzleHTTP client for RESTful API clients

photo by j_regan

Page 39: Writing code you won't hate tomorrow

morrisonlevi/ardentA library of collections for PHP

Page 40: Writing code you won't hate tomorrow

Readability

photo: Morgenland

Page 41: Writing code you won't hate tomorrow

paragraphs

photo: Trossachs Photography

Page 42: Writing code you won't hate tomorrow

whitespace

Page 43: Writing code you won't hate tomorrow
Page 44: Writing code you won't hate tomorrow

R&D Team for MIH/Naspers

São PauloCape Town

Page 45: Writing code you won't hate tomorrow

Object Calisthenics

photo by: boston_public_library

Page 46: Writing code you won't hate tomorrow

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

Page 47: Writing code you won't hate tomorrow

Its about perception, not rules or standards

photo by: david_a_l

Page 48: Writing code you won't hate tomorrow

#1 Only one indentation level per method.

photo by: justinliew

Page 49: Writing code you won't hate tomorrow

#2 Do not use else

photo by: justinliew

Page 50: Writing code you won't hate tomorrow
Page 51: Writing code you won't hate tomorrow
Page 52: Writing code you won't hate tomorrow
Page 53: Writing code you won't hate tomorrow

#3 Wrap primitive types, if they contain behavior

photo by: justinliew

Page 54: Writing code you won't hate tomorrow

#4 Only one -> per line

photo by: justinliew

Page 55: Writing code you won't hate tomorrow

#5 Do not abbreviate.

photo by: justinliew

Page 56: Writing code you won't hate tomorrow

#6 Keep your classes small.

photo by: justinliew

Page 57: Writing code you won't hate tomorrow

#7 Limit your instance variables to less then 5

photo by: justinliew

Page 58: Writing code you won't hate tomorrow

#8 Use first class collections

photo by: justinliew

Page 59: Writing code you won't hate tomorrow

#9 Use getters and setters.

photo by: justinliew

Page 60: Writing code you won't hate tomorrow

#10 Document your code.

photo by: justinliew

Page 61: Writing code you won't hate tomorrow

Your turn.

Page 62: Writing code you won't hate tomorrow

Improve yourself!

Page 63: Writing code you won't hate tomorrow

Read lots of code!

Page 64: Writing code you won't hate tomorrow

Write simple code.

Page 65: Writing code you won't hate tomorrow

Try Object Calisthenics for a month.

Page 66: Writing code you won't hate tomorrow

Use someone else’s code.

Page 67: Writing code you won't hate tomorrow

Share bite size libraries.

Page 68: Writing code you won't hate tomorrow

Thank you.

http://slides.doh.ms

http://doh.ms

@rdohms

we are hiring!

https://joind.in/11594

please rate me!