Another Newbie question on LCD 'trailing' characters

In my previous code with the KY-016 RGB LED and print to an I2C LCD, I encountered (not for the first time) trailing characters on a line.
I’ve read a number of code snippets online but would like to ask is there generally an accepted way of coding to ensure that trailing characters on a LCD screen are removed?
My ‘newbie’ solution is to simply print out spaces for each line to fill the DDRAM address.
Advantages, no flicker and no timing overhead. Disadvantage, remembering to do it and making sure I count characters correctly everytime to add the spaces for either 16 or 20 characters.
The article ‘7 Arduino LCD display tips and tricks’ suggests using sprintf() and using a buffer, which I guess is used to clear a line but comes with an overhead.

Any advice on a robust preferred method please?