Chapter 11. Debugging

Microsoft introduced a new debugger from version Dynamics NAV 2013. The purpose of the revamped debugger is to allow the IT persons to easily pinpoint the problem any specific user is facing while using the software. For example, conditional breakpoints, debugging other user sessions, and debugging C/AL code in the Windows client instead of incomprehensible C# code. All these new features will convert the debugging experience to a happy experience.

The following topics are covered in this chapter:

  • The art of debugging
  • Starting the debugger
  • Placing breakpoints
  • Line-by-line execution

The art of debugging

By definition, debugging is a methodical process of finding and reducing the number of bugs in an application. Normally, the first step in debugging is to attempt to reproduce the problem. On some occasions, the input of the program may need to be simplified to make it easier to debug. Then, the debugger tool is used to examine the program stats (values of variables, call stacks, and so on) to track down the origin of the problem(s), and, finally, fix it.

Debugging, however, can do so much more than just solving issues. It is a fantastic way to understand how an application works. You could just open the involved object, read the written code, and follow it up. However, it will be hard.

First of all, Dynamics NAV code is run after an event occurs. If you take a look at an object, you will see code in the events, but it will be hard to know when an event occurs or which event is the one that first causes the code to be executed.

It will also be hard to just read the code because you don't know which values a variable is taking. If you turn the debugger on, you read the code with a specific example that makes variables take specific values. This is really helpful!

Of course, this means that, depending on specific variable values, some lines of the code won't be executed and you won't be able to follow them. Therefore, you will have to create significant and varied examples in order to cover all (or almost all) code in a given object.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.189.7