CASE: use the diff function to review updates

Ever wondered how we review updates on templates? Not only do we review an update of a template functionally (what we call a functional review, simple as that), but we also will do a coding review, in which we look at the differences in coding the update will bring.

We use the diff function for that, which you can access in any template you are building right in the template editor above:
Screen Shot 2020-05-04 at 08.48.22

This function will create a view on which it’s easy to detect which lines of coding have changed, and what/how they changed.

Let’s dive into it with an easy example :slightly_smiling_face:

Let’s say we built a simple table that displays all 61-accounts:
Screen Shot 2020-05-04 at 08.44.06

But an update of the table is required: an account collection needs to be added, together with beneath the total of the accounts.

The update is prepared in another template, and looks like this:

Now, before we update the template on the original one, we just copy all the code from the update template and paste it into the editor of the original template, just like this:

and we press the diff symbol. We’ll get this view:

A: in this section, you’ll see a left and right column. The left features the line numbers of our original code, while the right shares the line numbers of the updated code.

In our example you already see our original first 4 lines have become new line numbers, which indicate new code has been added.

B: this green section indicates all new coding that has been added. Together with section A, you’ll see then that they have an impact on the line numbers as it’s all new coding.

C: if it ain’t red or green, then all is good. This just means no changes were done on the coding. So this can be skipped if needed.

D: this section has both red (the original code) and green (the update code), but the changes are extra highlighted.

For example:

  • line 5&6 (original code): the numbers that define the width of our columns are highlighted, indicating they have changed. On lines 9&10 (updated code) you indeed see the numbers have changed, as well the definition of the table changed (in input we’ll show the new table format, and in output the old one).

  • line 7 (original code): the collection in which we loop over (#61), will be changed. And on line 11 (updates code) we see that it has been replaced by the new collection services.

This is what we use on an almost daily basis. A few more examples:

So make sure you make this a habit when updating your templates! :point_up: