I would never say my example is a good practice in a sense of moodle. But I would say, those code will help anyone to understand how moodle file system works! And how we can use the parameters to call a file in moodle way.
Unfortunately moodle documentation doesn't explain straight forward with easy example and that's why we have to spend time in forum with this kind of topics.
"There is no benefit to have lots of resources, if we don't know why/which/how to use them"