Do you consider this technique “BAD”?

前端 未结 28 1442
借酒劲吻你
借酒劲吻你 2021-02-02 10:57

Sometimes you need to skip execution of part of a method under certain non-critical error conditions. You can use exceptions for that, but exceptions generally are not

28条回答
  •  梦谈多话
    2021-02-02 11:46

    Its a very strange idiom. It uses a loop for something its not intended and may cause confusion. I'd imagine this is going to span more than one page, and it would be a surprise to most people that this is never run more than once.

    How about using more usual language features like functions?

    bool success = someSensibleFunctionName();
    
    if(success)
    {
       ...
    }
    
    someCommonCodeInAnotherFunction();
    

提交回复
热议问题