Share
Embed
Transcript
39 slides
-
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! -
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 -
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 -
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” -
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. -
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. -
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 -
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)” -
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 -
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 -
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 -
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 -
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)