writing code that lasts - jab14

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

Upload: rafael-dohms

Post on 16-Apr-2017

19.446 views

Category:

Engineering


6 download

TRANSCRIPT

Page 1: Writing code that lasts - JAB14

Writing code that lasts.

Rafael Dohms@rdohms

photo: djandyw.com

Page 2: Writing code that lasts - JAB14

Writing code you won’t hate tomorrow.

Rafael Dohms@rdohms

photo: djandyw.com

Page 3: Writing code that lasts - JAB14

Let me introduce you to someone…

Page 4: Writing code that lasts - JAB14
Page 5: Writing code that lasts - JAB14
Page 6: Writing code that lasts - JAB14

No Tests.

Wrote his own framework.

500 line methods.

Used Singletons!

Page 7: Writing code that lasts - JAB14

photo: Rob Allen (@akrabat)

Page 8: Writing code that lasts - JAB14
Page 9: Writing code that lasts - JAB14

REWRITEALL THE CODE!

Page 10: Writing code that lasts - JAB14

Real Developers, SHIP STUFF.

photo: Glyn Lowe Photoworks

Page 11: Writing code that lasts - JAB14
Page 12: Writing code that lasts - JAB14
Page 13: Writing code that lasts - JAB14
Page 14: Writing code that lasts - JAB14

How do we find balance?

photo: Kalexanderson

Page 15: Writing code that lasts - JAB14

Code has an expiration date

photo: CarbonNYC

Page 16: Writing code that lasts - JAB14

Code is perishable, it rots.

photo by: massdistraction

Page 17: Writing code that lasts - JAB14

Code Evolves

photo by: kevin dooley

Page 18: Writing code that lasts - JAB14

Languages evolve.photo by: raneko

Page 19: Writing code that lasts - JAB14

You evolve.

photo by: Kaptain Kobold

Page 20: Writing code that lasts - JAB14

Complexity kills Comprehension

photo: osbornb

Page 21: Writing code that lasts - JAB14

Bad Design

photo: miskan

Page 22: Writing code that lasts - JAB14

Bad specs

Page 23: Writing code that lasts - JAB14

NIH

source: Urban dictionary

photo by: John 'K'

Page 24: Writing code that lasts - JAB14

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 that lasts - JAB14

The Solution™photo: Ian Sane

Page 26: Writing code that lasts - JAB14

Improve code

Page 27: Writing code that lasts - JAB14

Improve codemake it easier to comprehend

Page 28: Writing code that lasts - JAB14

Improve codemake it easier to comprehend

make it flexible

Page 29: Writing code that lasts - JAB14

Improve codemake it easier to comprehend

make it flexible

make it tested

Page 30: Writing code that lasts - JAB14

Improve codemake it easier to comprehend

make it flexible

make it tested

make it easier to replace, refactor

Page 31: Writing code that lasts - JAB14

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 that lasts - JAB14

Good Design Concepts

Page 33: Writing code that lasts - JAB14

SOLIDSingle ResponsibilityOpen/closeLiskov substitutionInterface segregationDependency inversion

Page 34: Writing code that lasts - JAB14

STUPIDSingletonTight CouplingUntestabilityPremature OptimizationIndescriptive NamingDuplication

Page 35: Writing code that lasts - JAB14

Composer

Page 36: Writing code that lasts - JAB14

PIEProudly

InventedElsewhere

Page 37: Writing code that lasts - JAB14

guzzle/guzzleHTTP client for RESTful API clients

Page 38: Writing code that lasts - JAB14

morrisonlevi/ardentA library of collections for PHP

Page 39: Writing code that lasts - JAB14

Readability

photo: Morgenland

Page 40: Writing code that lasts - JAB14

paragraphs

photo: Trossachs Photography

Page 41: Writing code that lasts - JAB14

whitespace

Page 42: Writing code that lasts - JAB14
Page 43: Writing code that lasts - JAB14

R&D Team for MIH/Naspers

São PauloCape Town

Page 44: Writing code that lasts - JAB14

Object Calisthenics

photo by: boston_public_library

Page 45: Writing code that lasts - JAB14

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 46: Writing code that lasts - JAB14

Its about perception, not rules or standards

photo by: david_a_l

Page 47: Writing code that lasts - JAB14

Sunday12:00

Voyager Room

Page 48: Writing code that lasts - JAB14

#1 Only one indentation level per method.

photo by: justinliew

Page 49: Writing code that lasts - JAB14

#2 Do not use else

photo by: justinliew

Page 50: Writing code that lasts - JAB14
Page 51: Writing code that lasts - JAB14
Page 52: Writing code that lasts - JAB14
Page 53: Writing code that lasts - JAB14

#3 Wrap primitive types, if they contain behavior

photo by: justinliew

Page 54: Writing code that lasts - JAB14

#4 Only one -> per line

photo by: justinliew

Page 55: Writing code that lasts - JAB14

#5 Do not abbreviate.

photo by: justinliew

Page 56: Writing code that lasts - JAB14

#6 Keep your classes small.

photo by: justinliew

Page 57: Writing code that lasts - JAB14

#7 Limit your instance variables to less then 5

photo by: justinliew

Page 58: Writing code that lasts - JAB14

#8 Use first class collections

photo by: justinliew

Page 59: Writing code that lasts - JAB14

#9 Use getters and setters.

photo by: justinliew

Page 60: Writing code that lasts - JAB14

#10 Document your code.

photo by: justinliew

Page 61: Writing code that lasts - JAB14

Your turn.

Page 62: Writing code that lasts - JAB14

Improve yourself!

Page 63: Writing code that lasts - JAB14

Read lots of code!

Page 64: Writing code that lasts - JAB14

Write simple code.

Page 65: Writing code that lasts - JAB14

Try Object Calisthenics for a month.

Page 66: Writing code that lasts - JAB14

Use someone else’s code.

Page 67: Writing code that lasts - JAB14

Share bite size libraries.

Page 68: Writing code that lasts - JAB14

Thank you.

http://slides.doh.ms

http://doh.ms

@rdohms