Abdul - there are a few issues with your example code, which you might want to fix, before sharing it as an example of good practice.
Fristly, you should never be accessing $_GET params directly - Moodle has built-in optional_param / required_param functions to deal with this.
Secondly, you bypass the FilesAPI by using SQL queries directly into the mdl_files table.
Thirdly, you are using the deprecated get_context_instance function instead of context_xx::instance functions.
Fourthly, you completely bypass the pluginfile.php mechanism for serving files securely from within Moodle (which makes it a terrible example in this case, where someone is specifically asking how to use the correct pluginfile.php mechanism for serving files).
That's all I've spotted from a quick glance.
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"
But the problem is that, as outlined above, your code does not demonstrate how to use parameters to call the file in a Moodle way - it shows how to bypass the Moodle way and retrieve files directly.
Yes, the documentation could be improved - I think it is great that Andy Normore started off the local/filemanager example as a demo of how to use the filemanager and access files within Moodle (I extended it and corrected some of the problems in my version here https://github.com/davosmith/filemanager ). Maybe when I have some spare time, I will look at updating the docs at http://docs.moodle.org/dev/File_API and http://docs.moodle.org/dev/Using_the_File_API_in_Moodle_forms or maybe just provide an extra page with a simple worked example in it. However, there are also lots of examples of how to use the files API inside Moodle core - take a look at the code for mod/resource for a reasonably straightforward example.