Swizec Teller - a geek with a hatswizec.com

Senior Mindset Book

Get promoted, earn a bigger salary, work for top companies

Senior Engineer Mindset cover
Learn more

    When to throw away your code

    Last week I mentioned that "code is expensive" and a reader – Dakshin – wrote back saying "Wait, if code is expensive, why are you throwing it away??"

    Their question was about the second example in What does "solve problems" even mean, throwing away a wrapper library and using the vendor SDK as a way to unblock 5 teams. My thesis is that without this library, teams will be able to move independently and control their destiny.

    And Dakshin is right! We have this working code that solves problems and people have put good effort into building. So why do I wanna throw it away?

    I love deleting code. Nothing brings more joy than grabbing a bunch of code you don't need anymore and throwing it away.

    Like when you spend 3 hours working on a tough problem, write a bunch of code to figure it out, then realize you can do it all in 2 lines of code with a different approach. Cmd+A, delete.

    Context matters

    But in this case it's even simpler – the library has outlived its purpose. Now it creates more problems than it solves.

    Its main value-add was cleaning personal information from feature flag requests. We don't need that anymore thanks to signing the right pieces of paper with the new vendor.

    My team owns 43% of all feature flags and we never adopted the library. Before the library, we used to call the backend. Then the backend updated to use this library ... and we kept our old approach because it worked.

    That means half the library's code was never exercised. Who knows if it even works πŸ€·β€β™‚οΈ

    And the iOS team was always on their own. You wouldn't want a shared library between TypeScript and iOS anyway.

    A third of our ecosystem uses this library. Suddenly feels like a much easier decision doesn't it?

    And consider this: What happens when the library everyone's using upgrades to the new vendor, but the individual teams aren't ready to migrate their feature flags? Mayhem.

    Instead of mayhem, we can let old flags keep using the old library and vendor while new flags gradually start using the new vendor directly. Separate dependencies ✌️

    So, when do you delete code?

    All code is a liability. Cheap to produce, expensive to maintain. It's not a work of art, it's a tool to achieve a goal.

    Delete when it stops providing value. It's just code, you'll write more tomorrow.

    Cheers,
    ~Swizec

    Published on June 19th, 2023 in Reader question, Software Engineering, Lessons

    Did you enjoy this article?

    Continue reading about When to throw away your code

    Semantically similar articles hand-picked by GPT-4

    Senior Mindset Book

    Get promoted, earn a bigger salary, work for top companies

    Learn more

    Have a burning question that you think I can answer? Hit me up on twitter and I'll do my best.

    Who am I and who do I help? I'm Swizec Teller and I turn coders into engineers with "Raw and honest from the heart!" writing. No bullshit. Real insights into the career and skills of a modern software engineer.

    Want to become a true senior engineer? Take ownership, have autonomy, and be a force multiplier on your team. The Senior Engineer Mindset ebook can help πŸ‘‰ swizec.com/senior-mindset. These are the shifts in mindset that unlocked my career.

    Curious about Serverless and the modern backend? Check out Serverless Handbook, for frontend engineers πŸ‘‰ ServerlessHandbook.dev

    Want to Stop copy pasting D3 examples and create data visualizations of your own? Learn how to build scalable dataviz React components your whole team can understand with React for Data Visualization

    Want to get my best emails on JavaScript, React, Serverless, Fullstack Web, or Indie Hacking? Check out swizec.com/collections

    Did someone amazing share this letter with you? Wonderful! You can sign up for my weekly letters for software engineers on their path to greatness, here: swizec.com/blog

    Want to brush up on your modern JavaScript syntax? Check out my interactive cheatsheet: es6cheatsheet.com

    By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❀️

    Created by Swizec with ❀️