SlideShare a Scribd company logo
1 of 50
Two Households,
Both Alike In Dignity
A Not-So-Tragedy of Refactoring
Front-end APIs
Julia Nguyen - @fleurchild
InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese and Brazilian
Portuguese)
• Post content from our QCon conferences
• News 15-20 / week
• Articles 3-4 / week
• Presentations (videos) 12-15 / week
• Interviews 2-3 / week
• Books 1 / month
Watch the video with slide
synchronization on InfoQ.com!
https://www.infoq.com/presentations/
front-end-api-technical-debt
Presented at QCon New York
www.qconnewyork.com
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
Julia Nguyen
@fleurchild
Founder @ifmeorg
Storyteller @mhprompt
Organizer @wscsf
Developer @indiegogo
Prologue
● Backer Experience and Trust Team
● Tech stack
○ Back-end: Ruby on Rails
○ Front-end: Angular 1, TypeScript (recent)
Indiegogo is more
than crowdfunding
Perk = Product?
Act I
C.R.E.A.M.
Capulets: Items and Options
Montagues: Apple Pay
Act II
An Apple. A Pay.
Too many modals!
Act III
Starcrossed Perks
All of the perks!
Act IV
A Wedding
Primary Goal
Server-side Cleanup
Serializer
Picks certain attributes from model
Serializers can be exposed from the
controller
Resource (???)
Contains logic for dealing with
attributes, so you don’t have duplicate
logic between serializers
SimpleDelegator
A Ruby class that implements the
decorator pattern.
Decorator Pattern
A design pattern that allows behaviour
to be added to a single object without
affecting other objects of the same class
Is an example of separation of
concerns!
Two Perk Serializers
private_api/perk_serializer.rb
- Regular perk
- Querying methods found in the
serializer
- Exposed in
campaign_perks_controller.rb
private_api/commerce/perk_serializer.rb
- Perk with items and options
- Querying methods found in
/lib/commerce/resources/perk.rb
- Exposed in
perk_items_controller.rb
Example of duplication: shipping_fees method
- Create BasePerkSerializer to be the parent serializer for perks
- Place shared attributes
- Initialize resource (SimpleDelegator) in that serializer, don’t need a
separate controller
Base Perk Serializer
Client-side Cleanup
Angular Architecture
js/client
A place for services
that make API calls
One Type to Rule Them All
- Create Perk typing and related typings like PerkItem in
js/client/perks/types.ts
- Get rid of PerkJSON and PerkFactoryPerk, replace with Perk
Settle on Attributes, Remove Duplication
- PerkFactory is sort of misleading, only calculated shipping fees
- Converted between shipping.fees and shipping_fees
- Refactor PerkFactory, eliminate shipping.fees and use shipping_fees
- Convert PerkFactory to TypeScript
- perk-factory.js was 342 lines
- Perk-factory.ts is 182 lines
A Good Fake Death!
Refactoring Front-end APIs in Summary
- Start from the server-side and move to the client-side, you will uncover more
- Use serializers! You don’t usually need all of the data!
- Consolidate serializers and remove duplication through the decorator pattern
- Model attribute names should be consistent between the server-side and client-side
- Consolidate services that make the same API calls, make them importable modules!
Act V
Postmortem
Technical Debt
Extra development work that arises
when code that is easy to implement in
the short run is used instead of
applying the best overall solution
Tackling debt “as you go” reduces debt
and prevents debt from accruing
Can’t Refactor Everything, But You Can Document It
Tackling Technical Debt in Summary
- Better to investigate technical debt at the beginning of a project than discover it later
- Account for technical debt in sprint planning, integrate it in the pull request process
(it’s not just a backlog issue)
- Get your PM involved in the process, even if they are non-technical
- Ask lots of questions from developers who have worked with the codebase for longer
(people skills people!)
- Tackle your refactoring in bite-sized chunks, easier to undo if you mess up
Useful Resources
Sandi Metz' Rules for Developers
Refactoring.com by Martin Fowler
"Don't reset --hard: Strategies for Tackling Large Refactors" by Siena Aguayo
"7 Design Patterns to Refactor MVC Components in Rails" by Viktoria
Kotsurenko
"JavaScript Factory Functions vs Constructor Functions vs Classes" by Eric
Elliott
Could tackling technical debt
have saved Romeo + Juliet?
If the Capulets and Montagues got their shit
together, quite possibly
But maybe the ~*drama*~ made their
relationship?
Let’s tackle technical debt like
we’re Mercutio and it’s 1996
@fleurchild
Watch the video with slide synchronization on
InfoQ.com!
https://www.infoq.com/presentations/front-
end-api-technical-debt

