Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Alex Pushkarev
Alex Pushkarev

Posted on

     

Fix my code! Chain of if-else statements.

How to get rid of a chain of if-else statements in your code? There're several ways.

👉Ignore it

Not all the code that you write can and has to be pretty and clean. Sometimes it just doesn't worth investing into making a particular code cleaner. And don't forget that any refactoring creates risk of breaking a working code.

👉Design patterns

GoF patterns offer several different ways to deal with if-else chains. Check them out!

👉Use loop

Sometimes it is possible to replace if-else statements with a loop. On the video below I show how to do that

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Currently, I am holding the position of Senior Software Engineer, but I prefer to consider myself a full-stack engineer.My passions are quality and efficiency. Agile fan and XP practitioner.
  • Joined

More fromAlex Pushkarev

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp