Notes

Plan for chaos

I've been building web and mobile apps for over a decade. If there's one rule that has saved me time and again, it's this:

Always plan for chaos.

Not “just in case.” Not “later.” Right now—on every screen, every API call, every user action.

Things will break. Networks drop. APIs return garbage. Users tap buttons 15 times while switching tabs. Devices go offline mid-request. Your app doesn't live in a perfect world—so your code shouldn't assume one.

An API call takes 12 seconds—and your UI hangs while the user stares.

The backend changes a field name—and half your screen goes blank.

A user pastes a 5,000-character emoji string into a text box—and crashes the view.

A slow connection drops mid-image load—and you show a broken layout.

A mobile device loses network—but you're still waiting on that fetch call.

I've seen all of this. Often in production.

Early in my career, I used to test on my fast laptop, perfect Wi-Fi, happy-path flows. Everything looked great… until it didn't.

Now I plan for chaos as a default. Here's how that plays out in my work,

Design for Loading and Errors First

Before I style the “happy” state of a screen, I build:

  • Loading skeletons or spinners
  • Error messages and retry buttons
  • Empty state visuals

If I can't handle those three states gracefully, I'm not done.

Never Trust APIs, Even Ours

I assume every API I use will break or change. So I,

  • Validate API responses before rendering
  • Fallback to defaults if data is missing
  • Use type guards to protect against undefined/null
  • Keep UI flexible—if a string turns out longer than expected, the layout shouldn't break

Also log everything that looks suspicious.

Debounce and Throttle Aggressively

I've seen users spam buttons and crash modals. I throttle scroll handlers, debounce search inputs, and disable buttons once clicked—everywhere. It's not paranoia. It's experience.

Account for Offline and Poor Networks

Especially on mobile, users lose connection a lot more than we assume.

  • Cache API responses when possible
  • Show friendly offline banners
  • Avoid features that break without connectivity or warn the user clearly

Feature Flags and Safe Fallbacks

I wrap risky features in flags. If something fails in production, I can turn it off instantly. That's saved us on more than one release night.

A Crash That Taught Me

One time, our mobile app crashed for hundreds of users because the backend returned a string "42" instead of a number 42. I hadn't added type checks, and React Native choked when trying to do math on a string.

It was a tiny bug. It broke the whole screen.

Now I use type-safe fetch wrappers and runtime guards because I learned the hard way.

Planning for Chaos Is a Skill

This mindset separates early career devs from veterans. It's not about being paranoid it's about respecting the reality of the real world. Phones overheat. Servers misbehave. Users surprise you. Chaos will happen.

Planning for it means:

  • Faster debugging
  • Less production stress
  • Better UX

And a reputation as the person whose code just works.

If you're building interfaces, you're the last line before the user sees chaos. You can't stop the storm but you can build a shelter.

Plan for chaos. Handle the weird. Expect failure. And make sure the app still smiles through it.