Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

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

206,841 Aufrufe • vor 1 Jahr •via X (Twitter)

10 Kommentare

Profilbild von George Moller
George Mollervor 1 Jahr

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 ↓

Profilbild von PATRYK
PATRYKvor 1 Jahr

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.

Profilbild von Vlad Tansky
Vlad Tanskyvor 1 Jahr

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

Profilbild von xavi
xavivor 1 Jahr

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

Profilbild von dcodes 🦀
dcodes 🦀vor 1 Jahr

just use zod

Profilbild von Hamilton Greene 🐷🦔
Hamilton Greene 🐷🦔vor 1 Jahr

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.

Profilbild von Remus
Remusvor 1 Jahr

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

Profilbild von Proziam
Proziamvor 1 Jahr

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

Profilbild von Ndeye Fatou Diop 🚢 💻 | DEV | 🇸🇳🇫🇷
Ndeye Fatou Diop 🚢 💻 | DEV | 🇸🇳🇫🇷vor 1 Jahr

💯 This makes it super hard to read the code

Profilbild von Seve
Sevevor 1 Jahr

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

Ähnliche Videos