polymorphism ruby

of 23/23
Replacing Conditionals With Polymorphism @gpespn

Post on 12-Apr-2017

173 views

Category:

Software

0 download

Embed Size (px)

TRANSCRIPT

  • Replacing

    Conditionals With

    [email protected]

  • Any fool can write code that a computer can understand.

    Good programmers write code that humans can understand.

    -- Martin Fowler

    @gpespn

  • @gpespn

    But why? Easier to read Maintainability Extensibility Isolation of change Easier to test

  • @gpespn

    B+

  • @gpespn

    C-

  • @gpespn

    New Feature! Guest sessions

  • @gpespn

  • @gpespn

    F-

  • @gpespn

    I just want to send a message

    to an object

  • @gpespn

    -Woof!

    -Meow!

  • @gpespn

    Polymorphism

    tell don't ask

  • @gpespn

  • @gpespn

  • @gpespn

  • @gpespn

    still have conditional!

  • @gpespn

    Create a high level abstract

    class

  • @gpespn

  • @gpespn

    Abstract Subclass Subclass

  • @gpespn

    Polymorphism

  • @gpespn

  • @gpespn

    Whats the catch? Parallel interfaces Design patterns that are confusing to those unfamiliar to them

    New words/vocabulary into application. LOC went up! Increased big picture complexity in exchange for macro clarity

    Too many Objects

  • @gpespn

  • @gpespn

    Questions?