Do you consider this technique “BAD”?

前端 未结 28 1444
借酒劲吻你
借酒劲吻你 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:51

    What about a functional approach?

    
            void method1()
            {
                ... some code
                if( condition )
                    method2();
            }
    
            void method2()
            {
                ... some more code
                if( condition )
                    method3();
            }
    
            void method3()
            {
                ... yet more code
                if( condition )
                    method4();
            }
    

提交回复
热议问题