PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
New WINDEV 27 feature!
  • In this lesson you will learn the following concepts
  • What is an audit?
  • Static audit
  • Table control (UI)
  • Procedure not run
  • Orphan element
  • Cleaning the project
  • Dynamic audit
Lesson 6.2. Project audits
In this lesson you will learn the following concepts
  • What is an audit and what is its purpose?
  • Starting and analyzing the static audit.
  • Starting and analyzing the dynamic audit.
Lesson duration

Estimated time: 15 mn
Previous LessonTable of contentsNext Lesson
What is an audit?
Audits provide a set of features used to:
  • automatically improve the quality and performance of a project.
  • monitor how it is put into production.
Two types of audits are available:
  • The static audit. The static audit analyzes a project and its elements. This audit is performed from the project editor.
  • The dynamic audit. The dynamic audit analyzes the behavior of a project during its execution. This audit can be performed in test mode or in the production environment.
We will run these audits on the "WD Optimization" project.
Static audit
The static audit is a feature of the environment used to analyze the source code of a project in order to detect various problems and to propose improvements.
  • To start the static audit on the "WD Optimization" project:
    1. On the "Project" tab, in the "Audit and performance" group, expand "Static audit" and select "Start static audit".

      Note

      The static audit of the project can also be started from the project dashboard, via the "Static audit and Compilation" widget.
      Simply:
      • enable the widget if necessary (click the link "Click here to re-enable").
      • click the arrow.
        Static audit widget
    2. The wizard starts. We will define the target of the static audit.
      Static audit
    3. Select "Run the static audit on the entire project".
    4. Validate the wizard.
    5. The audit report is displayed:
      Audit report
The static audit includes:
  • The static audit of the project.
  • The audit of the content of the application library.
  • The audit of the setup content.
  • Let's take a closer look at the points presented in this report.

Table control (UI)

In our project, the audit indicates that a Table control uses the standard search mode. This mode ('Starts with') searches for elements that start with the given characters. The audit recommends using a 'Contains' filter for the search by default.
The lifecycle of some WINDEV projects span several years. Often, these projects use features that date from the time the project was created (technologies that are now outdated, or that have been replaced by more secure alternatives), options that have become useless or inefficient.
In this example, the Table control uses a 'Starts with' search that can be replaced with a 'Contains' search, which is much more common and practical for users.
  • To fix this problem:
    1. Click the [...] button to get more details. A window with UI improvement suggestions appears.
      UI improvements
    2. In "WIN_UnusedWindow", the "TABLE_Product" control can be improved. This window is used to:
      • make the improvement ("Improve"). In this case, the improvement is made immediately.
      • ignore the improvement ("Ignore"). In this case, the improvement suggestion will no longer appear.
    3. In our example, we will make this change. Click "Improve".
    4. To apply all the selected improvements (only 1 in our example), click "Confirm actions".
  • In the static audit window, click the "Refresh" button to update the audit report.

Procedure not run

In our project, the audit indicates that a procedure is never run.
In large projects, you may want to create one or more procedures to perform a process then, further to a code reorganization, the procedure is no longer used but it remains in the project. These unused procedures unnecessarily overload the resources distributed to end-users.
  • To fix this problem:
    1. Click the [...] button to get more details. The window that lists the dead codes is displayed.
      Procedure not run - Dead code
    2. The "ObsoleteProcedure" procedure is never called. This window is used to:
      • specify that the procedure is still used ("Mark as useful"). In this case, the procedure will no longer be taken into account in the audit.
      • delete the procedure if it is actually unused ("Delete").
      • see the procedure ("View").
      • find the use cases in the strings for example ("Search").
    3. In our case, this procedure is actually unused, click "Delete".
    4. A window prompts you to confirm the deletion. Click "Delete" to confirm the deletion.
    5. Close the dead code window (click "X" in the upper-right corner).
  • In the static audit window, click the "Refresh" button to update the audit report.

Orphan element