More Related Content

What's hot

Documentation-driven development for Python web APIs v2
Documentation-driven development for Python web APIs v2Documentation-driven development for Python web APIs v2
Documentation-driven development for Python web APIs v2
José Haro Peralta
 
Documentation-driven development for Python web APIs
Documentation-driven development for Python web APIsDocumentation-driven development for Python web APIs
Documentation-driven development for Python web APIs
José Haro Peralta
 
Lessons learned: Choosing your documentation system
Lessons learned: Choosing your documentation systemLessons learned: Choosing your documentation system
Lessons learned: Choosing your documentation system
Pronovix
 

What's hot (20)

Charlotte DevOpsDays 2020 - building a service delivery infrastructure
Charlotte DevOpsDays 2020 - building a service delivery infrastructure  Charlotte DevOpsDays 2020 - building a service delivery infrastructure
Charlotte DevOpsDays 2020 - building a service delivery infrastructure
 
API Conference 2021
API Conference 2021API Conference 2021
API Conference 2021
 
apidays LIVE New York 2021 - Designing API's: Less Data is More! by Damir Svr...
apidays LIVE New York 2021 - Designing API's: Less Data is More! by Damir Svr...apidays LIVE New York 2021 - Designing API's: Less Data is More! by Damir Svr...
apidays LIVE New York 2021 - Designing API's: Less Data is More! by Damir Svr...
 
CheConf18.2 Swapping IDEs in Eclipse Che 7
CheConf18.2 Swapping IDEs in Eclipse Che 7CheConf18.2 Swapping IDEs in Eclipse Che 7
CheConf18.2 Swapping IDEs in Eclipse Che 7
 
Documentation-driven development for Python web APIs v2
Documentation-driven development for Python web APIs v2Documentation-driven development for Python web APIs v2
Documentation-driven development for Python web APIs v2
 
Advancing Your API Strategy in an Infrastructure World
Advancing Your API Strategy in an Infrastructure WorldAdvancing Your API Strategy in an Infrastructure World
Advancing Your API Strategy in an Infrastructure World
 
Rest in practice
Rest in practiceRest in practice
Rest in practice
 
Why your APIs should fly first class
Why your APIs should fly first classWhy your APIs should fly first class
Why your APIs should fly first class
 
PyBCN 2020
PyBCN 2020PyBCN 2020
PyBCN 2020
 
Documentation-driven development for Python web APIs
Documentation-driven development for Python web APIsDocumentation-driven development for Python web APIs
Documentation-driven development for Python web APIs
 
Delivering successful API integrations with documentation-driven development
Delivering successful API integrations with documentation-driven developmentDelivering successful API integrations with documentation-driven development
Delivering successful API integrations with documentation-driven development
 
The Effect of Microservices on API Design
The Effect of Microservices on API DesignThe Effect of Microservices on API Design
The Effect of Microservices on API Design
 
Lessons Learned from Revamping Our Doc Site
Lessons Learned from Revamping Our Doc SiteLessons Learned from Revamping Our Doc Site
Lessons Learned from Revamping Our Doc Site
 
Serverless Architecture
Serverless ArchitectureServerless Architecture
Serverless Architecture
 
API SDK Development – Lessons Learned
API SDK Development – Lessons LearnedAPI SDK Development – Lessons Learned
API SDK Development – Lessons Learned
 
A guide to hiring a great developer to build your first app (redacted version)
A guide to hiring a great developer to build your first app (redacted version)A guide to hiring a great developer to build your first app (redacted version)
A guide to hiring a great developer to build your first app (redacted version)
 
Lessons learned: Choosing your documentation system
Lessons learned: Choosing your documentation systemLessons learned: Choosing your documentation system
Lessons learned: Choosing your documentation system
 
Designing APIs with OpenAPI Spec
Designing APIs with OpenAPI SpecDesigning APIs with OpenAPI Spec
Designing APIs with OpenAPI Spec
 
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
 
Get your mobile app in production in 3 months: DevOps and Infrastructure
Get your mobile app in production in 3 months: DevOps and InfrastructureGet your mobile app in production in 3 months: DevOps and Infrastructure
Get your mobile app in production in 3 months: DevOps and Infrastructure
 

Similar to Refactor Front-end APIs & Accounting for Tech Debt

The Art and Science of Requirements Gathering
The Art and Science of Requirements GatheringThe Art and Science of Requirements Gathering
The Art and Science of Requirements Gathering
Vanessa Turke
 
Heroku for-team-collaboration
Heroku for-team-collaborationHeroku for-team-collaboration
Heroku for-team-collaboration
John Stevenson
 
20141210 - Microservice Container
20141210 - Microservice Container20141210 - Microservice Container
20141210 - Microservice Container
Jamie (Taka) Wang
 
How to Migrate Applications Off a Mainframe
How to Migrate Applications Off a MainframeHow to Migrate Applications Off a Mainframe
How to Migrate Applications Off a Mainframe
VMware Tanzu
 
Record matching over query results
Record matching over query resultsRecord matching over query results
Record matching over query results
ambitlick
 

Similar to Refactor Front-end APIs & Accounting for Tech Debt (20)

Poor Man's Kanban
Poor Man's KanbanPoor Man's Kanban
Poor Man's Kanban
 
Mobile and agile the floating writer's survival kit
Mobile and agile   the floating writer's survival kitMobile and agile   the floating writer's survival kit
Mobile and agile the floating writer's survival kit
 
Status Quo on the automation support in SOA Suite OGhTech17
Status Quo on the automation support in SOA Suite OGhTech17Status Quo on the automation support in SOA Suite OGhTech17
Status Quo on the automation support in SOA Suite OGhTech17
 
The Art and Science of Requirements Gathering
The Art and Science of Requirements GatheringThe Art and Science of Requirements Gathering
The Art and Science of Requirements Gathering
 
Heroku for team collaboration
Heroku for team collaborationHeroku for team collaboration
Heroku for team collaboration
 
Heroku for-team-collaboration
Heroku for-team-collaborationHeroku for-team-collaboration
Heroku for-team-collaboration
 
Professionalizing the Front-end
Professionalizing the Front-endProfessionalizing the Front-end
Professionalizing the Front-end
 
20141210 - Microservice Container
20141210 - Microservice Container20141210 - Microservice Container
20141210 - Microservice Container
 
Automation for the Humans
Automation for the HumansAutomation for the Humans
Automation for the Humans
 
Measure and Increase Developer Productivity with Help of Serverless at Server...
Measure and Increase Developer Productivity with Help of Serverless at Server...Measure and Increase Developer Productivity with Help of Serverless at Server...
Measure and Increase Developer Productivity with Help of Serverless at Server...
 
How to Migrate Applications Off a Mainframe
How to Migrate Applications Off a MainframeHow to Migrate Applications Off a Mainframe
How to Migrate Applications Off a Mainframe
 
Optimus XPages: An Explosion of Techniques and Best Practices
Optimus XPages: An Explosion of Techniques and Best PracticesOptimus XPages: An Explosion of Techniques and Best Practices
Optimus XPages: An Explosion of Techniques and Best Practices
 
Agile Secure Cloud Application Development Management
Agile Secure Cloud Application Development ManagementAgile Secure Cloud Application Development Management
Agile Secure Cloud Application Development Management
 
Object oriented software_engg
Object oriented software_enggObject oriented software_engg
Object oriented software_engg
 
Driving Enterprise Architecture Redesign: Cloud-Native Platforms, APIs, and D...
Driving Enterprise Architecture Redesign: Cloud-Native Platforms, APIs, and D...Driving Enterprise Architecture Redesign: Cloud-Native Platforms, APIs, and D...
Driving Enterprise Architecture Redesign: Cloud-Native Platforms, APIs, and D...
 
Driving Enterprise Architecture Redesign: Cloud-Native Platforms, APIs, and D...
Driving Enterprise Architecture Redesign: Cloud-Native Platforms, APIs, and D...Driving Enterprise Architecture Redesign: Cloud-Native Platforms, APIs, and D...
Driving Enterprise Architecture Redesign: Cloud-Native Platforms, APIs, and D...
 
Rapid Application Development with MEAN Stack
Rapid Application Development with MEAN StackRapid Application Development with MEAN Stack
Rapid Application Development with MEAN Stack
 
Exploiting the value of Dublin Core through pragmatic development
Exploiting the value of Dublin Core through pragmatic developmentExploiting the value of Dublin Core through pragmatic development
Exploiting the value of Dublin Core through pragmatic development
 
Introduction to Software Engineering
Introduction to Software EngineeringIntroduction to Software Engineering
Introduction to Software Engineering
 
Record matching over query results
Record matching over query resultsRecord matching over query results
Record matching over query results
 

More from C4Media

