Super-commenting your code




A small change I have been making to my development lately is the means of commenting my load script in Qlik, moving away from the typical single- and multi-line comments  (//, /* ... */). While everybody knows that commenting your code is a best practice, for about the same amount of effort, you can make the code easier to debug and embed your comments in the data itself.

TRACE

Use TRACE statements in place of standards comments denoting what a section of code accomplishes or to outline multi-step transformations. Standard single- and multi-line comments do not appear in the reload log, which makes it harder than necessary to tie an error back to its place in the script. Unlike comments, TRACE statements are visible in the reload log. You probably already knew they were visible in the progress window, during an on-demand reload, which is especially helpful for troubleshooting in Qlik Sense, where detailed reload logs are not readily available. They can also give you a general idea of what loads are contributing most to the reload time during development.

// Invisible ink in the reload log
TRACE Visible in the progress window, as you know, but also the reload log;

COMMENT TABLE/FIELD

Use COMMENT TABLE/FIELD in place of single-line comments explaining field- or table-level business logic. Standard single-line comments remain only in the code and are not portable: they don't go where the data they describe goes. Table and field comments are accessible in the Table Viewer and some places in the UI and are baked into QVD metadata, which may save the trouble of looking back at a QVD generator's logic.

COMMENT TABLE Example WITH 'This table is super-commented';
COMMENT FIELD ExampleField WITH 'This field is super-commented';
TAGS: Qlik Sense, QlikView, Data Model, Productivity, Load Script