Swizec Teller - a geek with a hatswizec.com

    The Magic Function principle

    "Hey how does the foobulizer work again?"

    Ugh not this again. You've been answering this same damn question for months. How are they still not getting it?? πŸ™„

    It's simple!

    You take the gnasher, connect it to the third function call from the left on a full moon, or the fourth one from top, if it's Sunday, then you plug into the fantalizer, add 3 lines of code using the in-house configuration language built from JSON, stand on your right leg, hold the left nostril, and voila: the foobulizer.

    I mean seriously, are they all stupid?

    Write the docs

    Your team is smart.

    When you get (or ask) the same question over and over, that's a symptom. The problem is the codebase. Or the architecture. Or the data model. Or the docs.

    Your team can't help itself. They need you.

    Fantastic job security aaaaand that's why senior engineers get nothing done. There's no time. πŸ’©

    When you answer the same question 3 times, write it down. Share the link.

    When they ask again, edit and share the link.

    Your doc won't always answer all the nuance of a question but it helps. Gets you on common ground, makes the chat more productive.

    Swizec Teller published ServerlessHandbook.dev avatarSwizec Teller published ServerlessHandbook.dev@Swizec
    If your team keeps asking a question, write a doc.

    If they keep asking, build the magic function that does the thing. Make it [easily] discoverable in your codebase.

    If you don't, they *will* find the wrong way πŸ˜‰

    #seniormindset

    And the more you write, the less you have to keep in your head. Mine has the memory of a goldfish πŸ˜‡

    The Senior Mindset series

    Get a series of curated essays on the mindset of a senior software engineer. What it takes to get there, what should you do when you're there, how to change the way you think.

    it describes my days in a way I have not read before.

    This was a very enlightening article about being a senior engineer.

    Join over 14,000 engineers just like you already improving their careers with my letters, workshops, courses, and talks. ✌️

    The Magic Function

    You know what's even better than up-to-date docs? Not needing docs.

    Imagine if instead of a complex 6 step process you could start the foobulizer with startFoobulizer().

    We used to have this problem at work. We still do but not with that part πŸ˜›

    The Magic Function saved my butt

    Verifying insurance was my first introduction to "Holy shit health tech is something else".

    The process goes like this: Get your info, maybe use what exists, talk to an API, see if it's valid, check a sea of inscrutable codes, decide if your insurance supports this appointment at this time (yes it changes), and a bunch other details.

    You don't want to deal with this as a user.

    Heck, I didn't wanna deal with it as a programmer! Confusing, terrible, makes-no-sense.

    We had an Insurance module, but it was hard to hold. You had to call the right functions in the right sequence at the right time.

    Get it wrong and the company doesn't get paid.

    I got it wrong. Five times πŸ˜…

    Edge case after edge case, bug after bug, meeting after meeting. 3 of us working on this stupid thing.

    We had docs, we had code, yet we couldn't make it work.

    Until one day the dude who grokked the business logic said "Screw this, this is bullshit."

    He built a new function: Insurance.verify(user, appointment).

    And oh my god it was beautiful. Cut through all the crap. You call this method, give it a user and an appointment, and it does it all for you. Standing on the right leg holding its left nostril and all! 😍

    Nobody has asked an insurance question since.

    Why The Magic Function works

    The Magic Function is a high level method that does the thing the whole thing and nothing but the thing.

    Forget reading and understanding docs. Forget writing and updating docs. Just make it work.

    Swizec Teller published ServerlessHandbook.dev avatarSwizec Teller published ServerlessHandbook.dev@Swizec
    Why is it called The Magic Function principle?

    Because of this quote from Penn & Teller. *you* do the work so the rest of your team doesn't have to
    Tweet media

    You do the work so your team doesn't have to. Like Penn & Teller say:

    Sometimes magic is just someone spending more time on something than anyone else might reasonably expect. ~ Teller of Penn&Teller fame

    You write The Magic Function when you see that code always goes together. You always make this DB update after that API call. You always call these 3 functions together. You always ...

    The Magic Function frees your team from that complexity. Instead of worrying about the details, they focus on their problem. πŸ§™

    Best part: they'll find your function on their own. No questions, no confusion.

    Engineers always find a way. Help them find the way.

    Ye olde unix philosophy??

    The opposite of The Magic Function is the unix philosophy – lots of small composable utilities.

    Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new "features". Expect the output of every program to become the input to another, as yet unknown, program

    How you read this depends on your idea of "one thing".

    Is one thing to verify insurance, or to call an API for 1 out of 50 different ways it needs to be called depending on circumstance? πŸ€”

    It's fractal. Single responsibility all the way down. A magic function calls other magic functions.

    You wouldn't wanna think about optimizing DOM updates to draw a button, just like your HTML rendering shouldn't think about where the HTML is from.

    Write functions, mostly magic. Think fractals.

    ✌️

    Cheers,
    ~Swizec

    PS: how to start a 1928 Ford is a 20min video. These days you press a button and go. When's the last time you read the instruction manual for a car?

    Did you enjoy this article?

    Published on February 5th, 2021 in Technical, Architecture, Mindset

    Want to become a true senior engineer?

    Getting that senior title is easy. Just stick around. Being a true senior takes a new way of thinking. Do you have it?

    Leave your email and get the Senior Mindset series - a series of curated essays on the mindset of a senior software engineer. What it takes to get there, what should you do when you're there, how to change the way you think.

    The Senior Mindset series

    Get a series of curated essays on the mindset of a senior software engineer. What it takes to get there, what should you do when you're there, how to change the way you think.

    it describes my days in a way I have not read before.

    This was a very enlightening article about being a senior engineer.

    Join over 14,000 engineers just like you already improving their careers with my letters, workshops, courses, and talks. ✌️

    Have a burning question that you think I can answer?Β I don't have all of the answers, but I have some! Hit me up on twitter or book a 30min ama for in-depth help.

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

    Curious about Serverless and the modern backend? Check out Serverless Handbook, modern backend for the frontend engineer.

    Ready to learn how it all fits together and build a modern webapp from scratch? Learn how to launch a webapp and make your first πŸ’° on the side with ServerlessReact.Dev

    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 bySwizecwith ❀️