Alternatives to ‘If-Then’ Statements

The Medium’s article “5 Alternatives to ‘If’ Statements for Conditional Branching” states: “There’s some thinking in the programming community that if should be considered harmful or a code smell. Regardless of the validity of this claim, there may be cases where if isn’t the best approach to branching, or where branching should be avoided altogether“. The article offers six programming alternatives to if...else.
Probably our readers will add business rules as another (much better!) alternative. It actually points once again to the difference in how programmers and non-programmers would represent the same business logic. You can find a good example in this old post that discussed different implementations of a very simple logical statement: “If x equals to 1, make it 2. If x is equals to 2, make it 1“.

This entry was posted in Decision Modeling. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s