More from C4Media (20)

Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoStreaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live Video
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy Mobile
 
Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java Applications
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No Keeper
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like Owners
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate Guide
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CD
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine Learning
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at Speed
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep Systems
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.js
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix Scale
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's Edge
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home Everywhere
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing For
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data Engineering
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 

Refactor Front-end APIs & Accounting for Tech Debt

  • 1. Two Households, Both Alike In Dignity A Not-So-Tragedy of Refactoring Front-end APIs Julia Nguyen - @fleurchild
  • 2. InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month Watch the video with slide synchronization on InfoQ.com! https://www.infoq.com/presentations/ front-end-api-technical-debt
  • 3. Presented at QCon New York www.qconnewyork.com Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide
  • 4. Julia Nguyen @fleurchild Founder @ifmeorg Storyteller @mhprompt Organizer @wscsf Developer @indiegogo
  • 5.
  • 6. Prologue ● Backer Experience and Trust Team ● Tech stack ○ Back-end: Ruby on Rails ○ Front-end: Angular 1, TypeScript (recent)
  • 7. Indiegogo is more than crowdfunding
  • 9.
  • 11.
  • 12.
  • 15.
  • 16.
  • 18.
  • 21. All of the perks!
  • 22.
  • 25.
  • 27. Serializer Picks certain attributes from model Serializers can be exposed from the controller
  • 28. Resource (???) Contains logic for dealing with attributes, so you don’t have duplicate logic between serializers
  • 29. SimpleDelegator A Ruby class that implements the decorator pattern. Decorator Pattern A design pattern that allows behaviour to be added to a single object without affecting other objects of the same class Is an example of separation of concerns!
  • 30. Two Perk Serializers private_api/perk_serializer.rb - Regular perk - Querying methods found in the serializer - Exposed in campaign_perks_controller.rb private_api/commerce/perk_serializer.rb - Perk with items and options - Querying methods found in /lib/commerce/resources/perk.rb - Exposed in perk_items_controller.rb Example of duplication: shipping_fees method
  • 31. - Create BasePerkSerializer to be the parent serializer for perks - Place shared attributes - Initialize resource (SimpleDelegator) in that serializer, don’t need a separate controller Base Perk Serializer
  • 32.
  • 35. js/client A place for services that make API calls
  • 36.
  • 37. One Type to Rule Them All - Create Perk typing and related typings like PerkItem in js/client/perks/types.ts - Get rid of PerkJSON and PerkFactoryPerk, replace with Perk
  • 38. Settle on Attributes, Remove Duplication - PerkFactory is sort of misleading, only calculated shipping fees - Converted between shipping.fees and shipping_fees - Refactor PerkFactory, eliminate shipping.fees and use shipping_fees - Convert PerkFactory to TypeScript - perk-factory.js was 342 lines - Perk-factory.ts is 182 lines
  • 39. A Good Fake Death!
  • 40.
  • 41. Refactoring Front-end APIs in Summary - Start from the server-side and move to the client-side, you will uncover more - Use serializers! You don’t usually need all of the data! - Consolidate serializers and remove duplication through the decorator pattern - Model attribute names should be consistent between the server-side and client-side - Consolidate services that make the same API calls, make them importable modules!
  • 43.
  • 44. Technical Debt Extra development work that arises when code that is easy to implement in the short run is used instead of applying the best overall solution Tackling debt “as you go” reduces debt and prevents debt from accruing
  • 45. Can’t Refactor Everything, But You Can Document It
  • 46. Tackling Technical Debt in Summary - Better to investigate technical debt at the beginning of a project than discover it later - Account for technical debt in sprint planning, integrate it in the pull request process (it’s not just a backlog issue) - Get your PM involved in the process, even if they are non-technical - Ask lots of questions from developers who have worked with the codebase for longer (people skills people!) - Tackle your refactoring in bite-sized chunks, easier to undo if you mess up
  • 47. Useful Resources Sandi Metz' Rules for Developers Refactoring.com by Martin Fowler "Don't reset --hard: Strategies for Tackling Large Refactors" by Siena Aguayo "7 Design Patterns to Refactor MVC Components in Rails" by Viktoria Kotsurenko "JavaScript Factory Functions vs Constructor Functions vs Classes" by Eric Elliott
  • 48. Could tackling technical debt have saved Romeo + Juliet? If the Capulets and Montagues got their shit together, quite possibly But maybe the ~*drama*~ made their relationship?
  • 49. Let’s tackle technical debt like we’re Mercutio and it’s 1996 @fleurchild
  • 50. Watch the video with slide synchronization on InfoQ.com! https://www.infoq.com/presentations/front- end-api-technical-debt