10 tips to avoid annoying if/else structures in your code

Опубликовано: 04 Апрель 2026
на канале: Codeur Senior
38,346
1.5k

➜ 🎁 Discover Angular coding in Big Tech - 7 days free: https://skool.com/angular-senior-room

When I started freelancing, my biggest fear was disappointing the developer teams I was teaching.

To overcome this fear, I took two years to read all the best-known coding books on Amazon.

What struck me most?

A strange piece of advice from the author of the best-selling book Clean Code, Robert C. Martin...
He recommended using polymorphism instead of the if/else conditional structure...

Enjoy watching,

Simon.

00:00: Introduction
02:24: Replacing if/else with a Substitution Algorithm
04:10: Replacing if/else with a Condition
04:58: Replacing if/else with a Guard Clause
06:33: Replacing if/else with a Filter
07:39: Replacing if/else with an Optional Chaining Operator
08:40: Replacing if/else with a Boolean Constructor
10:36: Replacing if/else with a Null Coalescing Operator
12:28: Replacing if/else with a Variable Extraction
13:33: Replacing if/else with a Value Object
14:46: Replacing if/else with Polymorphism
15:31: Replacing if/else with a Mapping Object