In my view it in certainly not a strong argument, if any argument at all. This type of arguments are thrown when there is nothing else sensible left to say to support one's view.... and one reason to use CLEAR is always, because Microsoft does it in their own Codeunits.
IF NOT ISNULL(WordOLEFormat) THEN CLEAR(WordOLEFormat);suggests that it was a junior developer who coded this function.
Answers
I think it is uses as a part of good practice. For local variables it does not matter.
For global is quite important imho, as you never know when your object cease to exists. If you don't clear it up yourself in your code you are basically counting on other developers that they will clear their vars. Which may or may not happen.
I've seen many, many problems caused by using global vars and not clearing them afterwars. The scenario in most cases was - someone usd global var and at the time everyting was fine. Next time / next change the object with global var was itself declared as global var - also not cleared between call. Results - easy to guess.
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Thanks for your comment on this topic.
Have a look at Codeunit 5054 "Word Management", Function "Execute Merge". This (local) Function uses CLEAR at the end. Would you basically say the CLEAR functions issued at the end do not matter?
This is also my opinion and also what I've experienced, but on the other hand why is the code there if it is "for nothing"?
Why am I asking this: I have and had discussions with fellow programmers and one reason to use CLEAR is always, because Microsoft does it in their own Codeunits.
Thanks
Thomas
For localy defined variables CLEAR at the end of the function does not do anyting useful - exceution wise.
It could make the code a bit more easy to understand by stressing that this var is no longer used. It is also 'future proof' in this sense that if anyone wants to refactor the code and make the var global (although the trend should be exactly opposite), this CLEAR(var) may help avoid troubles.
But - looking at C5054 end of ExecuteMerge small things like this: suggests that it was a junior developer who coded this function.
In my personal opinion looking at other's code, Microsoft's inlcuding, an using it as a template, is generally a good thing, as long as there are some thoughts put behind it. Why it has been done like this? How it works? What impact does it have, here and overall? Just "Because Microsoft does it" without asking such questions, without trying to understand the code seems to be a bit mindless Ctrl+C + Ctrl+V excercise.
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Thx, fully agree.
Thomas