Something I have done with my latest addon is try to segregate the naming within my global namespace for the addon.
In it's simplest forms, where I have a namespace of MyAddon I add a table named .UI for all UI elements.
This means there is no chance of having naming issues where a UI control and a function have the same name
Lua Code:
MyAddon = {}
MyAddon.vars = ZO_SavedVars:NewAccountWide("MyAddon_SavedVariables", 1, nil, MyAddon.defaults)
MyAddon.UI = {} -- Table for holding UI controls.
MyAddon.UI.TLW = WINDOW_MANAGER:CreateTopLevelWindow("MyAddonTopLevelFrame")
MyAddon.UI.TLW:SetAnchor(CENTER)
MyAddon.UI.TLW:SetDimensions(200, 50)
MyAddon.UI.WindowTitle = WINDOW_MANAGER:CreateControl("MyAddonWindowTitle", myAddonTopLevelFrame, CT_LABEL)
function MyAddon.WindowTitle(myText)
MyAddon.UI.WindowTitle:SetText(myText)
end
It helps me keep things tidy and is really handy when inspecting with zgoo.
MyAddon - the global namespace declared for the addon.
MyAddon.vars - this is the saved variables.
MyAddon.UI - this is for frames/controls.