U
U
Urukhayy2017-10-25 17:01:33
Programming
Urukhayy, 2017-10-25 17:01:33

The easiest and fastest way to identify the cause of a bug?

Given: Large recursive function of the form:

Функция "А"{
    Цикл 1{
        Цикл 2{
            Вызов функции "А" в зависимости от условия 1
            Вызов функции "А" в зависимости от условия 2
        }
    }
}

The output result is not equal to what is required. What is the easiest way to find a bug?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2017-10-25
@AlexMaxTM

Write to the logs each iteration with a detailed description of what parameter the function was called with and what values ​​of the counters the loops have. Then analyze the logs and see from what point the incorrect results of work begin.

Функция "А"{
// print_log('Вызов функции с параметрами: ')
    Цикл 1{
// print_log('Цикл 1: итерация N')
        Цикл 2{
// print_log('Цикл 2: итерация M')
            Вызов функции "А" в зависимости от условия 1
            Вызов функции "А" в зависимости от условия 2
        }
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question