Blog
Posts on software development, careers, and craft.
One of my clients creates a custom hook for *every* React component
One of my clients creates a custom hook for *every* React component. So every component is only JSX. Example: User.tsx // Just JSX useUser.ts // Al...
I can’t stop thinking about this quote
I can’t stop thinking about this quote. “Unspoken expectations are premeditated resentments.” - Neil Strauss Succinct, powerful relationship advice...
Problem: Too many browser tabs
Problem: Too many browser tabs. They’re distracting. It’s hard to find the tab I want. Many visible tabs create stress. Two solutions: 1. Topical b...
A bad developer keeps adding complexity until it finally works
A bad developer keeps adding complexity until it finally works. A good developer keeps reducing complexity until it can't be any simpler.
React problem: I want to use a feature flag to call one of two React hooks -...
React problem: I want to use a feature flag to call one of two React hooks - an old one, or a new one that will soon replace it. But, React hooks s...
Feature flag pattern: When replacing an old feature with a new feature via a...
Feature flag pattern: When replacing an old feature with a new feature via a feature flag, avoid changing the old code. Why? Because changing the o...
Problem: Slow pull request reviews Solutions: ✅ Pair program ✅ Open small,...
Problem: Slow pull request reviews Solutions: ✅ Pair program ✅ Open small, focused PRs ✅ Request a real-time review ✅ Request early feedback on dra...
Problem: We have a flaky test that keeps breaking our CI build
Problem: We have a flaky test that keeps breaking our CI build. Solution: Don't repeatedly the CI build hoping a flaky test will pass. Instead: 1....
I see some React apps using useMemo everywhere
I see some React apps using useMemo everywhere. Don't. useMemo is rarely necessary. It makes code harder to read. React compiler is coming later th...
I'm creating the same app using a variety of third-party React state...
I'm creating the same app using a variety of third-party React state management libraries. The tradeoffs in PR diffs are enlightening. I'm eager to...
I disagree with the majority here
I disagree with the majority here. There are 4 reasons to choose an anchor over a button in this scenario: 1. Semantics. If it changes the url, it’...
Why I prefer const over let: ✅ const provides me extra cues because const is...
Why I prefer const over let: ✅ const provides me extra cues because const is more “narrow” than let. Just like in TypeScript, I favor narrow types...
Rushing developers creates a downward spiral of quality
Rushing developers creates a downward spiral of quality. When developers feel rushed, they cut corners. Stress makes us less creative too, so we ta...
In TypeScript apps, if something is hard to type, my design is probably wrong
In TypeScript apps, if something is hard to type, my design is probably wrong. Sure, reusable libraries are often hard to type. But *app* code shou...
Problem: “Duplication is often better than the wrong abstraction”
Problem: “Duplication is often better than the wrong abstraction”. Solution: I typically abstract via small, focused, pure functions. A pure functi...
“Duplicated code is often better than wrong abstraction.” “Excessive...
“Duplicated code is often better than wrong abstraction.” “Excessive copy/paste bloats the code, hurts consistency, slows reading, increases bug ri...
In the last 10 years I think the change that has most improved my web...
In the last 10 years I think the change that has most improved my web development experience is moving from JavaScript to TypeScript. I haven't see...
Problem: I want to show a spinner if any React Query mutations are in progress
Problem: I want to show a spinner if any React Query mutations are in progress. Solution: useIsMutating. This hook returns true if any mutations ar...
Sometimes the divide between the backend and frontend leads to massive waste
Sometimes the divide between the backend and frontend leads to massive waste. Example: I'm looking at a web page that displays 6 numbers. Sounds si...
Problem: Fetching in useEffect is clunky, verbose, and error prone
Problem: Fetching in useEffect is clunky, verbose, and error prone. Solution: Use one of these instead: 1. React Server Components 2. Tanstack Quer...
Challenge: Name something that a software developer should *always* do
Challenge: Name something that a software developer should *always* do. Is there a single practice that always applies? "Write tests". Not always w...
Scenario: You’re using React Server Components, so you can query the DB in a...
Scenario: You’re using React Server Components, so you can query the DB in a server component. Your app is the DB’s only consumer. Do you query the...
Problem: You want to find copy/pasted code
Problem: You want to find copy/pasted code. Solution: jscpd. It finds copy/pasted code in over 150 languages. I just ran this command on a JS proje...
Early in my career, when someone would interrupt me while coding, it would...
Early in my career, when someone would interrupt me while coding, it would stress me out. I felt like I had a house of cards in my head. So it was...
Wanna speed up your TypeScript builds and improve your IDE's TypeScript...
Wanna speed up your TypeScript builds and improve your IDE's TypeScript language server performance? Replace type intersections with interfaces. He...
Accessibility mistake: Putting an aria-label on a non-interactive element
Accessibility mistake: Putting an aria-label on a non-interactive element. An aria-label is for *interactive* elements like a button or a link. So,...
Problem: You want type-safe mock responses
Problem: You want type-safe mock responses. Solution: 1. Create an object literal. 2. Use keys to describe each response. 3. Narrow the type via 'a...
You don’t need a service provider to do feature flags
You don’t need a service provider to do feature flags. There are many simple ways to toggle a feature: -Comment out code -Hide the feature’s link -...
Just finished the book “What’s Our Problem” by @waitbutwhy
Just finished the book “What’s Our Problem” by @waitbutwhy. America’s problem isn’t the left or the right. America’s problem is “low-rung”, “us vs...
Scenario: You're mocking HTTP calls in automated tests
Scenario: You're mocking HTTP calls in automated tests. Question: Do your tests reference the mock data structure? Or do you hard-code the expected...