View Single Post
08-31-16, 06:12 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Benio View Post
I though that my note about tainted global is clear enough.
It's just for clarity:
Not good enough. If you're going to call it an example, it should be a good example of working code. People will copy/paste "example code" without understanding it fully (or at all) and if your code does things wrong, so will theirs. Doing things wrong doesn't provide "clarity" -- it's just "doing things wrong".

Originally Posted by Benio View Post
It's util. Util (or utility) is indented to be used multiply times.
This means, that it is highly propable that a few addons will use sam utility.
Then we can just use already existing one.
If you intend for this to be a reusable library, write it as a proper library and make an actual release instead of a forum post.

If you intend for the code to be copied and pasted into addon files, it should be entirely local, and not create any globals at all. There's not nearly enough overhead to justify putting this in the global namespace, especially with some of the worst global names possible.

Originally Posted by Benio View Post
Clarity. Some people likes to see what function returns. However you're absolutelly free to remove it, if you only wish.
Again, this doesn't provide "clarity". It just adds clutter and confusion. When you post "example code" as a snippet in a forum post, you should be aware that 99.9999999999% of the people who are going to use it will not have a good understanding of the language or the API, and will just use the code as-is, probably without even reading it. Using bad coding paradigms and redundant/unnecessary/inefficient code is the opposite of helpful.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote