Why is it important to avoid overusing if/else statements in your code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why is it important to avoid overusing if/else statements in your code?

If I write neat code, no errors, wouldn’t I be fine?

19th May 2020, 12:14 AM
Tobi
4 Answers
+ 8
it will be fine, but harder to read and refactor in the future. if you don't use python (because there is no switch case in python), you can make the code much readable if you replace the if/else statement with switch case
19th May 2020, 12:15 AM
Sebastian Pacurar
Sebastian Pacurar - avatar
+ 4
here is a workaround in python Tobi but as Sebastian Pacurar stated there is no clear switch case in python https://www.google.com/amp/s/data-flair.training/blogs/python-switch-case/amp/
19th May 2020, 12:24 AM
BroFar
BroFar - avatar
+ 3
Tobi it literally is easier and faster imo in cpp In my reference above it explains more in detail
19th May 2020, 1:04 AM
BroFar
BroFar - avatar
+ 2
Sebastian Pacurar BroFar thank you guys. it is much appreciated. im currently on python. but plan on getting into c++, how does a switch case effect this?
19th May 2020, 1:02 AM
Tobi