Full Width [alt+shift+f] Shortcuts [alt+shift+k]
Sign Up [alt+shift+s] Log In [alt+shift+l]

Vladimir Klepov as a Coder

Vladimir Klepov as a...
Growing my team 4x has been a pain. Can we do better? My name is Vladimir, and I'm an engineering manager of a team building a banking app. Following the...
10 months ago
27
10 months ago
My name is Vladimir, and I'm an engineering manager of a team building a banking app. Following the success of our core banking product, we've decided to expand to other financial services. In the last four months my team has grown 4x, going from a 4-person team to 4 teams...
Vladimir Klepov as a...
How to timeout a promise Timeouts are one of the key building blocks to make your app stable. In short, if you send a request...
over a year ago
24
over a year ago
Timeouts are one of the key building blocks to make your app stable. In short, if you send a request to an endpoint and a response does not, for whatever reason, come soon, we act as if the request failed and fall back to plan B — try again, show an error message and let the user...
Vladimir Klepov as a...
The complete guide to safe type narrowing in TypeScript Say I'm building a TODO app with two tabs: done and pending tasks. To make the app routable, I put...
over a year ago
19
over a year ago
Say I'm building a TODO app with two tabs: done and pending tasks. To make the app routable, I put the active tab into the ?tab query parameter, so that mytodo.io?tab=done takes me directly to the done tasks. I implement routing like this (pardon my hand-coded querystring...
Vladimir Klepov as a...
How to increase test coverage FAST The second quarter is coming to an end. I suppose a lot of my fellow developers are struggling to...
over a year ago
18
over a year ago
The second quarter is coming to an end. I suppose a lot of my fellow developers are struggling to meet their ambitious KPI of "20% more test coverage". Fear not — I'll show you a couple of neat tricks that will up your coverage game in no time, so that you can go on with your...
Vladimir Klepov as a...
From engineer to manager: what I love, what I hate It's been almost 2 years since I moved to a team lead role, then to a full-time engineering...
a year ago
17
a year ago
It's been almost 2 years since I moved to a team lead role, then to a full-time engineering management position after the expansion of our team. I've been a front-end developer for 7 years before that, and initially I took the "advanced individual contributor" career track before...
Vladimir Klepov as a...
Build better libraries, use dev warnings Suppose you're making a cool library that sums numbers in an array. You add a new option, inital,...
over a year ago
17
over a year ago
Suppose you're making a cool library that sums numbers in an array. You add a new option, inital, that lets users specify an initial value for the summation: sum([1, 1, 1], { inital: 10 }) // 13 Oh no! You made a typo — of course you meant initial, not inital. What's done is...
Vladimir Klepov as a...
Can we useRef, but without the .current? Let's try! Ah, ref.current. Everybody knows that I love useRef — I've built custom useMemo with it, and I've...
over a year ago
17
over a year ago
Ah, ref.current. Everybody knows that I love useRef — I've built custom useMemo with it, and I've used it instead of useState to optimize re-renders. But typing ref.current over and over is just annoying. Come on, Vladimir, startX.current is just the same as this.startX in a...
Vladimir Klepov as a...
Let's Make Software Better My previous post, a classic rant, how-bad-software-is-these-days kind, attracted unexpected and...
over a year ago
17
over a year ago
My previous post, a classic rant, how-bad-software-is-these-days kind, attracted unexpected and probably even unreasonable attention. This time I'm in for something different — I'm going to preach. Behold, and open your eyes, and open your hearts, and open your minds, as I am...
Vladimir Klepov as a...
The most useful programming language Aspiring developers often ask me what's the best programming language to learn. Personally, I mostly...
a year ago
17
a year ago
Aspiring developers often ask me what's the best programming language to learn. Personally, I mostly work with JS — solid choice, but everyone and their dog learns JS these days, so it might be time to add some diversity. I'm curious — which single programming language covers the...
Vladimir Klepov as a...
I conducted 60 interviews in 2 months — here's what I learned It's hard to believe, but, starting mid-october 2023 I conducted 60 technical interviews and hired...
a year ago
16
a year ago
It's hard to believe, but, starting mid-october 2023 I conducted 60 technical interviews and hired 10 people into our team. It's been extremely tiring: around 80 hours of active interviewing, plus writing interview reports, plus screening CVs and take-home assignments, plus...
Vladimir Klepov as a...
How to destroy your app performance using React contexts useContext hook has made React Context API so pleasant to work with that many people are even...
over a year ago
16
over a year ago
useContext hook has made React Context API so pleasant to work with that many people are even suggesting that we drop external state management solutions and rely on the built-in alternative instead. This is dangerous thinking that can easily push your app's performance down the...
Vladimir Klepov as a...
Svelte reactivity — an inside and out guide I've been working with svelte exclusively for a year now, but I still manage to shoot myself in the...
a year ago
16
a year ago
I've been working with svelte exclusively for a year now, but I still manage to shoot myself in the foot every now and then when using reactive state. Some of the confusion is due to my prior experience with React, but some points are confusing on their own. Today, I dive into...
Vladimir Klepov as a...
How we made our pre-commit check 7x faster As a guy who's somewhat responsible for a large chunk of front-end development infrastructure at our...
over a year ago
16
over a year ago
As a guy who's somewhat responsible for a large chunk of front-end development infrastructure at our company, I've spent the last couple of months woried about the performance of our pre-commit checks. We have around 50 projects on a standard react + typescript stack, and a...
Vladimir Klepov as a...
Cleaner ways to build dynamic JS arrays Building dynamic arrays in JS is often messy. It goes like this: you have a default array, and you...
over a year ago
16
over a year ago
Building dynamic arrays in JS is often messy. It goes like this: you have a default array, and you need some items to appear based on a condition. So you add an if (condition) array.push(item). Then you need to shuffle things around and bring in an unshift or two, and maybe even...
Vladimir Klepov as a...
Keep a React component mounted The second most important React optimization technique after shouldComponentUpdate and friends is...
over a year ago
16
over a year ago
The second most important React optimization technique after shouldComponentUpdate and friends is remount management. Some portions of the UI can be hidden or shown — sidebars, drop-down menus, modals and draggable widgets are all prominent examples. The basic React pattern for...
Vladimir Klepov as a...
How to replace useState with useRef and be a winner React state is the bread and butter of a react app — it's what makes your app dynamic. React state...
over a year ago
16
over a year ago
React state is the bread and butter of a react app — it's what makes your app dynamic. React state lives in useState, useReducer or in this.state of a class component, and changing it updates your app. But then there's a vast ocean of state not managed by React. This includes...
Vladimir Klepov as a...
Quick Tip: docx is a zip Archive Microsof Office's docx files are actually zip archives with a bunch of XMLs and all the attached...
over a year ago
16
over a year ago
Microsof Office's docx files are actually zip archives with a bunch of XMLs and all the attached media. Super useful, everyone should know it! When I tell my colleagues, friends, or students about it, they don't take me seriously the first time. So, here we go again. If you have...
Vladimir Klepov as a...
Is your babel's transform-runtime getting lazy? You better check. IE11 is not dead yet, and our library is supposed to run there and make russian grandmas happy. As...
over a year ago
16
over a year ago
IE11 is not dead yet, and our library is supposed to run there and make russian grandmas happy. As you can guess, we rely on babel's preset-env a lot. We also don't want our code to be 55% babel helpers, so we use babel's transform-runtime — it should make babel import someHelper...
Vladimir Klepov as a...
Did I just build a better useCallback? Edit: the technique initially proposed in this post was not concurrent-mode safe. I've added a new...
over a year ago
16
over a year ago
Edit: the technique initially proposed in this post was not concurrent-mode safe. I've added a new section describing a fix to this problem. Thanks to the readers who noticed it! useCallback has always been one of my least favorite hooks: it does not provide much value over...
Vladimir Klepov as a...
10 Design Rules for Programmers For some reason, many developers disdain design. We are programmers, we are smart and rational, and...
over a year ago
15
over a year ago
For some reason, many developers disdain design. We are programmers, we are smart and rational, and we think technically. Designers are weird and artistic, they wear black sweaters and long scarves, they are no match to us. I never quite understood how you can ignore design if...
Vladimir Klepov as a...
So you think you know everything about React refs React refs appear to be a very simple feature. You pass a special prop to a DOM component, and you...
over a year ago
15
over a year ago
React refs appear to be a very simple feature. You pass a special prop to a DOM component, and you can access the current DOM node for that component in your JS. This is one of those great APIs that work just the way you'd expect, so you don't even think about how, exactly, it...
Vladimir Klepov as a...
Advanced Promise Coordination: Rate Limiting In the previous post we learnt to serialize and concurrecy-limit promise-based operations in js....
over a year ago
15
over a year ago
In the previous post we learnt to serialize and concurrecy-limit promise-based operations in js. This time we dive further and handle rate limiting. What Exactly to Rate Limit Let's get terminological matters out of the way first. Promises represent operations that last a certain...
Vladimir Klepov as a...
Advanced Promises Coordination: Serialization and Concurrency Limiting I'm sure you can chain promises with doBefore().then(() => doAfter()) and even run multiple promises...
over a year ago
15
over a year ago
I'm sure you can chain promises with doBefore().then(() => doAfter()) and even run multiple promises in parallel using Promise.any. However, chaining an unknown count of homogenous promises is trickier. Let me teach you to serialze promises like a pro! Suppose we want a list of...
Vladimir Klepov as a...
7 things you may not know about useState Doing code reviews for our hook-based project, I often see fellow developers not aware of some...
over a year ago
15
over a year ago
Doing code reviews for our hook-based project, I often see fellow developers not aware of some awesome features (and nasty pitfalls) useState offers. Since it's one of my favourite hooks, I decided to help spread a word. Don't expect any huge revelations, but here're the 7 facts...
Vladimir Klepov as a...
How useRef turned out to be useMemo's father It's no secret that react's useCallback is just sugar on top of useMemo that saves the children from...
over a year ago
15
over a year ago
It's no secret that react's useCallback is just sugar on top of useMemo that saves the children from having to see an arrow chain. As the docs go: useCallback((e) => onChange(id, e.target.value), [onChange, id]); // is equivalent to useMemo(() => (e) => onChange(id,...
Vladimir Klepov as a...
Become the master of your eslint with no-restricted-syntax The other day I was doing my normal thing trying to force import '*.css' to be the last import in a...
over a year ago
15
over a year ago
The other day I was doing my normal thing trying to force import '*.css' to be the last import in a file, which ensures a predicatbale CSS order. I spent hours looking for a eslint plugin to do that, but with little luck. Without getting into too much details: The built-in...
Vladimir Klepov as a...
useEffect sometimes fires before paint useEffect should run after paint to prevent blocking the update. But did you know it's not really...
over a year ago
15
over a year ago
useEffect should run after paint to prevent blocking the update. But did you know it's not really guaranteed to fire after paint? Updating state in useLayoutEffect makes every useEffect from the same render run before paint, effectively turning them into layout effects....
Vladimir Klepov as a...
Don't trust JS library size, min+gzip Many modern front-end libraries and apps obsess over their bundle size. It’s a noble pursuit — an...
over a year ago
15
over a year ago
Many modern front-end libraries and apps obsess over their bundle size. It’s a noble pursuit — an app that uses smaller libraries has less bloat, loads faster, and the users are happier. We can agree to that. Measuring the impact of a library on the app’s bundle size sounds easy,...
Vladimir Klepov as a...
Not Sucking at TypeScript: 3 Tips I have spent three years developing in TypeScript, but sometimes it is owerwhelming. I'm sitting...
over a year ago
15
over a year ago
I have spent three years developing in TypeScript, but sometimes it is owerwhelming. I'm sitting there with all those little "fuck-fuck-fucks" in my head, thinking of how I'd great it would be to burn the annotations, change the extensions to .js and get out of this nighmare...
Vladimir Klepov as a...
How I made banditypes, the smallest TS validation library I open-sourced banditypes — the smallest runtime validation library for TS / JS. It manages to fit...
a year ago
14
a year ago
I open-sourced banditypes — the smallest runtime validation library for TS / JS. It manages to fit all the basic functionality into an astounding 400 bytes. For reference, the popular zod and yup libraries are around 11KB, superstruct measures 1.8KB for the same set of...
Vladimir Klepov as a...
Two practical uses for capture event listeners Normally, JS event are handled while bubbling up the DOM tree, and we've all had the pleasure to...
over a year ago
14
over a year ago
Normally, JS event are handled while bubbling up the DOM tree, and we've all had the pleasure to catch an event from a child node on its parent. You'd even be excused for thinking that's the only way DOM events move. Many also know there's something else — events start at the...
Vladimir Klepov as a...
Svelte stores: the curious parts We've already learnt a lot about svelte's reactivity system — the primary way to work with state in...
a year ago
14
a year ago
We've already learnt a lot about svelte's reactivity system — the primary way to work with state in svelte components. But not all state belongs in components — sometimes we want app-global state (think state manager), sometimes we just want to reuse logic between components....
Vladimir Klepov as a...
5 coding interview questions I hate I’ve taken part in well over a hundred tech interviews now, on both sides. Some were fun, and some...
over a year ago
14
over a year ago
I’ve taken part in well over a hundred tech interviews now, on both sides. Some were fun, and some were pure cringe. I’ve been asked if I have kids (supposedly, people with children won’t have time to job hop), and if “I bet my ass I cost that much”. Fun times. But today I’d like...
Vladimir Klepov as a...
Simpifying AngularJS controllers with ES5 get / set I've been developing an AngularJS application for the past year — and voila! here I am, alive and...
over a year ago
14
over a year ago
I've been developing an AngularJS application for the past year — and voila! here I am, alive and well. I'm not some crazy old fuck who thinks AngularJS is a promising new technology. Nor have I been waiting to publish this post for 3 years. It's just how things turned up for me....
Vladimir Klepov as a...
Another Week with Bad Software In the midst of my September job hop I headed to Kazan for the weekend. I don't know exactly why —...
over a year ago
14
over a year ago
In the midst of my September job hop I headed to Kazan for the weekend. I don't know exactly why — probably because I could. I had a hotel booked via booking.com, but once I arrived there the receptionist told me it was the first time he's heard of my booking, and he told me that...
Vladimir Klepov as a...
Zero-setup bundle size checker We all love keeping bundle size under control. There are many great tools that help you with that —...
over a year ago
14
over a year ago
We all love keeping bundle size under control. There are many great tools that help you with that — webpack-bundle-analyzer, bundlesize, size-limit, what not. But sometimes you you're lazy, or you're stuck choosing the tool, or the project is too small to justify spending extra...
Vladimir Klepov as a...
Go beyond eslint limits with these 3 tricks My current obsession with statically checking JS code got me to appreciate eslint even more....
over a year ago
14
over a year ago
My current obsession with statically checking JS code got me to appreciate eslint even more. Recently, I've shown you how to use no-restricted-syntax to lint almost anything. Still, like any tool, eslint has its limits — often a precise rule bends eslint too much, and is not...
Vladimir Klepov as a...
Open source starter pack for JS devs So you've decided to open-source your project. Amazing! Bad news first: writing code is only the...
over a year ago
14
over a year ago
So you've decided to open-source your project. Amazing! Bad news first: writing code is only the beginning. The information for library authors on the web is surprisingly fragmented, so I've decided to put together a list of things to keep in mind when open-sourcing a JS...
Vladimir Klepov as a...
Thanks React, I'm fine with an imperative setInterval Like many of you, I've read Dan Abramov's excellent article, making setInterval declarative with...
over a year ago
14
over a year ago
Like many of you, I've read Dan Abramov's excellent article, making setInterval declarative with React hooks. It's a great introduction to hook thinking and gotchas, highly recommended to any react dev. But by now the insistence on being declarative in every hook ever has gone...
Vladimir Klepov as a...
Are many useStates better than useState(object)? Lately I've converted a lot of class components to functional. One question left me curious every...
over a year ago
14
over a year ago
Lately I've converted a lot of class components to functional. One question left me curious every time — why do I feel like splitting the old class state into so many useState(atom) — one for each state key? Is there any real benefit in it? Should I just leave a single...
Vladimir Klepov as a...
Making sense of TypeScript using set theory I've been working with TypeScript for a long long time. I think I'm not too bad at it. However, to...
over a year ago
14
over a year ago
I've been working with TypeScript for a long long time. I think I'm not too bad at it. However, to my despair, some low-level behaviors still confuse me: Why does 0 | 1 extends 0 ? true : false evaluate to false? I'm very ashamed, but I sometimes confuse "subtype" and...
Vladimir Klepov as a...
Using global memoization in React When our React apps get slow, we usually turn to useMemo to avoid useless job on re-render. It’s a...
over a year ago
13
over a year ago
When our React apps get slow, we usually turn to useMemo to avoid useless job on re-render. It’s a hammer that often works well, and makes it hard to shoot yourself in the foot. But useMemo is not a silver bullet — sometimes it just introduces more useless work instead of making...
Vladimir Klepov as a...
OOP for FP lovers: Simplistic Dependency Injection With all the enthusiasm around functional design in javascript community, we've come to reject the...
over a year ago
13
over a year ago
With all the enthusiasm around functional design in javascript community, we've come to reject the concepts whose names remind us of object-orientation. We throw constructors, methods and classes out of the window because they seem to smell of bank cubicles, water coolers and...
Vladimir Klepov as a...
Why you Might Want to Extend React Components Do not extend components. If there is anything React community agrees upon, this is it. Use HOCs....
over a year ago
13
over a year ago
Do not extend components. If there is anything React community agrees upon, this is it. Use HOCs. Use state managers (and their connector HOCs). Use render props. Do not inherit. Remember, composition over inheritance! Obey your guru. Once upon a time, a developer extended his...
Vladimir Klepov as a...
Major Garbage Producers in JS The reckless coding culture of JS favors producing garbage. In real life, if you're environmentally...
over a year ago
13
over a year ago
The reckless coding culture of JS favors producing garbage. In real life, if you're environmentally conscious (hey there, my European readers), you probably do all sorts of crazy thinks to cut down on garbage — reject plastic bags in a supermarket, recycle bottles, keep the paper...
Vladimir Klepov as a...
What is a react component, anyways? I used to teach a class on React. There’s no better way to start a hands-on course than “Let’s write...
over a year ago
13
over a year ago
I used to teach a class on React. There’s no better way to start a hands-on course than “Let’s write a simple component!”. But time after time I hear — “Vladimir, what’s a component, anyways?”. Bah, what a question! It’s a react thingie. React apps are made of components. Why do...
Vladimir Klepov as a...
Why I prefer JS for front-end build automation Every front-end project involves some automation to build it, test it, lint it, run dev servers,...
over a year ago
13
over a year ago
Every front-end project involves some automation to build it, test it, lint it, run dev servers, measure bundle size, and what not. npm scripts are fine for one-liners, but as the workflows grow more complex — run these things in parallel, then do something else, but only if...
Vladimir Klepov as a...
SemVer: The Tricky Parts Semantic versioning, is the way to version packages in JS ecosystem. I always thought I understood...
over a year ago
13
over a year ago
Semantic versioning, is the way to version packages in JS ecosystem. I always thought I understood semver, but that illusion disappeared once I started maintaining libraries myself. Semver has tricky edge cases where it's unclear what the new version number should be: Should you...
Vladimir Klepov as a...
Five Tricks for Debug-Logging in JavaScript Cheer up, today is a quick tip day. No rants, no motivation, no existentialism — just a few simple...
over a year ago
12
over a year ago
Cheer up, today is a quick tip day. No rants, no motivation, no existentialism — just a few simple tricks you can use right now. We'll be talking about console.log and friends for debugging javascript, mostly in the browser. If you don't use devtools debugger — try it, but I'm...
Vladimir Klepov as a...
Ditch google analytics now: 7 open-source alternatives I love writing, and I also love data. When starting my blog, I integrated Google Analytics — it's...
over a year ago
12
over a year ago
I love writing, and I also love data. When starting my blog, I integrated Google Analytics — it's free, easy to set up (just drop a few tags on the page), and that's what I knew back then. I did not enjoy it being run by a big corporation, but I was too lazy to research the...
Vladimir Klepov as a...
Extravagantly fast rendering with React benders The other day I was working on a React-based library of huge, reusable SVG images, and I ran into...
over a year ago
12
over a year ago
The other day I was working on a React-based library of huge, reusable SVG images, and I ran into performance problems. Just kidding, I've never had a problem I'm solving here, but I've had great fun working around it. I wanted to make components producing mostly static DOM as...
Vladimir Klepov as a...
Good advice on JSX conditionals Conditional rendering is a cornerstone of any templating language. React / JSX bravely chose not to...
over a year ago
12
over a year ago
Conditional rendering is a cornerstone of any templating language. React / JSX bravely chose not to have a dedicated conditional syntax, like ng-if="condition", relying on JS boolean operators instead: condition && <JSX /> renders <JSX /> iff condition is truthy, condition ?...
Vladimir Klepov as a...
Make useRef lazy — 4 ways I love useRef, but it lacks the lazy initializer functionality found in other hooks (useState /...
over a year ago
12
over a year ago
I love useRef, but it lacks the lazy initializer functionality found in other hooks (useState / useReducer / useMemo). useRef({ x: 0, y: 0 }) creates an object { x: 0, y: 0 } on every render, but only uses it when mounting — it subsequent renders it's thrown away. With useState,...
Vladimir Klepov as a...
Why I always wrap Context.Provider and useContext React context is a cool feature, and I use it a lot for injecting configuration and making container...
over a year ago
12
over a year ago
React context is a cool feature, and I use it a lot for injecting configuration and making container / child component APIs (think <RadioGroup /> + <RadioButton />). Unfortunately, out of the box Context comes with a limiting and not very convenient API. In most cases, I choose...
Vladimir Klepov as a...
useLayoutEffect is a bad place for deriving state Today we'll talk about updating state inside useLayoutEffect in reaction to prop changes. Will it...
over a year ago
10
over a year ago
Today we'll talk about updating state inside useLayoutEffect in reaction to prop changes. Will it work? Is it safe? Are there better ways to implement such state changes? TLDR: it works, but leaves you with an extra DOM update that may break stuff. As we all know, useLayoutEffect...
Vladimir Klepov as a...
Seven habits of bad interviewers I’ve been to plenty of bad interviews. Sometimes, only some questions are bad, but usually it goes...
over a year ago
10
over a year ago
I’ve been to plenty of bad interviews. Sometimes, only some questions are bad, but usually it goes further than that. Bizarre questions like “what’s the difference between a number and an array” are just a symptom of deeper issues. Let’s take a step back — why are we...