An interesting proposal by Nickas Millard on how to improve code by reducing the use of If-Else.
I doubt If-Else will go away, but Nickas gives solid solutions on how not to use them.
In the Swift world that I live in, the expansion of the Swift Case statement has greatly diminished the use of If-Else. Personally, with the use of the Guard statement, my code immediately takes care of error states like out of range or bad parameters (a common use of Else clause) at the start of a code block. This also greatly reduced the number of Else clauses.
No comments:
Post a Comment