Загрузка видео...

Не удалось загрузить видео

На главную

❌ Avoid deeply nested validations that are hard to read. ✅ Instead use invariants.

207,021 просмотров • 2 лет назад •via X (Twitter)

Комментарии: 10

Фото профиля George Moller
George Moller2 лет назад

I've been working professionally with React and JavaScript for more than 8 years and I compiled all my knowledge into 100+ infographics and 70+ video tutorials just like this one. Check them out ↓

Фото профиля PATRYK
PATRYK2 лет назад

Don’t follow this advice. It makes your code less readable, it confuses other developers and your IDE. This level of abstraction is not helping anybody. Just use early return.

Фото профиля Vlad Tansky
Vlad Tansky2 лет назад

Nice, but wouldn’t it be easier to read code with if(!condition) throw new Error(“some message”) Instead of creating abstraction?

Фото профиля xavi
xavi2 лет назад

Just use fail fast/ early return and you’ll avoid that level of abstraction.

Фото профиля dcodes 🦀
dcodes 🦀2 лет назад

just use zod

Фото профиля Hamilton Greene 🐷🦔
Hamilton Greene 🐷🦔2 лет назад

I don't like this - you're hiding important control flow inside deeply nested functions. The caller must now know that implicitly your functions use exception control flow and throw on certain conditions (also hidden). Guards (if not x return) are usually better.

Фото профиля Remus
Remus2 лет назад

Dude an "any" wrapper function? That's scares the shit out of me

Фото профиля Proziam
Proziam2 лет назад

I have to know, what are you using for the animations and graphics? Looks clean

Фото профиля Ndeye Fatou Diop 🚢 💻 | DEV | 🇸🇳🇫🇷
Ndeye Fatou Diop 🚢 💻 | DEV | 🇸🇳🇫🇷2 лет назад

💯 This makes it super hard to read the code

Фото профиля Seve
Seve2 лет назад

"early bail" or "early return" is far better terminology

Похожие видео