The audit indicates that our project contains an orphan element.
Just like with procedures, windows or reports can be created to run a quick test, then be saved and forgotten. The presence of orphan elements in the executable unnecessarily consumes the resources distributed to the end users.
  • To fix this problem:
    1. Click the [...] button to get more details. The window that lists the orphan elements is displayed.
      Orphan element
    2. The "WIN_UnusedWindow" window is never called. The window that lists the orphan elements is used to:
      • specify that the element is still used ("Mark as useful"). In this case, the window will no longer be taken into account in the audit. This option can be useful when using a test window specific to the development for example.
      • delete the element if it is actually unused ("Delete").
      • see the element ("View").
      • find the use cases in the strings for example ("Search").
    3. In our case, this "WIN_UnusedWindow" window is actually unused, click "Delete".
    4. Close the window of orphan elements (click the "X" in the upper-right corner).
  • In the static audit window, click the "Refresh" button to update the audit report.

Cleaning the project

Our project contains several unused files. You can clean the project to keep the necessary elements only. The executable and the setup client are not overloaded with unused images, external files (or other).
  • To fix this problem:
    1. Click the [...] button to get more details.
    2. The project cleanup wizard starts. This wizard shows the unused files that can be deleted.
    3. Go to the next step.
    4. Select the type of cleanup. You can:
      • create a zip file with the unused files.
      • move the unused files to a specific directory.
    5. Validate the option proposed by default and go to the next step.
    6. Finish the wizard.
Our project has been optimized by following all the tips of the static audit.
The static audit is used to get an overall status on the source code of your project. Our advice: run it on a regular basis!
Let's see what happens at runtime when the dynamic audit is started.
Dynamic audit
The dynamic audit is used to analyze the application execution. The audit detects problems such as:
  • Excessive memory consumption,
  • Slowness of algorithms used,
  • Errors "hidden" at runtime,
  • ...
A dynamic audit can be performed in a test environment or on a live application.
The "WD Optimization" project contains a specific window triggering errors that can be detected by the dynamic audit.
The dynamic audit and the project test will be started at the same time.
  • To start the dynamic audit on the "WD Optimization" project:
    1. On the "Project" tab, in the "Test mode" group, expand "Test mode" and select "Debug the project while the audit is enabled". The project test is run.

      Note

      The dynamic audit of the project can also be started from the project dashboard, via the "Dynamic audit" widget. To do so:
      • enable the widget if necessary (click the link "Click here to re-enable").
      • expand the arrow and select "Detailed Go of the project".
        Widget on the dashboard
      Remark: The dynamic audit is automatically run each time the application is tested via the GO option. A report is automatically displayed in the project dashboard:
      Widget on the dashboard
    2. Click the "Test window of dynamic audit" button.
    3. Click the different buttons in the window. At the end of each process, a toast message is displayed to specify that the process is over. For the "Assertion and Exception" option, an assertion is displayed: click "Continue" to see the message appear as a toast.
    4. Stop the application test.
    5. The report window of the dynamic audit appears.
Report of the dynamic audit
  • Let's analyze this window:
    • The top section of this window allows you to choose the data display options. You can:
      • choose a chronological display (respecting the order in which the events occurred) or an overall display, used to group the different types of problems. In this case, the timeline allows you to see the position and importance of the problems.
      • choose the type of problem to be displayed (error, assertion, etc.). This allows you to focus on major errors, etc.
    • The bottom section of this window displays the different events that occurred and that may cause problems in the application.
  • In this example, the dynamic audit detects several problems:
    • An overly long text assigned programmatically,
    • A SWITCH loop for which no CASE is run,
    • An assertion is triggered instead of an exception,
    • Opening a file that does not exist,
    • The assignment of a nonexistent image file to an Image control.
    For each problem, a "..." button allows you to access the details of the event. If the event is linked to a specific line of code, the button allows you to open the code editor directly at the corresponding location in order to fix the problem.
  • Close the dynamic audit window.

Note

The dynamic audit of a project can also be performed when an application is deployed on the user computers.
You can:
  • modify the application and use dbgEnableAudit to start the audit.
  • use a text file in the application directory. This solution allows you not to modify the executable. Simply create a file in the same directory and with the same name as the executable, but with a ".WX" extension.
The audit generates a ".wdaudit" file, this file must be loaded in the development environment to analyze the result.
For more details, see Dynamic audit.
Previous LessonTable of contentsNext Lesson
Minimum version required
  • Version 27
Comments
Click [Add] to post a comment