Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Saving Sprockets

Saving Sprockets

Richard Schneeman

May 06, 2016
Tweet

More Decks by Richard Schneeman

Other Decks in Programming

Transcript

  1. Type to enter
    text
    Saving
    Sprockets

    View full-size slide

  2. 2016
    @schneems
    Saving
    Sprockets

    View full-size slide

  3. Why does
    sprockets
    need saving?

    View full-size slide

  4. Major
    Feature of
    Rails 3.1

    View full-size slide

  5. Sprockets is
    the asset
    pipeline

    View full-size slide

  6. Sprockets
    came first

    View full-size slide

  7. They
    Call me
    @Schneems

    View full-size slide

  8. Sounds like
    “schnapps”

    View full-size slide

  9. Ruby
    “Hero”

    View full-size slide

  10. Ruby
    “Hero”

    View full-size slide

  11. All likeness to
    Disney owned
    properties
    totally
    coincidental

    View full-size slide

  12. And/or
    parody

    View full-size slide

  13. (Please don’t
    sue me)

    View full-size slide

  14. Call me by my
    real name

    View full-size slide

  15. No need to
    look like Indy
    to maintain
    OSS

    View full-size slide

  16. He’s my
    Sprockets
    Spirit Animal

    View full-size slide

  17. From 2011
    to
    2016

    View full-size slide

  18. 51 million
    downloads

    View full-size slide

  19. Rails has 65
    million

    View full-size slide

  20. One developer
    responsible
    for 2,027
    commits

    View full-size slide

  21. 68%
    Sprockets

    View full-size slide

  22. 68%
    Sprockets
    0.9%
    Rails

    View full-size slide

  23. 51 million
    downloads
    1 developer

    View full-size slide

  24. One day, Josh
    left

    View full-size slide

  25. What should
    we do?

    View full-size slide

  26. Abandon
    Sprockets?

    View full-size slide

  27. What are the
    problems?

    View full-size slide

  28. You can’t fix
    what you
    can’t define

    View full-size slide

  29. A re-write
    assumes we
    know better

    View full-size slide

  30. Assets are
    easy, edge
    cases are
    hard

    View full-size slide

  31. Established
    API

    View full-size slide

  32. How many of
    you maintain
    code?

    View full-size slide

  33. How many of
    you want to
    maintain it
    forever?

    View full-size slide

  34. Losing
    maintainers
    is inevitable

    View full-size slide

  35. It’s not
    always
    expected

    View full-size slide

  36. When we lose
    a maintainer
    it hurts

    View full-size slide

  37. How do we
    cope with
    losing a
    maintainer?

    View full-size slide

  38. “They’ll come
    back”

    View full-size slide

  39. “Leaving is so
    selfish”

    View full-size slide

  40. “That was a
    pretty jerk
    thing to do”

    View full-size slide

  41. “Maybe if we
    hire them to
    work on it full
    time…”

    View full-size slide

  42. “They’re not
    coming back”

    View full-size slide

  43. “Who will
    take this
    over?”

    View full-size slide

  44. A maintainer
    does not OWE
    you anything

    View full-size slide

  45. “I deserve an
    explanation

    View full-size slide

  46. Not even an
    explanation

    View full-size slide

  47. Leaving a
    project is a
    personal
    decision

    View full-size slide

  48. Josh didn’t
    want to talk
    about it

    View full-size slide

  49. We should
    respect what
    they’ve done

    View full-size slide

  50. You OWE a
    maintainer
    respect

    View full-size slide

  51. “But I HATE
    software

    View full-size slide

  52. Critique
    software
    without
    demonizing the
    creators

    View full-size slide

  53. I’m going to
    critique the
    crap out of
    Sprockets

    View full-size slide

  54. Critique
    don’t
    Criticize

    View full-size slide

  55. You are not
    your software

    View full-size slide

  56. You are not
    your khakis

    View full-size slide

  57. Josh gave
    years of his
    life

    View full-size slide

  58. HUNDREDS
    of closed
    issues

    View full-size slide

  59. To @josh
    Thanks for
    making
    Sprockets

    View full-size slide

  60. Words
    without
    actions are
    empty

    View full-size slide

  61. Be actionable

    View full-size slide

  62. “ES6 support
    is great…

    View full-size slide

  63. “looks like
    they don’t have
    async/await
    support yet

    View full-size slide

  64. “I need those
    because of

    View full-size slide

  65. Is this
    comment
    adding
    anything?

    View full-size slide

  66. Hyperbole
    breeds
    burnout

    View full-size slide

  67. Be productive

    View full-size slide

  68. Complaining
    accomplishes
    nothing

    View full-size slide

  69. How do we
    keep a
    maintainer
    longer?

    View full-size slide

  70. How to stay
    as a
    maintainer
    longer?

    View full-size slide

  71. Do we want
    mantainers to
    stay?

    View full-size slide

  72. Graceful
    handoff

    View full-size slide

  73. Almost every
    day I say
    “this is
    insane”

    View full-size slide

  74. 6 hours of my
    life later, I
    say “this is
    genius”

    View full-size slide

  75. Maintainers
    are historians

    View full-size slide

  76. Maintainers
    bring
    context

    View full-size slide

  77. Good commit
    messages

    View full-size slide

  78. Good PR
    messages

    View full-size slide

  79. Well written
    CHANGELOG
    entries

    View full-size slide

  80. Don’t compare
    to having
    someone who
    was there

    View full-size slide

  81. A story is
    worth 1000
    commit
    messages

    View full-size slide

  82. You can’t ask
    a commit
    message a
    question

    View full-size slide


  83. Did you
    also
    consider…

    View full-size slide


  84. LOL I’m a
    commit
    message

    View full-size slide

  85. Keep
    maintainers
    longer by
    giving them
    what they want

    View full-size slide

  86. “I don’t have
    time to help

    View full-size slide

  87. “Gahhhhhh
    fix all the
    things for
    me!!!!!!!!!

    View full-size slide

  88. 5 minutes to
    check snap-
    faceta-
    foursquare-
    tagram?

    View full-size slide

  89. 5 minutes to
    help

    View full-size slide

  90. Contribute to
    docs

    View full-size slide

  91. Read the
    guides

    View full-size slide

  92. Did you find
    surprising
    behavior?

    View full-size slide

  93. Was your
    behavior
    documented?

    View full-size slide

  94. Add it to the
    guide

    View full-size slide

  95. 5 minutes to
    help

    View full-size slide

  96. Submit bug
    reports

    View full-size slide

  97. SRSLY
    We don’t
    know if it’s
    broken

    View full-size slide

  98. 5 minutes to
    help

    View full-size slide

  99. Ask common
    questions

    View full-size slide

  100. “Was this
    working
    previously?

    View full-size slide

  101. Would you
    rather a
    maintainer
    spent time
    fixing bugs?

    View full-size slide

  102. Asking for
    minutiae in
    issue
    comments?

    View full-size slide

  103. Give a
    minute, save
    a minute

    View full-size slide

  104. If you don’t
    who will?

    View full-size slide

  105. Exposes you
    to different
    parts of the
    project

    View full-size slide

  106. Helps you
    grow as a
    developer

    View full-size slide

  107. 10 minutes to
    help

    View full-size slide

  108. Include a
    example app
    that reproduces
    the problem

    View full-size slide

  109. OMG
    example apps
    are amazing

    View full-size slide

  110. “First run
    $ rails new”

    View full-size slide

  111. Could not
    reproduce

    View full-size slide

  112. “Oh, yeah
    try…”

    View full-size slide

  113. Could not
    reproduce

    View full-size slide

  114. “Can you
    try…”

    View full-size slide

  115. “Here’s an
    app that
    reproduces
    the problem”

    View full-size slide

  116. github.com/
    /
    ExampleApp

    View full-size slide

  117. Give a
    minute, save
    a minute

    View full-size slide

  118. Challenge
    make 1
    example app
    this year

    View full-size slide

  119. 30 minutes to
    help?

    View full-size slide

  120. Try fixing a/
    your bug

    View full-size slide

  121. Guaranteed
    to learn
    something

    View full-size slide

  122. Read other
    people’s code

    View full-size slide

  123. Navigating
    and
    debugging
    are skills

    View full-size slide

  124. Navigating
    and debugging
    are marketable
    skills

    View full-size slide

  125. Go the extra
    mile

    View full-size slide

  126. How do we
    make
    transition
    easier?

    View full-size slide

  127. What is a
    maintainer?

    View full-size slide

  128. Someone who
    knows the
    stories

    View full-size slide

  129. Someone who
    takes 5
    minutes

    View full-size slide

  130. Someone who
    takes 10
    minutes

    View full-size slide

  131. Someone who
    takes 30
    minutes

    View full-size slide

  132. Helping
    preserves
    history

    View full-size slide

  133. Helping is the
    answer to
    keeping
    maintainers

    View full-size slide

  134. Helping is the
    answer to
    creating
    maintainers

    View full-size slide

  135. How do we
    foster a a
    culture for
    helping?

    View full-size slide

  136. What do
    maintainers
    want?

    View full-size slide

  137. What do
    helpers want?

    View full-size slide

  138. They want
    what regular
    users want

    View full-size slide

  139. A good
    developer UX

    View full-size slide

  140. Non-magical
    code

    View full-size slide

  141. Backwards
    compatibility

    View full-size slide

  142. Good
    deprecations

    View full-size slide

  143. Reliable
    Tests

    View full-size slide

  144. $ yard doc lib/
    [warn]: In file `README.md':248: Cannot resolve link to ExecJS
    from text:
    [warn]: {ExecJS}...
    [warn]: In file `README.md':439: Cannot resolve link to Tilt
    from text:
    [warn]: {Tilt}...
    [warn]: In file `README.md':248: Cannot resolve link to ExecJS
    from text:
    [warn]: {ExecJS}...
    [warn]: In file `README.md':439: Cannot resolve link to Tilt
    from text:
    [warn]: {Tilt}...
    [warn]: In file `lib/sprockets/unloaded_asset.rb':62: Cannot
    resolve link to type: from text:
    [warn]: ...{type: ”application/javascript“}...
    Files: 70
    Modules: 30 ( 10 undocumented)
    Classes: 48 ( 25 undocumented)
    Constants: 50 ( 32 undocumented)
    Methods: 405 ( 72 undocumented)
    73.92% documented

    View full-size slide

  145. Sprockets
    methods are
    documented

    View full-size slide

  146. Method docs
    are like unit
    tests

    View full-size slide

  147. Don’t tell the
    whole story

    View full-size slide

  148. Easy to get
    out of sync
    with reality

    View full-size slide

  149. A README
    tells a story

    View full-size slide

  150. Like an
    integration
    test

    View full-size slide

  151. $ wc -w README.md
    2619 README.md

    View full-size slide

  152. Sprockets
    tells a LONG
    story

    View full-size slide

  153. Helpers love
    docs

    View full-size slide

  154. Sprockets
    has docs

    View full-size slide

  155. Y U NO
    HELPERS
    SPROCKETS?

    View full-size slide

  156. Design
    Research

    View full-size slide

  157. User Stories

    View full-size slide

  158. Consider the
    people using
    your
    “product”

    View full-size slide

  159. Likes long
    walks on the
    beach

    View full-size slide

  160. Favorite food
    is bagel bites

    View full-size slide

  161. Building the
    next UBER for
    goldfish

    View full-size slide

  162. Cares only
    about the
    user level
    interface

    View full-size slide

  163. //= require “foo.js”

    View full-size slide

  164. Addicted to
    ES6

    View full-size slide

  165. Loves to fly
    fish

    View full-size slide

  166. Plugin
    developer

    View full-size slide

  167. Did you know
    sprockets has
    plugins?

    View full-size slide

  168. Called
    Processors

    View full-size slide

  169. Cares about
    the processor
    interface

    View full-size slide

  170. def self.call(input)
    data = input[:data]
    # …
    end

    View full-size slide

  171. Has a dog
    named
    Exception

    View full-size slide

  172. Hates
    mustard

    View full-size slide

  173. Rails
    Developer

    View full-size slide

  174. I.e. people
    building an
    asset pipeline

    View full-size slide

  175. Cares about
    Low level
    interface

    View full-size slide

  176. env = Sprockets::Environment.new(".")
    env.gzip = false

    View full-size slide

  177. Different
    people need
    different docs

    View full-size slide

  178. Don’t make
    me hunt
    down docs

    View full-size slide

  179. sprockets/
    guides

    View full-size slide

  180. Building an
    Asset
    Processing
    Framework

    View full-size slide

  181. End User
    Asset
    Generation

    View full-size slide

  182. Extending
    Sprockets

    View full-size slide

  183. Makes it
    easier for devs
    to find what
    they need

    View full-size slide

  184. Lives in the
    source, not a
    wiki

    View full-size slide

  185. Docs are only
    valid for a
    point in time

    View full-size slide

  186. Helpers love
    contributing
    to docs

    View full-size slide

  187. Make more
    docs

    View full-size slide

  188. Make better
    docs

    View full-size slide

  189. Docs are the
    gateway to
    code
    contributions

    View full-size slide

  190. Sprockets
    designed to
    solve
    problems

    View full-size slide

  191. Sometimes it
    feels like

    View full-size slide

  192. They don’t
    know why
    it fails

    View full-size slide

  193. Sprockets
    isn’t talking
    to devs

    View full-size slide

  194. How does
    code talk?

    View full-size slide

  195. “something
    broke”

    View full-size slide

  196. No route matches
    {:action=>"show", :controller=>"users"}

    View full-size slide

  197. “This broke”

    View full-size slide

  198. No route matches
    {:action=>"show", :controller=>"users"},
    :id key is missing

    View full-size slide

  199. No route matches
    {:action=>"show", :controller=>"users"},
    :id key is missing

    View full-size slide

  200. Good errors
    are
    instructive

    View full-size slide

  201. Sprockets
    will have
    better errors

    View full-size slide

  202. I care about
    this

    View full-size slide

  203. Deprecations

    View full-size slide

  204. Deprecating
    in comments
    is not enough

    View full-size slide

  205. A) No one
    casually
    reads your
    method docs

    View full-size slide

  206. B) Who has
    the time?

    View full-size slide

  207. You cannot
    break your
    API without
    warning*

    View full-size slide

  208. *when you’ve
    got 51 million
    downloads

    View full-size slide

  209. Your code
    knows

    View full-size slide

  210. YELL AT
    THEM FOR IT

    View full-size slide

  211. Sprockets 3.X
    will have
    deprecations
    before 4.x

    View full-size slide

  212. Deprecations
    nudge

    View full-size slide

  213. Deprecations
    Help people
    upgrade

    View full-size slide

  214. Deprecations
    help with API
    design

    View full-size slide

  215. If you can’t
    write a good
    deprecation

    View full-size slide

  216. The interface
    wasn’t very
    good

    View full-size slide

  217. What if you
    change a
    hash key?

    View full-size slide

  218. Sprockets did
    this

    View full-size slide

  219. filename = input[:source_path] || input[:filename]

    View full-size slide

  220. (more) Sane
    Code

    View full-size slide

  221. Sprockets
    suffers from
    the god object
    problem

    View full-size slide

  222. 1 main class,
    lot’s of
    concerns.

    View full-size slide

  223. 1 object,
    105 methods

    View full-size slide

  224. Where did
    that method
    come from?

    View full-size slide

  225. Sprockets::Base

    View full-size slide

  226. Sprockets::
    Environment

    View full-size slide

  227. Sprockets::
    Dependencies

    View full-size slide

  228. Sprockets::
    DigestUtils

    View full-size slide

  229. Sprockets::
    HTTPUtils

    View full-size slide

  230. Sprockets::
    Mime

    View full-size slide

  231. Sprockets::
    Server

    View full-size slide

  232. Sprockets::
    Resolve

    View full-size slide

  233. Sprockets::
    Loader

    View full-size slide

  234. Sprockets::
    Bower

    View full-size slide

  235. Sprockets::
    PathUtils

    View full-size slide

  236. Sprockets::
    PathDependencyUtils

    View full-size slide

  237. Sprockets::
    PathDigestUtils

    View full-size slide

  238. Sprockets::
    DigestUtils

    View full-size slide

  239. Sprockets::
    SourceMapUtils

    View full-size slide

  240. Sprockets::
    UriUtils

    View full-size slide

  241. Sprockets::
    Utils

    View full-size slide

  242. Sprockets::
    Compressing

    View full-size slide

  243. Sprockets::
    Configuration

    View full-size slide

  244. Sprockets::
    Base

    View full-size slide

  245. Inherited by

    View full-size slide

  246. Sprockets::
    Environment

    View full-size slide

  247. Wrapped and
    cached by

    View full-size slide

  248. Sprockets::
    CachedEnvironment

    View full-size slide

  249. Impossible to
    know at a
    glance how
    they interact

    View full-size slide

  250. For more info
    go to Rafael
    Franca’s talk

    View full-size slide

  251. Which was
    yesterday

    View full-size slide

  252. Solution to
    god objects?

    View full-size slide

  253. Move logic
    over to helper
    classes

    View full-size slide

  254. Minimize God
    object API

    View full-size slide

  255. Small easy to
    understand
    files

    View full-size slide

  256. Readable
    code

    View full-size slide

  257. Attracts
    helpers who
    read code

    View full-size slide

  258. Ruby is
    Object
    Oriented

    View full-size slide

  259. Get
    comfortable
    with objects

    View full-size slide

  260. Sandi Metz
    POODR

    View full-size slide

  261. Katrina Owen
    Refactoring
    &
    Exercism.io

    View full-size slide

  262. Helping
    takes
    commitment

    View full-size slide

  263. respect that

    View full-size slide

  264. “thanks for
    submitting
    this PR

    View full-size slide

  265. They cared
    enough to try
    to help

    View full-size slide

  266. Help them
    help you

    View full-size slide

  267. What else do
    people want?

    View full-size slide

  268. Maybe they
    want
    recognition?

    View full-size slide

  269. Maybe
    helpers want
    pizza?

    View full-size slide

  270. Windows
    Tests

    View full-size slide

  271. Thanks
    @daniel-rikowski

    View full-size slide

  272. These are our
    ideals

    View full-size slide

  273. So you inherited
    a project with
    51 million
    downloads

    View full-size slide

  274. The original
    maintainer
    mic-dropped

    View full-size slide

  275. What do you
    do?

    View full-size slide

  276. Find
    something
    that needs
    fixing

    View full-size slide

  277. Bug driven
    development

    View full-size slide

  278. Get an
    example app

    View full-size slide

  279. OMG
    example apps
    are amazing

    View full-size slide

  280. Reproduce
    the problem

    View full-size slide

  281. Every bug you
    fix, you’ll learn
    more about the
    project

    View full-size slide

  282. Eventually
    you’ll begin
    to see non-
    bug problems

    View full-size slide

  283. So you’ve got
    a bug report
    what do you
    do now?

    View full-size slide

  284. Source Maps
    in Sprockets
    4

    View full-size slide

  285. Half finished

    View full-size slide

  286. I had no idea
    what source
    maps were

    View full-size slide

  287. Fixing bugs
    made tests
    break

    View full-size slide

  288. Are those test
    reliable?

    View full-size slide

  289. ¯\_(ツ)_/¯

    View full-size slide

  290. Where do we
    start?

    View full-size slide

  291. Become an
    archeologist

    View full-size slide

  292. Create guides

    View full-size slide

  293. What is a
    source map?

    View full-size slide

  294. Read my
    guide!

    View full-size slide

  295. Good OSS
    maintainers
    steal
    borrow

    View full-size slide

  296. Used other
    projects to
    verify
    Sprockets

    View full-size slide

  297. Encoding
    $ npm install uglify-js

    View full-size slide

  298. Encoding
    $ uglifyjs foo.js
    --source-map foo.js.map
    var foo="foo";var bar="bar";
    //# sourceMappingURL=foo.js.map

    View full-size slide

  299. Decoding
    $ npm install source-map

    View full-size slide

  300. Is it finished?

    View full-size slide

  301. No, need more
    actionable bug
    reports

    View full-size slide

  302. Where do we
    go now?

    View full-size slide

  303. Maintainers
    Won’t be
    around
    forever

    View full-size slide

  304. I
    Won’t be
    around
    forever

    View full-size slide

  305. Help
    maintain the
    history of
    Sprockets

    View full-size slide

  306. Preserve the
    stories

    View full-size slide

  307. Get involved

    View full-size slide

  308. If you won’t,
    who will?

    View full-size slide

  309. We all need to
    step up

    View full-size slide

  310. Take 5
    minutes

    View full-size slide

  311. Create
    example apps

    View full-size slide

  312. A maintainer

    View full-size slide

  313. Save
    Sprockets

    View full-size slide