Writing Code That Lasts

Embed Size (px)

Citation preview

  • 8/12/2019 Writing Code That Lasts

    1/69

  • 8/12/2019 Writing Code That Lasts

    2/69

    Writing code

    yo#

    wo$

    !

    hat%

    tomorrow.

    Rafael Dohms

    @rdohms

    photo: djandyw.com

  • 8/12/2019 Writing Code That Lasts

    3/69

    Let me

    introduceyou to

    someone

  • 8/12/2019 Writing Code That Lasts

    4/69

  • 8/12/2019 Writing Code That Lasts

    5/69

  • 8/12/2019 Writing Code That Lasts

    6/69

    No Tests.

    Wrote his own framework.

    500 line methods.

    Used Singletons!

  • 8/12/2019 Writing Code That Lasts

    7/69photo: Rob Allen ( @akrabat)

  • 8/12/2019 Writing Code That Lasts

    8/69

  • 8/12/2019 Writing Code That Lasts

    9/69

    REWRITEALL THE CODE!

    h t Gl L Ph t k

  • 8/12/2019 Writing Code That Lasts

    10/69

    Real Developers,SHIP STUFF.

    photo: Glyn Lowe Photoworks

  • 8/12/2019 Writing Code That Lasts

    11/69

  • 8/12/2019 Writing Code That Lasts

    12/69

  • 8/12/2019 Writing Code That Lasts

    13/69

    photo: Kalexanderson

  • 8/12/2019 Writing Code That Lasts

    14/69

    How do we findbalance?

    photo: Kalexanderson

    photo: CarbonNYC

  • 8/12/2019 Writing Code That Lasts

    15/69

    Code has an

    expiration date

    photo: CarbonNYC

    photoby: massdistraction

  • 8/12/2019 Writing Code That Lasts

    16/69

    Code is

    perishable, it rots.

    photo by: massdistraction

    photo by: kevin dooley

  • 8/12/2019 Writing Code That Lasts

    17/69

    Code Evolves

    photo by: kevin dooley

  • 8/12/2019 Writing Code That Lasts

    18/69

    Languages evolve.

    photo by: raneko

    photo by: Kaptain Kobold

  • 8/12/2019 Writing Code That Lasts

    19/69You evolve

    p y p

    photo: osbornb

  • 8/12/2019 Writing Code That Lasts

    20/69

    Complexity

    kills

    Comprehension photo: miskan

  • 8/12/2019 Writing Code That Lasts

    21/69

    Bad Design

    p

  • 8/12/2019 Writing Code That Lasts

    22/69

    Bad specs

    photo by: John 'K'

  • 8/12/2019 Writing Code That Lasts

    23/69

    NIH

    source: Urban dictionary

    photo by: John K

    photo by: John 'K'

  • 8/12/2019 Writing Code That Lasts

    24/69

    NIH| n"t #n$vent#d h#%|

    Not Invented HereThe 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

    photo: Ian Sane

  • 8/12/2019 Writing Code That Lasts

    25/69

    The Solution

  • 8/12/2019 Writing Code That Lasts

    26/69

    Improve code

  • 8/12/2019 Writing Code That Lasts

    27/69

    Improve code

    make it easier to comprehend

  • 8/12/2019 Writing Code That Lasts

    28/69

    Improve code

    make it easier to comprehend

    make it flexible

  • 8/12/2019 Writing Code That Lasts

    29/69

    Improve code

    make it easier to comprehend

    make it flexible

    make it tested

  • 8/12/2019 Writing Code That Lasts

    30/69

    Improve code

    make it easier to comprehend

    make it flexible

    make it tested

    make it easier to replace, refactor

  • 8/12/2019 Writing Code That Lasts

    31/69

    Improve code

    make it easier to comprehend

    make it flexible

    make it tested

    make it easier to replace, refactor

    make it not exist

  • 8/12/2019 Writing Code That Lasts

    32/69

    Good DesignConcepts

  • 8/12/2019 Writing Code That Lasts

    33/69

    SOLIDSingle ResponsibilityOpen/close

    Liskov substitutionInterface segregation

    Dependency inversion

  • 8/12/2019 Writing Code That Lasts

    34/69

    STUPIDSingleton

    Tight CouplingUntestabilityPremature OptimizationIndescriptive Naming

    Duplication

  • 8/12/2019 Writing Code That Lasts

    35/69

    Composer

  • 8/12/2019 Writing Code That Lasts

    36/69

    PIEProudly

    InventedElsewhere

  • 8/12/2019 Writing Code That Lasts

    37/69

    guzzle/guzzleHTTP client for RESTful API clients

  • 8/12/2019 Writing Code That Lasts

    38/69

    morrisonlevi/ardentA library of collections for PHP

  • 8/12/2019 Writing Code That Lasts

    39/69

    Readability

    photo: Morgenland

    photo: Trossachs Photography

  • 8/12/2019 Writing Code That Lasts

    40/69

    paragraphs

  • 8/12/2019 Writing Code That Lasts

    41/69

    whitespace

  • 8/12/2019 Writing Code That Lasts

    42/69

  • 8/12/2019 Writing Code That Lasts

    43/69

    R&D Team for MIH/Naspers

    So PauloCape Town

    Obj

  • 8/12/2019 Writing Code That Lasts

    44/69

    Object

    Calisthenics

    photo by: boston_public_library

    photo by: boston_public_library

  • 8/12/2019 Writing Code That Lasts

    45/69

    Calisthenics/&kal%s$THeniks/

    Calisthenics are a form of dynamic exerciseconsisting of a variety of

    simple, often rhythmical, movements, generally using minimal

    equipment or apparatus.

  • 8/12/2019 Writing Code That Lasts

    46/69

    Its about perception,

    not rules or standards photo by: david_a_l

  • 8/12/2019 Writing Code That Lasts

    47/69

    Sunday 12:00Voyager Room

    photo by: justinliew

  • 8/12/2019 Writing Code That Lasts

    48/69

    #1Only one

    indentation level

    per method photo by: justinliew

  • 8/12/2019 Writing Code That Lasts

    49/69

    #2

    Do notuse else

  • 8/12/2019 Writing Code That Lasts

    50/69

  • 8/12/2019 Writing Code That Lasts

    51/69

  • 8/12/2019 Writing Code That Lasts

    52/69

    photo by: justinliew

  • 8/12/2019 Writing Code That Lasts

    53/69

    #3Wrap primitive

    types, if they

    contain behavior photo by: justinliew

  • 8/12/2019 Writing Code That Lasts

    54/69

    #4

    Only one->per line

    photo by: justinliew

  • 8/12/2019 Writing Code That Lasts

    55/69

    #5

    Do notabbreviate.

    photo by: justinliew

  • 8/12/2019 Writing Code That Lasts

    56/69

    #6

    Keep yourclasses small.

    photo by: justinliew

  • 8/12/2019 Writing Code That Lasts

    57/69

    #7Limityour

    instance variablesto less then 5

    photo by: justinliew

  • 8/12/2019 Writing Code That Lasts

    58/69

    #8

    Use first classcollections

    photo by: justinliew

  • 8/12/2019 Writing Code That Lasts

    59/69

    #9

    Usegettersand setters.

    photo by: justinliew

  • 8/12/2019 Writing Code That Lasts

    60/69

    #10

    Documentyour code.

  • 8/12/2019 Writing Code That Lasts

    61/69

  • 8/12/2019 Writing Code That Lasts

    62/69

    Improveyourself!

  • 8/12/2019 Writing Code That Lasts

    63/69

    Read lots ofcode!

  • 8/12/2019 Writing Code That Lasts

    64/69

    Write simplecode.

  • 8/12/2019 Writing Code That Lasts

    65/69

    Try Object Calisthenicsfor a month.

  • 8/12/2019 Writing Code That Lasts

    66/69

    Use someoneelses code.

  • 8/12/2019 Writing Code That Lasts

    67/69

    Share bite sizelibraries.

  • 8/12/2019 Writing Code That Lasts

    68/69

    Thank you.

    http://slides.doh.ms

    http://doh.ms

    @rdohms

    Video recording Resources on

    http://slides.doh.ms/http://slides.doh.ms/http://l.doh.ms/1nxaWCshttp://l.doh.ms/1nxaWCshttp://l.doh.ms/1nxaWCshttp://l.doh.ms/1nxaWCshttp://l.doh.ms/1nxaWCshttp://l.doh.ms/1nxaWCshttp://l.doh.ms/1nxaWCshttp://l.doh.ms/1nxaWCshttp://l.doh.ms/1nxaWCs
  • 8/12/2019 Writing Code That Lasts

    69/69

    Video recording

    Slides

    Books

    Object Calisthenics

    http://l.doh.ms/1lje5U8http://l.doh.ms/1lje5U8http://l.doh.ms/1lje5U8http://l.doh.ms/1lje5U8http://l.doh.ms/1lje5U8http://l.doh.ms/1lje5U8http://l.doh.ms/1lje5U8http://l.doh.ms/1lje5U8http://l.doh.ms/1lje5U8http://l.doh.ms/1iqkrvBhttp://l.doh.ms/1iqkrvBhttp://l.doh.ms/1iqkrvBhttp://l.doh.ms/1iqkrvBhttp://l.doh.ms/1iqkrvBhttp://l.doh.ms/1iqkrvBhttp://l.doh.ms/1iqkrvBhttp://l.doh.ms/1iqkrvBhttp://l.doh.ms/1iqkrvBhttp://l.doh.ms/1iq6jZchttp://l.doh.ms/1iq6jZchttp://l.doh.ms/1iq6jZchttp://l.doh.ms/1iq6jZchttp://l.doh.ms/1iq6jZchttp://l.doh.ms/1iq6jZchttp://l.doh.ms/1iq6jZchttp://l.doh.ms/1iq6jZchttp://l.doh.ms/1iq6jZchttp://l.doh.ms/1nxaWCs