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

Tooling

 Tooling

Write less code

Scott Barrow

June 19, 2018
Tweet

More Decks by Scott Barrow

Other Decks in Programming

Transcript

  1. Motivation - Knowledge sharing/Lack of cohesion - Promote modularity -

    Decouple responsibility - Separation of concerns - Modular scaling - stop reinventing the wheel - …and many more buzzwords 110 repositories!
  2. Motivation - Knowledge sharing/Lack of cohesion - Promote modularity -

    Decouple responsibility - Separation of concerns - Modular scaling - stop reinventing the wheel - …and many more buzzwords many different ways of writing a CRUD app
  3. Motivation - Knowledge sharing/Lack of cohesion - Promote modularity -

    Decouple responsibility - Separation of concerns - Modular scaling - stop reinventing the wheel - …and many more buzzwords Ruby is modular, object oriented. Leverage ways to abstract code for reuse by others Write as if you intend to abstract later
  4. Motivation - Knowledge sharing/Lack of cohesion - Promote modularity -

    Decouple responsibility - Separation of concerns - Modular scaling - stop reinventing the wheel - …and many more buzzwords But wait, our saviour Sandi Metz says “Duplication is far cheaper than the wrong abstraction”
  5. 1. Programmer A sees duplication.
 2. Programmer A extracts duplication

    and gives it a name.
 This creates a new abstraction. It could be a new method, or perhaps even a new class.
 3. Programmer A replaces the duplication with the new abstraction.
 Ah, the code is perfect. Programmer A trots happily away.
 4. Time passes.
 5. A new requirement appears for which the current abstraction is almost perfect.
 6. Programmer B gets tasked to implement this requirement.
 Programmer B feels honour-bound* to retain the existing abstraction, but since isn't exactly the same for every case, they alter the code to take a parameter, and then add logic to conditionally do the right thing based on the value of that parameter.
 What was once a universal abstraction now behaves differently for different cases.
 7. Another new requirement arrives.
 Programmer X.
 Another additional parameter.
 Another new conditional.
 Loop until code becomes incomprehensible.
 8. You appear in the story about here, and your life takes a dramatic turn for the worse.
 9.
  6. Motivation - Knowledge sharing/Lack of cohesion - Promote modularity -

    Decouple responsibility - Separation of concerns - Modular scaling - stop reinventing the wheel - …and many more buzzwords - payment gateways - sending data to an external API - filtering a recordset by a string or metadata.
  7. Motivation - Knowledge sharing/Lack of cohesion - Promote modularity -

    Decouple responsibility - Separation of concerns - Modular scaling - stop reinventing the wheel - …and many more buzzwords - Easier to test, maintain - Allows for a clean interface - Encapsulation
  8. Motivation - Knowledge sharing/Lack of cohesion - Promote modularity -

    Decouple responsibility - Separation of concerns - Modular scaling - stop reinventing the wheel - …and many more buzzwords “Hey, I saw that you created X for Y and I’d like you to do X for Z… My budget is half a baristas’ annual salary (excluding tips)”
  9. Motivation - Knowledge sharing/Lack of cohesion - Promote modularity -

    Decouple responsibility - Separation of concerns - Modular scaling - stop reinventing the wheel - …and many more buzzwords Short term wins < Long profit Delayed gratification > Instant gratification
  10. Examples - Generic Rest API’s - Indexing and filtering of

    metadata (elastic etc…) - React/Vue Libraries e.g. image galleries - React/Vue components (modular by design) - CSS Themes - Payment services (Service objects) - Notification services - Styleguides - Mockups
  11. Example FZD School of Design The requirements were: - They

    wanted a CMS but not a CMS - The ability to add new images to the site without having to duplicate uploading of images - handle existing 9000+ images - Ability to create pages, with no markup or style experience - An admin area for administrating content (but not complex) - Doesn't want to look like a college or school - Wants Wordpress flexibility, 500px swagger, Indian takeaway website budget
  12. Example https://github.com/ballistiq/media-api - JSON API spec http://jsonapi.org/ - FastJSONAPI -

    https://github.com/Netflix/fast_jsonapi - Carrierwave - SOC unlike paperclip (and not dead) - Fog - S3 backing - Versionist - https://github.com/bploetz/versionist - acts-as-taggable-array-on - https://github.com/tmiyamon/ - swagger-docs - https://github.com/richhollis/swagger-docs - shoulda_matchers - testing schema - RSpec - because its not a stable API without tests
  13. 3 main components to the whole image side of the

    site - MediaManger (admin) - MediaSlider (front page sliders) - MediaGallery (Main gallery with filters) Common Components Main Components 3 shared dependencies - Gallery component (used on Media Manager, Media Gallery) - LinkTag (used on all images) - Searchbar (used on Media Manager and the dropzone)