~~sometimes~~ all the time you find code that makes you go O.o Someone did the weirdest thing, but it works. Probably.
My favorite thing to say in these moments is "But why?". When it's really weird and we're good friends, I post this gif.
You have to be careful with that. It works when trust is super duper extra high and even then you have to be ready to back it up with a good conversation.
Here's a few better ways to ask that question.
- What problem does this solve for you?
- What do you like about this solution?
- Have you tried <obvious approach>?
- I wasn't around for this, can you explain why <obvious approach> wouldn't work here?
- Have you seen <library that solves this problem>?
- I saw this solved a different way in <other part of codebase>. Would that work here?
- In past projects I've done <easier approach>. What do you think of that solution? Would it work here?
Asking "but why" makes people feel judged and puts them on the defensive. Personally I love explaining but why and will talk your ear off. But normal people have a much smaller ego and will shut down when confronted directly.
Instead you approach with obvious curiosity, validate that this is in fact a brilliant solution you would never think of, and ask about all the constraints they were solving for that you didn't know about.
60% chance they tried the obvious solution and it didn't work. That's why the code looks weird. It has to!
Then you ask them to put that answer in a comment.
PS: the last 2 will probably result in a "Oh thanks! I'll do that next time". Let it go, next time is fine
I write articles with real insight into the career and skills of a modern software engineer. "Raw and honest from the heart!" as one reader described them. Fueled by lessons learned over 20 years of building production code for side-projects, small businesses, and hyper growth startups. Both successful and not.
Subscribe below 👇
Join Swizec's Newsletter and get insightful emails 💌 on mindsets, tactics, and technical skills for your career. Real lessons from building production software. No bullshit.
"Man, love your simple writing! Yours is the only newsletter I open and only blog that I give a fuck to read & scroll till the end. And wow always take away lessons with me. Inspiring! And very relatable. 👌"
Senior Mindset Book
Get promoted, earn a bigger salary, work for top companiesLearn 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
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
By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️