Thread: Addon Etiquette
View Single Post
04/21/14, 12:17 PM   #26
Vicster0
 
Vicster0's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 82
Originally Posted by Joviex View Post
I'll be frank. Use namespaces.

You have a bunch of stuff you want "global" put it into a class i.e. namespace.
Does LUA allow you to reference items within your namespace(s) without full qualifiers? No.
But then you are not making namespaces like Viacom.Nickelodeon.West.Post
Just be smart. You use LibAddonMenu right? Most people probablly declare it as LAM
LAM: is your namespace/entry point.
Do the same thing to wrap "globals", dont go making a

defaults = {}

in the main module space when everyone and their uncle will do the same and cause a conflict.

MyModule.defaults = {}

I prefer dot notation, though I can see the argument for simply prepends of some prefix like MM_

Either case, yes, you SHOULD mangle/prefix/tag your stuff different from everyone elses.
Yup - I agree with this. I wouldn't (personally) put too much pressure on ONLY doing it this way but I do agree with this style. I think as long as you use something to make it as unique as possible and do as Seerah said and always try to make things local whenever you can, you are at least on the right track.

Also, pro-tip, when using tools like Zgoo, namespaces can/will save you LOADS of time debugging code.
  Reply With Quote