Ask Question

How do i describe a strategy for avoiding nested conditionals.

+5
Answers (1)
  1. 10 May, 12:12
    0
    The target code is in the middle here and has a nice path up to it, however connecting the dots for the else conditions isn't quite as clear. While this code might be understandable in the heat of writing, if you decided later that userOwnsCat () needed to be true for a user to log in, and you wanted a specific error condition for it ... things get messy, quickly. Essentially, this code is not maintainable.

    There's no issue with the logic in this nested example - it's just badly organised. The very same logic can be written in such a way that it only ever goes one level deep, and there's not much to it either.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “How do i describe a strategy for avoiding nested conditionals. ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers